Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 20, 2005 Casting float to int and int to float | ||||
---|---|---|---|---|
| ||||
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 Re: Casting float to int and int to float | ||||
---|---|---|---|---|
| ||||
Posted in reply to Garett Bass | "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 Re: Casting float to int and int to float | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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 Re: Casting float to int and int to float | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | 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 Re: Casting float to int and int to float | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oskar Linde | 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
|
Copyright © 1999-2021 by the D Language Foundation