On Fri, Apr 29, 2011 at 3:28 PM, Steven D'Aprano <st...@pearwood.info> wrote: > Robert Kern wrote: >> Actually, Python treats all NaNs as quiet NaNs and never signalling NaNs. > > Sorry, did I get that backwards? I thought it was signalling NANs that cause > a signal (in Python terms, an exception)? > > If I do x = 0.0/0 I get an exception instead of a NAN. Hence a signalling > NAN.
Aside from the divide-by-zero case, we treat NaNs as quiet NaNs. This is largely due to the fact float operations are delegated to the underlying CPU, and SIGFPE is ignored by default. You can fiddle with it either by building and using the fpectl module, or else by switching to decimal.Decimal() instead (which offers much finer control over signalling through its thread local context information). The latter is by far the preferable course, unless you're targeting specific hardware with well-defined FPE behaviour. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com