On 07/04/2013 06:16 PM, Ali Çehreli wrote:
> I am commenting without fully understanding the context: Both size_t and 
> double
> are 64 bit types on a 64-bit system. double.mant_dig being 53, converting from
> size_t to double loses information for many values.

Oh, bugger.  You mean that because it needs space to store the exponent, it has
a reduced number of significant figures compared to size_t?

> import std.stdio;
> import std.conv;
> 
> void main()
> {
>     size_t i = 0x8000_0000_0000_0001;
>     double d0 = i.to!double;
>     double d1 = cast(double)i;
> 
>     writefln("%s", i);
>     writefln("%f", d0);
>     writefln("%f", d1);
> }
> 
> Prints
> 
> 9223372036854775809
> 9223372036854775808.000000
> 9223372036854775808.000000

Don't understand why the error arises here, as the number of significant figures
is the same for all the numbers ... ?

Reply via email to