Benchmarks - LDC vs GDC

FeepingCreature feepingcreature at gmail.com
Fri Jun 30 07:53:18 UTC 2023


On Thursday, 29 June 2023 at 04:41:54 UTC, Walter Bright wrote:
> On 6/28/2023 4:29 PM, Cecil Ward wrote:
>> Isn’t the main thing ignoring infinities and NaNs? I don’t 
>> think that’s all there is to it though. I would say, in my 
>> extremely limited exposure to floating point, that
> I forgot precisely what it did, but it takes shortcuts. I just 
> concluded "nope" to that.
>
> > if you have debugged your code then infinities and NaNs
> should not
> > be encountered anyway
>
> Famous last words.

Hey, that's what `feenableexcept(FE_ALL_EXCEPT)` is for.

```
#define _GNU_SOURCE

#include <fenv.h>
#include <stdio.h>

void main() {
   printf("infinity = %f\n", 1.0f / 0.0f);
   feenableexcept(FE_ALL_EXCEPT);
   // will crash with a float error.
   printf("infinity = %f\n", 1.0f / 0.0f);
}
```

(I thought there was a way to make it never generate 
infinities/nans in the first place, but I can't find it.)


More information about the Digitalmars-d mailing list