Boost logo

Boost Users :

Subject: Re: [Boost-users] Numeric_cast from int to float
From: Matthieu Brucher (matthieu.brucher_at_[hidden])
Date: 2009-01-26 13:01:23


Hi,

> I always thought that the conversion from int to float could raise an
> exception when the int can not be properly represented as a float.

Well, in this case, even casting 2 should raise an exception :|

> However, this is not what I am gettingn in version 1.33.1. For
> example, in my opinion, casting -2147483647 to a float should be
> raising an exception but boost::numerical_cast always says that the
> conversion is valid and well-formed.
>
> Obviously, my boost version is a little outdated, but I can not
> upgrade at this time due to several constraints.
>
> My question is: is this behavior either a bug (even in newer versions
> of boost) or a feature?

It's more the consequences of the IEEE float representation.

Matthieu

-- 
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net