Re: [Numpy-discussion] float128 in fact float80

2011-10-15 Thread Nadav Horesh
On 32 bit systems it consumes 96 bits (3 x 32). and hence float96 On 64 bit machines it consumes 128 bits (2x64). The variable size is set for an efficient addressing, while the calculation in hardware is carried in the 80 bits FPU (x87) registers. Nadav ___

Re: [Numpy-discussion] float128 casting rounding as if it were float64

2011-10-15 Thread Charles R Harris
On Sat, Oct 15, 2011 at 12:54 PM, Matthew Brett wrote: > Hi, > > On Wed, Oct 12, 2011 at 11:24 AM, Charles R Harris > wrote: > > > > > > On Tue, Oct 11, 2011 at 12:17 PM, Matthew Brett > > > wrote: > >> > >> Hi, > >> > >> While struggling with floating point precision, I ran into this: > >> > >>

[Numpy-discussion] NumPy example list is corrupted

2011-10-15 Thread Alan Frankel
I've been editing the "Tentative NumPy? Tutorial" and occasionally referring to the "NumPy? Example List" ( http://www.scipy.org/Numpy_Example_List ). In the process, I think I mistakenly corrupted the NumPy Example List. Since the website does not offer any wiki-type functionality for reverti

[Numpy-discussion] float128 in fact float80

2011-10-15 Thread Matthew Brett
Hi, After getting rather confused, I concluded that float128 on a couple of Intel systems I have, is in fact an 80 bit extended precision number: http://en.wikipedia.org/wiki/Extended_precision >>> np.finfo(np.float128).nmant 63 >>> np.finfo(np.float128).nexp 15 That is rather confusing. What

Re: [Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Derek Homeier
On 15.10.2011, at 9:42PM, Aronne Merrelli wrote: > > On Sat, Oct 15, 2011 at 1:12 PM, Matthew Brett > wrote: > Hi, > > Continuing the exploration of float128 - can anyone explain this behavior? > > >>> np.float64(9223372036854775808.0) == 9223372036854775808L > True > >>> np.float128(92233720

Re: [Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Aronne Merrelli
On Sat, Oct 15, 2011 at 1:12 PM, Matthew Brett wrote: > Hi, > > Continuing the exploration of float128 - can anyone explain this behavior? > > >>> np.float64(9223372036854775808.0) == 9223372036854775808L > True > >>> np.float128(9223372036854775808.0) == 9223372036854775808L > False > >>> int(np.

Re: [Numpy-discussion] Printing individual array elements with at least 15 significant digits

2011-10-15 Thread Derek Homeier
On 15.10.2011, at 9:21PM, Hugo Gagnon wrote: > I need to print individual elements of a float64 array to a text file. > However in the file I only get 12 significant digits, the same as with: > a = np.zeros(3) a.fill(1./3) print a[0] > 0. len(str(a[0])) - 2 > 12 >

[Numpy-discussion] Printing individual array elements with at least 15 significant digits

2011-10-15 Thread Hugo Gagnon
Hello, I need to print individual elements of a float64 array to a text file. However in the file I only get 12 significant digits, the same as with: >>> a = np.zeros(3) >>> a.fill(1./3) >>> print a[0] 0. >>> len(str(a[0])) - 2 12 whereas >>> len(repr(a[0])) - 2 17 which makes more

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-15 Thread Matthew Brett
Hi, On Tue, Oct 11, 2011 at 7:32 PM, Benjamin Root wrote: > On Tue, Oct 11, 2011 at 2:06 PM, Derek Homeier > wrote: >> >> On 11 Oct 2011, at 20:06, Matthew Brett wrote: >> >> > Have I missed a fast way of doing nice float to integer conversion? >> > >> > By nice I mean, rounding to the nearest i

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-15 Thread Matthew Brett
Hi, On Wed, Oct 12, 2011 at 8:31 AM, David Cournapeau wrote: > On 10/12/11, "V. Armando Solé" wrote: >> On 12/10/2011 10:46, David Cournapeau wrote: >>> On Wed, Oct 12, 2011 at 9:18 AM, "V. Armando Solé" wrote:   From a pure user perspective, I would not expect the abs function to retu

Re: [Numpy-discussion] float128 casting rounding as if it were float64

2011-10-15 Thread Matthew Brett
Hi, On Wed, Oct 12, 2011 at 11:24 AM, Charles R Harris wrote: > > > On Tue, Oct 11, 2011 at 12:17 PM, Matthew Brett > wrote: >> >> Hi, >> >> While struggling with floating point precision, I ran into this: >> >> In [52]: a = 2**54+3 >> >> In [53]: a >> Out[53]: 18014398509481987L >> >> In [54]:

[Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Matthew Brett
Hi, Continuing the exploration of float128 - can anyone explain this behavior? >>> np.float64(9223372036854775808.0) == 9223372036854775808L True >>> np.float128(9223372036854775808.0) == 9223372036854775808L False >>> int(np.float128(9223372036854775808.0)) == 9223372036854775808L True >>> np.ro

Re: [Numpy-discussion] ndarray with double comparison

2011-10-15 Thread Chao YUE
Thanks. quite useful!! Chao 2011/10/15 Neil > Marc Shivers gmail.com> writes: > > > > > you could use bitwise comparison with paretheses: In [8]: > (a>4)&(a<8)Out[8]: > array([False, False, False, False, False, True, True, True, False, > False, False], dtype=bool) > > > > For cases like th

Re: [Numpy-discussion] ndarray with double comparison

2011-10-15 Thread Neil
Marc Shivers gmail.com> writes: > > you could use bitwise comparison with paretheses:  In [8]: (a>4)&(a<8)Out[8]: array([False, False, False, False, False,  True,  True,  True, False,   False, False], dtype=bool) > For cases like this I find it very useful to define a function between()