dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Nov 5 12:03:24 UTC 2021
On Friday, 5 November 2021 at 11:54:21 UTC, Ola Fosheim Grøstad
wrote:
> On Friday, 5 November 2021 at 11:44:42 UTC, FeepingCreature
> wrote:
>> When I have to do numeric work and suspect NaNs in play, I
>> like to `feenableexcept(FE_INVALID)`. Then every time a NaN
>> arises in a computation, I get a nice SIGFPE.
>
> Yes, and the IEEE spec suggests that ones should be able to
> choose whether you get exceptions or compute with NaNs based on
> the nature of the application/computation. Regardless, as long
> as hardware follow IEEE and supports using NaN in calculations,
> you are better off playing up to the IEEE standard (for a
> modern system level language that means you should have easy
> access to both approaches).
To put some meat on this. The ideal is that you can have two
implementations for the same computation, one fast and one
robust. So ideally you should be able to do the computations with
NaNs in expressions where the NaNs can disappear and use
exceptions where they cannot disappear. If an exception occurs
you fall back to the slower robust implementation. In reality you
have to weigh in performance characteristic of the hardware so…
very much system level programming and not only a choice that can
be done on the language level.
For instance in raytracing I would want NaNs. Then I can make a
choice based on neighbouring pixels whether I want to compute it
again using a slower method or simply fill it in with the average
of the neighbours (if all the neighbours have roughly the same
colour).
More information about the Digitalmars-d
mailing list