On Monday, 17 December, 2018 12:27, Jay Kreibich <j...@kreibi.ch> wrote:

>> On Dec 17, 2018, at 1:12 PM, Keith Medcalf <kmedc...@dessus.com> wrote:

>> The "nearest" representation of 211496.26 is
>> 211496.26000000000931323.  The two representable IEEE-754 double
>> precision floating point numbers bounding 211496.26 are:

>> 211496.26000000000931323
>> 211496.2599999999802094

>> The difference between 211496.25999999992 (which is itself a
>> truncated representation -- the actual stored value should presumably
>> be 211496.25999999992200173) and 211496.26000000000931323 is
>> 8.73114913702011e-11, or 3 ULP.

>> Applying half-even rounding at the second "decimal place" to
>> 211496.25999999992 (which when multiplied by 100 is
>> 21149625.9999999925494194 which half-even rounds to 21149626.0 which
>> when divided by 100 is 211496.26000000000931323 or exactly the
>> "nearest representable IEEE-754 double precision floating point
>> number" to 211496.26

> Which brings up an important point…. When saying "double-precision
> floating point is accurate to within 15 decimal digits” it does NOT
> mean floating point can perfectly represent any number up to 15
> digits long, it means that the delta between intent and
> representation is 15 digits smaller than the largest represented
> digit.  In this case, the delta is 10 digits under the radix point,
> plus another 5 or 6 digits from the other side of the radix point.

> In short, the problem _is_ storage… or at least representation.  And
> that’s before calculations muck everything up further.

Which is why:

sqlite> create table x(x);
sqlite> insert into x values(1.0);
sqlite> insert into x values(1.0e100);
sqlite> insert into x values(1.0);
sqlite> insert into x values(-1.0e100);
sqlite> select sum(x) from x;
0.0

but

sqlite> select sum(x) from (select x from x order by abs(x) desc);
2.0

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.





_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to