<br><br><div><span class="gmail_quote">On 9/4/06, <b class="gmail_sendername">Charles R Harris</b> <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br><br><div></div><div><span class="q"><span class="gmail_quote">On 9/4/06, <b class="gmail_sendername">Sebastian Haase</b> <<a href="mailto:haase@msg.ucsf.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
haase@msg.ucsf.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Paulo J. S. Silva wrote:<br>> Once again, the information that singed zero is part of IEEE standard is<br>> in the paper I cited in my last message.<br>><br>> It is very important to be able to compute the sign of an overflowed
<br>> quantity in expressions like 1/x when x goes to zero.<br>><br>> Best,<br>><br>> Paulo<br>Hi,<br><br>This is all very interesting ( and confusing (to me, maybe others) at<br>the same time ...) ...<br>
<br>
Question 0: Are you sure this is not a bug ?<br>  >>> N.array([66]).round(-1)<br>[60]</blockquote></span></div><div><div><br>That does look like a bug.<br><br>>>> array([66]).round(-1)<br>array([60])<br>
>>> array([66.]).round(-1)
<br>array([ 70.])<br><br>I suspect it is related to the integer data type of the first example. The code probably does something like this:<br><br>round(66/10)*10<br><br>and 66/10 == 6 in integer arithmetic.</div></div></div>
</blockquote><div><br>The problem is somewhere in this bit of code:<br><br>// f will be a double<br><div style="text-align: left;">f = PyFloat_FromDouble(power_of_ten(decimals));<br>if (f==NULL) return NULL;<br><br>// op1 will be division
<br>ret = PyObject_CallFunction(op1, "OOO", a, f, out);<br>if (ret==NULL) goto finish;<br><br>// round in place.<br>tmp = PyObject_CallFunction(n_ops.rint, "OO", ret, ret);<br>if (tmp == NULL) {Py_DECREF(ret); ret=NULL; goto finish;}
<br><br>I suspect the problem is the division, which has integer 'a', double 'f', and integer 'out'. Integer out is probably the killer. Let's see:<br><br># use doubles for output<br>>>> out = zeros(1)  <br>>>> array([66]).round(decimals=-1, out=out)
<br>array([ 70.])<br><br>yep, that's the problem<br><br>Chuck.<br></div><br><snip><br><br></div></div><br>