From: Stefan v. d. W. <st...@su...> - 2006-11-11 21:57:24
|
On Sat, Nov 11, 2006 at 06:30:06PM -0300, Lisandro Dalcin wrote: > On 11/11/06, Stefan van der Walt <st...@su...> wrote: > > NaN (or inf) is a floating point number, so seeing a zero in integer > > representation seems correct: > > > > In [2]: int(N.nan) > > Out[2]: 0L > > >=20 > Just to learn myself: Why int(N.nan) should be 0? Is it C behavior? As far as I know (and please correct me if I'm wrong), nan's are just a specific bit pattern set in memory when an invalid floating point operation occurs (in IEEE 754 nan's are represented by an exponent of all 1's and a non-zero mantissa). Most integer representations have no way of indication an invalid result (and C provides no such conversion, as far as I am aware), so nan's are interpreted as 0 (which could have been any arbitrary number for that matter, although 0 seems a logical choice). Regards St=E9fan |