Re: float to int conversion

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

 



On 22 April 2013 12:12, Vincent Lefevre <vincent+gcc@xxxxxxxxxx> wrote:
> On 2013-04-22 11:58:48 +0100, David Paterson wrote:
>> It depends what you mean by "catching errors".  As far as rounding is
>> concerned you won't get an exception, or a detectable error such as a
>> NaN.
>
> There's the "inexact" exception. But contrary to invalid operations
> (and overflows, at least in rounding to nearest), the only way to
> detect it is to test the exception status flags; the numerical
> value won't say anything about the exception (unless you have some
> knowledge about it, such as you know that the value is an integer
> but you don't get an integer... But not all inexact exceptions can
> be detected in such a way).

Yes, it can help, although as you say, not in all cases.  And as you
also note, just knowing there has been an error doesn't define how to
correct it.

It's much better to prevent errors than to try to deal with them :)

Oh, and the reason it's not set for the assignment is that it's probably
done as a compile-time conversion int to float.

Regards,

David




[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