www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Casting float to int and int to float

reply "Garett Bass" <gtbass studiotekne.com> writes:
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 
Dec 19 2005
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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.
Dec 19 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
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
Dec 19 2005
parent reply Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
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
Dec 19 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
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
Dec 20 2005