[Numpy-discussion] bug in round with negative number of decimals

David M. Cooke cookedm at physics.mcmaster.ca
Mon Sep 4 16:29:06 EDT 2006


On Mon, 4 Sep 2006 01:53:40 -0400
"A. M. Archibald" <peridot.faceted at gmail.com> wrote:
> 
> A better question to ask is, "Can I change numpy's rounding behaviour
> for my programs?" (And, more generally, "can I set all the various
> floating-point options that the IEEE standard and my processor both
> support?") I don't know the answer to that one, but it does seem to be
> a goal that numpy is trying for (hence, for example, the difference
> between numpy float scalars and python floats).

(looks) I think we've missed rounding. And the inexact flag.

You can control how overflow, underflow, divide-by-0, and invalid-operand
are handled using geterr and seterr, though.

Unfortunately, getting/setting the rounding mode is hard to do in a
platform-independent way :(

gcc has fegetround() and fesetround() (they're part of the C99 standard, I
believe). I don't know what to use on other machines (esp. Windows with MSVC),
although the Boost Interval library looks like a good place to start:
http://boost.cvs.sourceforge.net/boost/boost/boost/numeric/interval/detail/

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the NumPy-Discussion mailing list