all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* math round woes
@ 2014-08-30  9:42 Ivan Kanis
  2014-08-30  9:55 ` David Kastrup
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ivan Kanis @ 2014-08-30  9:42 UTC (permalink / raw
  To: Emacs Development List

Hello,

I am having problem this week with org-drill failing due to a rounding
error.

(round 586514472.354) -> eval: Arithmetic range error: "round",
586514472.354

I thought I'd patch things with calc:

(require 'calc-arith)
(math-round 586514472.354) -> 586514472.354

I looked at math-round and it calls math-trunk:

(math-trunk 1.1) -> 1.1

What's going on?

I am on the emacs-24 branch.
-- 
Static from nylon underwear.
    -- BOFH excuse #57



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30  9:42 math round woes Ivan Kanis
@ 2014-08-30  9:55 ` David Kastrup
  2014-08-30  9:57 ` Andreas Schwab
  2014-08-30 10:29 ` Rüdiger Sonderfeld
  2 siblings, 0 replies; 7+ messages in thread
From: David Kastrup @ 2014-08-30  9:55 UTC (permalink / raw
  To: emacs-devel

Ivan Kanis <ivan@kanis.fr> writes:

> Hello,
>
> I am having problem this week with org-drill failing due to a rounding
> error.
>
> (round 586514472.354) -> eval: Arithmetic range error: "round",
> 586514472.354
>
> I thought I'd patch things with calc:
>
> (require 'calc-arith)
> (math-round 586514472.354) -> 586514472.354
>
> I looked at math-round and it calls math-trunk:
>
> (math-trunk 1.1) -> 1.1
>
> What's going on?

Uh, calc does calculations with its own number representation rather
than Lisp floating point numbers.  But calc cannot actually help you in
any way since the basic problem is that the result _will_ _not_ _fit_
into a Lisp integer.

If you are fine with putting it in a floating point number, use fround
rather than round.

-- 
David Kastrup




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30  9:42 math round woes Ivan Kanis
  2014-08-30  9:55 ` David Kastrup
@ 2014-08-30  9:57 ` Andreas Schwab
  2014-08-30 15:59   ` Ivan Kanis
  2014-08-30 10:29 ` Rüdiger Sonderfeld
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2014-08-30  9:57 UTC (permalink / raw
  To: Ivan Kanis; +Cc: Emacs Development List

Ivan Kanis <ivan@kanis.fr> writes:

> (require 'calc-arith)
> (math-round 586514472.354) -> 586514472.354
>
> I looked at math-round and it calls math-trunk:
>
> (math-trunk 1.1) -> 1.1
>
> What's going on?

Since you are calling an internal calc function you need to use its
internal number representation (and s/k/c/).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30  9:42 math round woes Ivan Kanis
  2014-08-30  9:55 ` David Kastrup
  2014-08-30  9:57 ` Andreas Schwab
@ 2014-08-30 10:29 ` Rüdiger Sonderfeld
  2014-08-30 20:01   ` Ivan Kanis
  2 siblings, 1 reply; 7+ messages in thread
From: Rüdiger Sonderfeld @ 2014-08-30 10:29 UTC (permalink / raw
  To: emacs-devel; +Cc: Ivan Kanis

On Saturday 30 August 2014 11:42:46 Ivan Kanis wrote:
> (round 586514472.354) -> eval: Arithmetic range error: "round",
> 586514472.354

It seems you are using GNU Emacs on a 32 bit system without wide-int support.  
Try building GNU Emacs using `--with-wide-int`.

Regards,
Rüdiger




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30  9:57 ` Andreas Schwab
@ 2014-08-30 15:59   ` Ivan Kanis
  2014-08-30 16:02     ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Kanis @ 2014-08-30 15:59 UTC (permalink / raw
  To: Andreas Schwab; +Cc: Emacs Development List

August, 30 at 11:57 Andreas wrote:

> Ivan Kanis <ivan@kanis.fr> writes:
>
>> (require 'calc-arith)
>> (math-round 586514472.354) -> 586514472.354
>>
>> I looked at math-round and it calls math-trunk:
>>
>> (math-trunk 1.1) -> 1.1
>>
>> What's going on?
>
> Since you are calling an internal calc function you need to use its
> internal number representation (and s/k/c/).

What's s/k/c?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30 15:59   ` Ivan Kanis
@ 2014-08-30 16:02     ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2014-08-30 16:02 UTC (permalink / raw
  To: Ivan Kanis; +Cc: Emacs Development List

Ivan Kanis <ivan@kanis.fr> writes:

> August, 30 at 11:57 Andreas wrote:
>
>> Ivan Kanis <ivan@kanis.fr> writes:
>>
>>> (require 'calc-arith)
>>> (math-round 586514472.354) -> 586514472.354
>>>
>>> I looked at math-round and it calls math-trunk:
>>>
>>> (math-trunk 1.1) -> 1.1
>>>
>>> What's going on?
>>
>> Since you are calling an internal calc function you need to use its
>> internal number representation (and s/k/c/).
>
> What's s/k/c?

See sed(1).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math round woes
  2014-08-30 10:29 ` Rüdiger Sonderfeld
@ 2014-08-30 20:01   ` Ivan Kanis
  0 siblings, 0 replies; 7+ messages in thread
From: Ivan Kanis @ 2014-08-30 20:01 UTC (permalink / raw
  To: Rüdiger Sonderfeld; +Cc: emacs-devel

August, 30 at 12:29 Rüdiger Sonderfeld wrote:

> On Saturday 30 August 2014 11:42:46 Ivan Kanis wrote:
>> (round 586514472.354) -> eval: Arithmetic range error: "round",
>> 586514472.354
>
> It seems you are using GNU Emacs on a 32 bit system without wide-int support.  
> Try building GNU Emacs using `--with-wide-int`.

It works, thank you! I am sure I have seen the error on a 64bit Linux,
though... 
-- 
In science the credit goes to the man who convinces the world, not to
the man to whom the idea first occurs.
    -- Francis Darwin



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-30 20:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30  9:42 math round woes Ivan Kanis
2014-08-30  9:55 ` David Kastrup
2014-08-30  9:57 ` Andreas Schwab
2014-08-30 15:59   ` Ivan Kanis
2014-08-30 16:02     ` Andreas Schwab
2014-08-30 10:29 ` Rüdiger Sonderfeld
2014-08-30 20:01   ` Ivan Kanis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.