Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #121798

Re: There is no "correct" result for std::fmod across all IEEE 754 representations

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-03 13:20 +0200
Organization A noiseless patient Spider
Message-ID <20250303132024.00007cac@yahoo.com> (permalink)
References <6in6sjtgdf82rmi09a5q21l7lp19vagb4m@4ax.com> <20250301230320.000074a4@yahoo.com> <tcv6sj1c4j6643nfcfk7jp937dspbksrdf@4ax.com> <20250302110710.00003fa2@yahoo.com> <vq2mjs$vml8$1@dont-email.me>

Show all headers | View raw


On Sun, 2 Mar 2025 17:37:48 -0500
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:

> On 3/2/25 04:07, Michael S wrote:
> > On Sat, 01 Mar 2025 21:57:13 +0000
> > Mr Flibble <leigh@i42.co.uk> wrote:  
> ...
> >> My point is std::fmod is almost useless
> >> MATHEMATICALLY unless the arguments don't involve approximation,
> >> but with IEEE 754 floating point you get what you pay for.
> >>
> >> /Flibble  
> >
> > If you were saying that fmod(x/y) for big values of x/y is almost  
> 
> fmod(x,y)?

Yes, sorry.

> 
> > useless physically / engineerially then I'd tend to agree.
> > When physicist or engineer says 'double x= bar;' where bar is a
> > number that can be represented exactly in binary64 then what he
> > means (if he cared at all to think about what he means, which is
> > rare) is that he believes that x is in range (bar-ULP:bar+ULP] and
> > he hopes that probability of x being within range
> > [bar-ULP/2:bar+ULP/2] is much higher that 0.5. So, obviously, as
> > long as y is abs(y)<ULP(x) for physicist fmod(x/y) is meaningless.  
> 
> Actually, most numbers of relevance to science and engineering have a
> uncertainty which is determined by how the raw measurements were made
> from which the number was calculated, which are usually much bigger
> than 1 ULP. The only exceptions are mathematical constants. Despite
> that fact, it is in fact quite commonplace for the uncertainties to
> be small enough to make the return value of fmod() meaningful. As a
> general rule, if that weren't the case, there wouldn't be any desire
> to use fmod().
> 

My point was that for physicist fmod(x,y) is meaningless as long as
abs(y)<ULP(x).
I never said that when abs(y)>ULP(x) then fmod(x,y) is always
meaningful, just that it is a necessary condition.

Bonita's test suit consists of 50% of trivial cases (abs(y) > abs(x)),
47.7 % of meaningless cases, and only 2.3% of the cases are
potentially meaningful.


Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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