summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-01-20 13:06:55 -0700
committerCharles Harris <charlesr.harris@gmail.com>2013-01-20 13:27:12 -0700
commite5f4f8283e7721b0a72b621b765c42d7d7866f4f (patch)
tree6ec1676af97d5a74ccfbba05d7554a23c82abe44
parent56b06fe5bf20d11ca8188a00333ddf69ed8b2e42 (diff)
downloadnumpy-e5f4f8283e7721b0a72b621b765c42d7d7866f4f.tar.gz
BUG: gh-2935, fix printing of scalar float -0.0.
The issue was that the string value of scalar floating types equal to -0.0 lacked a trailing ".0". >>> print np.float64(-0.0) -0 The problem resulted from using val < 0 to check for a leading negative sign. That expression evaluates false when val = -0.0, and the need to append ".0" was not detected.
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index dacb9c9ce..52d59f43a 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -468,7 +468,7 @@ format_@name@(char *buf, size_t buflen, @type@ val, unsigned int prec)
/* If nothing but digits after sign, append ".0" */
cnt = strlen(buf);
- for (i = (val < 0) ? 1 : 0; i < cnt; ++i) {
+ for (i = (buf[0] == '-') ? 1 : 0; i < cnt; ++i) {
if (!isdigit(Py_CHARMASK(buf[i]))) {
break;
}