[Matrix-SIG] array([19990609],'f') bug?

Yoon, Hoon (CICG - NY Program Trading) HYoon@exchange.ml.com
Wed, 23 Jun 1999 09:06:16 -0400


Tim,

Actually, I am using double already. I thought this should bring up error
msg or NaN. Not unexpected numeric change. Given that I often deal with
large trade sizes, this is not unusal. The conversion could cause hard to
find errors.

**************************************************************
S. Hoon Yoon                   (Quant)                    Merrill Lynch
Equity Trading 
yelled@yahoo.com hoon@bigfoot.com(w)
"Miracle is always only few standard deviations away, but so is
catastrophe."
* Expressed opinions are often my own, but NOT my employer's.
"I feel like a fugitive from the law of averages."    Mauldin
**************************************************************

> -----Original Message-----
> From:	Tim Peters [SMTP:tim_one@email.msn.com]
> Sent:	Wednesday, June 23, 1999 1:14 AM
> To:	matrix-sig@python.org
> Subject:	RE: [Matrix-SIG] array([19990609],'f') bug?
> 
> [Hoon Yoon]
> > Can anyone explain this strange behavior?
> > NT svcpack 3 running version 11 of NumPy
> > >>> array([19990609],'f')
> >        array([ 19990608.],'f')
> > Anyone have a fix?
> 
> IEEE floats (single-precision) have 24 mantissa bits, so the dense range
> of
> representable integers is [-2**24, 2**24] = [-16777216, 16777216].  Your
> input number is outside that range, but is in the next larger binade (i.e.
> +/- 2**25), where only every *second* integer is exactly representable
> (and
> in the next binade after that, only every fourth integer is representable;
> and in the next binade after that, only every eighth; etc).  That's why it
> got chopped to an even integer.
> 
> So long as you're using floats, you'll either get 19990608 or 19990610
> (ANSI
> C doesn't define which one you'll get back, but the important point is
> that
> it's impossible to get back 19990609).
> 
> so-use-doubles-or-ints-or-stick-to-float-ints-divisible-by-large-powers-
>     of-2-ly y'rs  - tim
> 
> 
> 
> _______________________________________________
> Matrix-SIG maillist  -  Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig