Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#12500 closed Bugs (fixed)

cpp_bin_float default value is NaN. But should be 0 according to the documentation.

Reported by: alex@… Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

What should be: "Default constructed cpp_bin_floats have a value of zero." http://www.boost.org/doc/libs/1_61_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_bin_float.html

This seems quite natural and convenient.

But in reality the default constructor seems to make NaN. And its code seems to confirm that as far as I can see:

cpp_bin_float() : m_data(), m_exponent(exponent_nan), m_sign(false) {}

As a result cpp_bin_float can't be used with boost::numeric::ublas::symmetric_matrix.

E.g. in boost\numeric\ublas\functional.hpp

in struct matrix_norm_inf

in real_type u = real_type ();

it is expected that the default value is 0.

Change History (3)

comment:1 by alex@…, 6 years ago

To be more precise the default constructor code is:

cpp_bin_float() BOOST_MP_NOEXCEPT_IF(noexcept(rep_type())) : m_data(), m_exponent(exponent_nan), m_sign(false) {}

After I have adjusted it in my local copy of boost:

cpp_bin_float() BOOST_MP_NOEXCEPT_IF(noexcept(rep_type())) : m_data(), m_exponent(exponent_zero), m_sign(false) {}

it seems to create zeroes. That is I've replaced exponent_nan with exponent_zero. I am just not sure if this adjustment is sufficient and consistent.

Thank you

comment:2 by John Maddock, 6 years ago

Resolution: fixed
Status: newclosed

comment:3 by Michael Shatz, 6 years ago

It's a pity. I like a previous behavior. May be, it was contradiction docs, but it was great for debugging.

Note: See TracTickets for help on using tickets.