issue 7006 - std.math.pow (integral, integral) crashes on negative exponents
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Wed Dec 18 00:03:14 UTC 2019
On Tuesday, 17 December 2019 at 23:29:53 UTC, Timon Gehr wrote:
> what it says on the page? (Please no more pointless
> elaborations on what common terms mean,
Well, «may» have other connotations in standard texts that in
oridinary language, so I read such texts differently than you,
obviously.
> on x86. For instance, if I added a single special case for
> std::pow(0.0,0.0) to a standards-compliant C++17 implementation
> for x86-64 with floating-point support, which values could I
> return without breaking C++17 standard compliance?)
Whatever you like. It is implementation defined. That does not
mean it is encouraged to return something random.
According to the standard x^y is defined as:
exp(y * log(x))
The problem with floating point is that what you want depends on
the application. If you want to be (more) certain that you don't
return inaccurate calculations then you want NaN or some other
"exception" for all inaccurate operations. So that you can switch
to a different algorithm. If you do something real time you
probably just want something "reasonable".
> Indeed, however it is still somewhat common for very popular
> languages:
Yes, but some have built up the standard under less demanding
regimes like ECMA, then improve on it under ISO.
I am quite impressed that C++ ISO moves anywhere (and mostly in
the right direction) given how hard it is to reach consensus on
anything related to langauge design and changes! :-)
More information about the Digitalmars-d
mailing list