From: Tatsuro MATSUOKA <tmmingw@gm...>  20080424 20:59:19

Hello I'm a member of the octave team and am dealing with the octave building on mingw. In the octave test , there found the question about the implementation of function of 'round'. To tell the truth, I do not fully understand the problem. The Octave thread is the following http://www.cae.wisc.edu/pipermail/helpoctave/2008April/008958.html The digest is >  The code used internally by MinGW for "round" is the following >  (http://www.koders.com/c/fidB63EAFA2C117AAFC1CF9FE9691F8DDBE4DD01A22.aspx) >  >  double >  round (double x) >  { >  /* Add +/ 0.5 then then round towards zero. */ >  return trunc ( x + (x >= 0.0 ? 0.5 : 0.5)); >  } >  >  The problem with this implementation is when x is the vicinity of bitmax: it >  leads to floatingpoint overflow (in the mantissa) and produces rounding error, >  For instance if x = bitmax, round(x) => bitmax+1, while it should return >  bitmax. >  >  Octave used to use the above implementation for MSVC, but because of >  this problem, I switched it to use the (more robust) gnulib implementation. In the octave iomappers.cc the following is exist #if defined (HAVE_ROUND) return round (x); #else if (x >= 0) { double y = floor (x); if ((x  y) >= 0.5) y += 1.0; return y; } else { double y = ceil (x); if ((y  x) >= 0.5) y = 1.0; return y; } #endif } ********************************************************************** In octave building on mingw, it has fonction 'round' and HAVE_ROUND is set and round is used. In this cases, octave bitmap test failed. > > ***** assert(bitcmp(A,Amax),bitor(bitshift(1,Amax1),bitshift(1,Amax2))); > > !!!!! test failed > > error: assert (bitcmp (A, Amax),bitor (bitshift (1, Amax  1), bitshift (1, Amax  2))) > expected > > 6.7554e+015 > > but got > > 1.1259e+016 > > values do not match > > shared variables { > > Amax = 53 > > Bmax = 9.0072e+015 > > A = 2.2518e+015 > > } > > 6.7554e+015 So I modified config.h and undfined HAVE_ROUND and make again without reconfigration. The test was succcessful because the following code was usesd #else if (x >= 0) { double y = floor (x); if ((x  y) >= 0.5) y += 1.0; return y; } else { double y = ceil (x); if ((y  x) >= 0.5) y = 1.0; return y; } #endif ====================== Regards Tatsuro 