From: Teemu Likonen <tlikonen@iki.fi>
To: Jean Louis <bugs@gnu.support>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999?
Date: Fri, 02 Apr 2021 20:41:53 +0300 [thread overview]
Message-ID: <87eefsk2hq.fsf@iki.fi> (raw)
In-Reply-To: <YGdOevnQRsMPDDcn@protected.localdomain>
[-- Attachment #1: Type: text/plain, Size: 796 bytes --]
* 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"
--
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
next prev parent reply other threads:[~2021-04-02 17:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 13:42 What is 0.01 here not 0.01 here 0.009999999999999? Jean Louis
2021-04-02 13:56 ` Stefan Monnier
2021-04-02 17:03 ` Jean Louis
2021-04-02 17:41 ` Teemu Likonen [this message]
2021-04-02 18:44 ` Jean Louis
2021-04-02 20:46 ` John Yates
2021-04-02 21:19 ` Jean Louis
2021-04-02 22:04 ` John Yates
2021-04-02 23:29 ` Jean Louis
2021-04-03 4:39 ` Arthur Miller
2021-04-03 5:36 ` Jean Louis
2021-04-03 3:56 ` Arthur Miller
2021-04-03 5:19 ` Jean Louis
2021-04-03 13:54 ` Stefan Monnier
2021-04-02 14:02 ` Eli Zaretskii
2021-04-02 17:07 ` Jean Louis
2021-04-03 4:49 ` Arthur Miller
2021-04-16 20:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-17 10:53 ` Jean Louis
2021-04-19 10:51 ` Eric S Fraga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eefsk2hq.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).