December 20, 2005
In D, does a cast from float to int (and vice-versa) actually convert the whole part of the float to an equivalent integer value? Or does the cast merely reinterpret the bits as the other type?

Thanks,
Garett


December 20, 2005
"Garett Bass" <gtbass@studiotekne.com> wrote in message news:do7jpf$1up0$1@digitaldaemon.com...
> In D, does a cast from float to int (and vice-versa) actually convert the whole part of the float to an equivalent integer value?

Right.


December 20, 2005
Jarrett Billingsley wrote:

> "Garett Bass" <gtbass@studiotekne.com> wrote
>> In D, does a cast from float to int (and vice-versa) actually convert the whole part of the float to an equivalent integer value?
> 
> Right.

What is the "equivalent integer value" of a float that is out of the range of the integer it is casted to?

-manfred
December 20, 2005
Manfred Nowak wrote:

> What is the "equivalent integer value" of a float that is out of the range of the integer it is casted to?

The smallest representable integer. For
long: (0x8000000000000000) -9223372036854775808
int: (0x80000000) -2147483648
etc...

/Oskar
December 20, 2005
Oskar Linde wrote:
[...]
> The smallest representable integer. For
> long: (0x8000000000000000) -9223372036854775808
> int: (0x80000000) -2147483648
> etc...

Sadly, it is neither documented nor implemented this way.

-manfred
Top | Discussion index | About this forum | D home