[Numpy-svn] r6230 - branches/fix_float_format/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sun Dec 28 21:23:28 CST 2008


Author: cdavid
Date: 2008-12-28 21:23:25 -0600 (Sun, 28 Dec 2008)
New Revision: 6230

Modified:
   branches/fix_float_format/numpy/core/src/npy_format.c
Log:
    Modify NumPyOS_ascii_format* macro so that a cast to a different type than input value can be forced if necessary.


Modified: branches/fix_float_format/numpy/core/src/npy_format.c
===================================================================
--- branches/fix_float_format/numpy/core/src/npy_format.c	2008-12-29 03:22:35 UTC (rev 6229)
+++ branches/fix_float_format/numpy/core/src/npy_format.c	2008-12-29 03:23:25 UTC (rev 6230)
@@ -236,7 +236,7 @@
  * 
  * Return value: The pointer to the buffer with the converted string.
  */
-#define _ASCII_FORMAT(type, suffix) \
+#define _ASCII_FORMAT(type, suffix, print_type) \
 char* NumPyOS_ascii_format ## suffix(char *buffer, size_t buf_size, \
 			      const char *format, \
 			      type val, int decimal) \
@@ -245,7 +245,7 @@
 		if(_check_ascii_format(format)) {\
 			return NULL; \
 		} \
-		PyOS_snprintf(buffer, buf_size, format, val); \
+		PyOS_snprintf(buffer, buf_size, format, (print_type)val); \
 		return _fix_ascii_format(buffer, buf_size, decimal);\
 	} else if (isnan(val)){ \
 		if (buf_size < 4) { \
@@ -268,6 +268,10 @@
 	return buffer; \
 }
 
-_ASCII_FORMAT(float, f)
-_ASCII_FORMAT(double, d)
-_ASCII_FORMAT(long double, l)
+_ASCII_FORMAT(float, f, float)
+_ASCII_FORMAT(double, d, double)
+#ifndef FORCE_NO_LONG_DOUBLE_FORMATTING
+_ASCII_FORMAT(long double, l, long double)
+#else
+_ASCII_FORMAT(long double, l, double)
+#endif



More information about the Numpy-svn mailing list