Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #121746
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: There is no "correct" result for std::fmod across all IEEE 754 representations |
| Date | 2025-03-01 23:03 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <20250301230320.000074a4@yahoo.com> (permalink) |
| References | <6in6sjtgdf82rmi09a5q21l7lp19vagb4m@4ax.com> |
On Sat, 01 Mar 2025 19:27:46 +0000
Mr Flibble <leigh@i42.co.uk> wrote:
> Hi!
>
> There is no "correct" result for std::fmod across all IEEE 754
> representations.
>
> Why?
>
> #include <cmath>
> #include <iostream>
>
> int main()
> {
> std::cout << "Result of std::fmod(1.0e42, 1000.0): " <<
> std::fmod(1.0e42, 1000.0);
> }
>
> Result of std::fmod(1.0e42, 1000.0): 312
>
> The correct answer mathematically is 0 not 312 but as IEEE 754 has a
> fixed width mantissa, x is inprecise so there is no correct "precise"
> result for std::fmod(x, y) for all x & y as Bonita Montero claims
> rendering her test case utter bollocks.
>
> Given these FACTS please present actual problems with:
>
> double my_fmod(double x, double y)
> {
> if (y == 0.0)
> return x / y;
> return x - std::trunc(x / y) * y;
> }
>
> /Flibble
For x that is a closest IEEE-754 binary64 approximation of 1e42, i.e.
for 0x1.6f578c4e0a061p+139, 312 is an exact answer.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-01 19:27 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Michael S <already5chosen@yahoo.com> - 2025-03-01 23:03 +0200
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-01 21:57 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Michael S <already5chosen@yahoo.com> - 2025-03-02 11:07 +0200
Re: There is no "correct" result for std::fmod across all IEEE 754 Muttley@DastardlyHQ.org - 2025-03-02 09:17 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 Michael S <already5chosen@yahoo.com> - 2025-03-02 16:03 +0200
Re: There is no "correct" result for std::fmod across all IEEE 754 Muttley@dastardlyhq.com - 2025-03-02 16:56 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-02 15:24 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-02 17:37 -0500
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Michael S <already5chosen@yahoo.com> - 2025-03-03 13:20 +0200
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 16:25 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 16:30 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Michael S <already5chosen@yahoo.com> - 2025-03-03 18:54 +0200
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 17:11 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 18:26 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 18:20 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 19:26 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 18:33 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 19:37 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 18:46 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 19:48 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 18:50 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 19:53 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 18:58 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 20:05 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 19:09 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 20:14 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 20:27 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 19:33 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-03 20:36 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-03 19:37 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Bonita Montero <Bonita.Montero@gmail.com> - 2025-03-04 10:42 +0100
Re: There is no "correct" result for std::fmod across all IEEE 754 representations Mr Flibble <leigh@i42.co.uk> - 2025-03-04 18:24 +0000
Re: There is no "correct" result for std::fmod across all IEEE 754 representations "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-03-03 12:25 -0800
csiph-web