help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is 0.01 here not 0.01 here 0.009999999999999?


From: Jean Louis
Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999?
Date: Fri, 2 Apr 2021 21:44:40 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Teemu Likonen <tlikonen@iki.fi> [2021-04-02 20:42]:
> * 2021-04-02 20:03:54+0300, Jean Louis wrote:
> 
> > Not that I need the absolute internally, just the practical
> > result as we learned it in school like that 10.11 plus 0.01
> > results with 10.12 and not something else. Results are used for
> > automated version numbers (in some cases).
> 
> As you have learned, floating point numbers are not decimal numbers even
> if they are read and printed as such. For decimal mathematics you can
> use calc-eval function. Some comparison:
> 
>     ELISP> (+ 10.12 0.01)
>     10.129999999999999
> 
>     ELISP> (calc-eval "10.12 + 0.01")
>     "10.13"
> 
>     ELISP> (* 3 0.1)
>     0.30000000000000004
> 
>     ELISP> (calc-eval "3 * 0.1")
>     "0.3"

Hey, that is good to know, it spares me efforts. 

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]