[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/
- What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Stefan Monnier, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, John Yates, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, John Yates, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/02
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Arthur Miller, 2021/04/03
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/03
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Arthur Miller, 2021/04/03
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Jean Louis, 2021/04/03
- Re: What is 0.01 here not 0.01 here 0.009999999999999?, Stefan Monnier, 2021/04/03
Re: What is 0.01 here not 0.01 here 0.009999999999999?, Eli Zaretskii, 2021/04/02