[Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.103,2.104

Tim Peters tim_one@users.sourceforge.net
Thu, 01 Nov 2001 13:51:17 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv21887/python/Objects

Modified Files:
	floatobject.c 
Log Message:
float_abs() again:  Guido pointed out that this could screw up in the
presence of NaNs.  So pass the issue on to the platform libm fabs();
after all, fabs() is a std C function because you can't implement it
correctly in portable C89.


Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.103
retrieving revision 2.104
diff -C2 -d -r2.103 -r2.104
*** floatobject.c	2001/11/01 20:09:42	2.103
--- floatobject.c	2001/11/01 21:51:15	2.104
***************
*** 569,578 ****
  float_abs(PyFloatObject *v)
  {
! 	if (v->ob_fval < 0)
! 		return float_neg(v);
! 	else if (v->ob_fval > 0)
! 		return float_pos(v);
! 	else /* ensure abs(-0) is +0 */
! 		return PyFloat_FromDouble(+0.0);
  }
  
--- 569,573 ----
  float_abs(PyFloatObject *v)
  {
! 	return PyFloat_FromDouble(fabs(v->ob_fval));
  }