Opened 13 years ago

Closed 13 years ago

#3052 closed Bugs (fixed)

math::signbit fails to report -0

Reported by: tegtmeye@… Owned by: John Maddock
Milestone: Boost 1.40.0 Component: math
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

math::signbit fails to report -0. Observed from boost::units, IEEE 754 handling

#include <boost/math/special_functions/sign.hpp>

#include <iostream>
#include <math.h>

int main(void)
{
  float i=copysign(0.,-1.);
  float j=boost::math::copysign(0.,-1.);
  
  std::cout << "i: " << i << ", signbit: " << std::signbit(i) << "\n";
  std::cout << "j: " << j << ", signbit: " << boost::math::signbit(j) << "\n";

  return 0;
}

Change History (2)

comment:1 by tegtmeye@…, 13 years ago

Sorry, reports on my machine [Mac 10.5, gcc version 4.0.1 (Apple Inc. build 5490)]

i: -0, signbit: 1
j: -0, signbit: 0

comment:2 by John Maddock, 13 years ago

Resolution: fixed
Status: newclosed

I believe this has already been fixed in Trunk - unfortunately it didn't make the last release - should make the next one though.

I'm closing this for now, but please reopen if the version of sign.hpp here: https://svn.boost.org/trac/boost/browser/trunk/boost/math/special_functions/sign.hpp doesn't fix the issue.

Note: See TracTickets for help on using tickets.