From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: Floating point modulus
Date: Mon, 12 Jan 2015 12:36:18 +0100 [thread overview]
Message-ID: <20150112113617.GA13104@ypig.lip.ens-lyon.fr> (raw)
In-Reply-To: <150111113601.ZM29941@torch.brasslantern.com>
On 2015-01-11 11:36:01 -0800, Bart Schaefer wrote:
> On Jan 10, 11:10pm, Bart Schaefer wrote:
> }
> } The following patch would instead silently substitute the fmod() call
> } when using the % operator on a float.
>
> Incidentally, what's a reliable test for this that could be added to
> C01arith.ztst? I worry about rounding error differing by platform:
>
> torch% print $(( 29.1 % 13.0 ))
> 3.1000000000000014
The rounding error is due to the decimal-to-binary conversions, not to
the % operation, which, if I'm not mistaken, is necessarily exact in a
floating-point system: considering x % y, if |x| < |y|, then the result
is x, which is exact; otherwise the result is a multiple of ulp(y) and
less than |y| in absolute value, thus exactly representable.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2015-01-12 11:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-09 12:43 PATCH: hist: remove wrong NULL terminator Mikael Magnusson
2015-01-09 17:45 ` Ray Andrews
2015-01-09 18:33 ` Lawrence Velázquez
2015-01-09 18:36 ` Lawrence Velázquez
2015-01-09 19:38 ` Mikael Magnusson
2015-01-09 21:39 ` Ray Andrews
2015-01-09 22:30 ` Peter Stephenson
2015-01-09 23:39 ` Ray Andrews
2015-01-10 0:39 ` Bart Schaefer
2015-01-10 7:45 ` Ray Andrews
2015-01-10 22:04 ` Lawrence Velázquez
2015-01-10 22:50 ` Ray Andrews
2015-01-11 1:58 ` Bart Schaefer
2015-01-11 5:46 ` Ray Andrews
2015-01-11 7:10 ` Floating point modulus Bart Schaefer
2015-01-11 17:33 ` Peter Stephenson
2015-01-11 19:25 ` Bart Schaefer
2015-01-11 19:25 ` Ray Andrews
2015-01-11 20:00 ` Bart Schaefer
2015-01-11 20:58 ` Ray Andrews
2015-01-11 21:34 ` Peter Stephenson
2015-01-12 0:18 ` Ray Andrews
2015-01-12 10:03 ` Peter Stephenson
2015-01-11 19:36 ` Bart Schaefer
2015-01-11 20:01 ` Peter Stephenson
2015-01-11 20:04 ` Bart Schaefer
2015-01-11 20:25 ` Peter Stephenson
2015-01-12 0:02 ` Ray Andrews
2015-01-12 2:23 ` Bart Schaefer
2015-01-12 2:46 ` Bart Schaefer
2015-01-12 9:56 ` Peter Stephenson
2015-01-12 13:49 ` Peter Stephenson
2015-01-12 16:35 ` Bart Schaefer
2015-01-12 16:45 ` Peter Stephenson
2015-01-12 11:36 ` Vincent Lefevre [this message]
2015-01-10 7:08 ` PATCH: hist: remove wrong NULL terminator Bart Schaefer
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150112113617.GA13104@ypig.lip.ens-lyon.fr \
--to=vincent@vinc17.net \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).