Re: Exact integer-valued floats

2012-09-24 Thread wrw
On Sep 22, 2012, at 7:06 PM, Dave Angel wrote: > On 09/22/2012 05:05 PM, Tim Roberts wrote: >> Dennis Lee Bieber wrote: >>> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote: For non IEEE 754 floating point systems, there is no telling how bad the implementation could be :( >>> L

Re: Exact integer-valued floats

2012-09-23 Thread Hans Mulder
On 23/09/12 01:06:08, Dave Angel wrote: > On 09/22/2012 05:05 PM, Tim Roberts wrote: >> Dennis Lee Bieber wrote: >>> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote: For non IEEE 754 floating point systems, there is no telling how bad the implementation could be :( >>> Let's see

Re: Exact integer-valued floats

2012-09-22 Thread Tim Roberts
True. Seymour wanted all of the integer instructions to be combinatorial logic, rather than iterative. Fortunately, since the floating point binary point was to the right, it was trivial to pack integers to float, do a floating computation, then unpack back to integer. Apologize in advance fo

Re: Exact integer-valued floats

2012-09-22 Thread Dave Angel
On 09/22/2012 05:05 PM, Tim Roberts wrote: > Dennis Lee Bieber wrote: >> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote: >>> For non IEEE 754 floating point systems, there is no telling how bad the >>> implementation could be :( >> Let's see what can be found... >> >> IBM 360: Same

Re: Exact integer-valued floats

2012-09-22 Thread Tim Roberts
Dennis Lee Bieber wrote: > >On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote: >> >> For non IEEE 754 floating point systems, there is no telling how bad the >> implementation could be :( > > Let's see what can be found... > > IBM 360: Same as Sigma-6 (no surprise; hearsay is the Si

Re: Exact integer-valued floats

2012-09-22 Thread Nobody
On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Have I got this right? Is there a way to work out the gap between one >> float and the next? > > Yes, 53-bit mantissa as people have mentioned. That tells you what ints > can be exactly represented. But, arithme

Re: Exact integer-valued floats

2012-09-21 Thread Steven D'Aprano
On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Have I got this right? Is there a way to work out the gap between one >> float and the next? > > Yes, 53-bit mantissa as people have mentioned. That tells you what ints > can be exactly represented. But, arithme

Re: Exact integer-valued floats

2012-09-21 Thread Paul Rubin
Steven D'Aprano writes: > Have I got this right? Is there a way to work out the gap between one > float and the next? Yes, 53-bit mantissa as people have mentioned. That tells you what ints can be exactly represented. But, arithmetic in some situations can have a 1-ulp error. So I wonder if i

Re: Exact integer-valued floats

2012-09-21 Thread Alister
On Fri, 21 Sep 2012 17:29:13 +, Steven D'Aprano wrote: > Python floats can represent exact integer values (e.g. 42.0), but above > a certain value (see below), not all integers can be represented. For > example: > > py> 1e16 == 1e16 + 1 # no such float as 10001.0 True py> > 1e16

Re: Exact integer-valued floats

2012-09-21 Thread Hans Mulder
On 21/09/12 22:26:26, Dennis Lee Bieber wrote: > On 21 Sep 2012 17:29:13 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > >> >> The question is, what is the largest integer number N such that every >> whole number between -N and N inclusive can be represented as a

Re: Exact integer-valued floats

2012-09-21 Thread Nobody
On Fri, 21 Sep 2012 17:29:13 +, Steven D'Aprano wrote: > The question is, what is the largest integer number N such that every > whole number between -N and N inclusive can be represented as a float? > > If my tests are correct, that value is 9007199254740992.0 = 2**53. > > Have I got this r

Re: Exact integer-valued floats

2012-09-21 Thread Jussi Piitulainen
Steven D'Aprano writes: > Python floats can represent exact integer values (e.g. 42.0), but above a > certain value (see below), not all integers can be represented. For > example: > > py> 1e16 == 1e16 + 1 # no such float as 10001.0 > True > py> 1e16 + 3 == 1e16 + 4 # or 1

Re: Exact integer-valued floats

2012-09-21 Thread Ian Kelly
On Fri, Sep 21, 2012 at 11:29 AM, Steven D'Aprano wrote: > The question is, what is the largest integer number N such that every > whole number between -N and N inclusive can be represented as a float? > > If my tests are correct, that value is 9007199254740992.0 = 2**53. > > Have I got this right