Is 'double' a signed type? (boost type traits)

Hi, I have found some surprising behaviour with boost type traits using MSVC2012 (v11). I used boost::is_signed<T>::value where T is double and it evaluates to false, but I expected true as double can hold negative numbers. More surprisingly, I found that, for double, is_unsigned is not the inverse of is_signed, and hence this static assert produces a compiler error. BOOST_STATIC_ASSERT(boost::is_unsigned<double>::value == !boost::is_signed<double>::value); I am missing a rationale for this, or it is a bug? Thanks -- Craig -- View this message in context: http://boost.2283326.n4.nabble.com/Is-double-a-signed-type-boost-type-traits... Sent from the Boost - Users mailing list archive at Nabble.com.

On Fri, Dec 21, 2012 at 2:14 PM, cdmh
(v11). I used boost::is_signed<T>::value where T is double and it evaluates to false, but I expected true as double can hold negative numbers.
Quoting the documentation for boost::is_unsigned [1]: "Inherits: If T is an signed integer type or an enumerated type with an underlying signed integer type, then inherits from true_type, otherwise inherits from false_type." So, boost::is_signed will only ever be true for integer types (and similarly for is_unsigned). You might want to additionally use boost::is_floating_point, as AFAIK, there are no unsigned floating point types. Best, Mika [1] http://www.boost.org/doc/libs/1_52_0/libs/type_traits/doc/html/boost_typetra...
participants (2)
-
cdmh
-
Mika Fischer