Re: float to int conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/22/2013 09:25 AM, Warlich, Christof wrote:
>  
> imho, float to int conversion is wrong when the float exceeds the integer range:
>  
> $ cat test1.c
> #include <stdio.h>
> int main() {
>     float a = 1.23e24f;
>     printf("%d, %d\n", (int) a, (int) 1.23e24f);
>     return 0;
> }
>  
>  
> Is this a (known) bug, shall it be reported?

No.

   "When a finite value of real floating type is converted to an integer
   type other than _Bool, the fractional part is discarded (i.e., the
   value is truncated toward zero). If the value of the integral part
   cannot be represented by the integer type, the behavior is
   undefined."

Andrew.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux