Bug of the sqrt() compiled by DMD

Salih Dincer salihdb at hotmail.com
Sun Jun 19 20:26:27 UTC 2022


On Sunday, 19 June 2022 at 10:41:32 UTC, Johan wrote:
> An IEEE 64-bit double (D's `double`) has 52 bits of mantissa. 
> It _can_ represent the first number without loss of precision 
> because of the 4 zero bits at the end (56 - 4 = 52). It can 
> _not_ represent the second number: instead of 0x20 0000 0F90 
> 97D9, `n2` will store the value 0x20 0000 0F90 97D0, and you 
> calculate the sqrt of that.

I think the problem is not with bits. Because the size of the 
number is only twice uint.max. When integer type is changed qua 
long, the problem is fixed. Please try and see with your own eyes:

```d
alias integer = long;
```

SDB at 79


More information about the Digitalmars-d mailing list