Live data from Hacker News

9999999999999999.0 – 9999999999999998.0

geocar.sdf1.org

11–20 of 274 posts

Re: 9999999999999999.0 – 9999999999999998.0

#11
What is the "right answer"? Is the article claiming that such languages don't respect IEEE-754, or that IEEE-754 is shit?

If you want arbitrary precision, use an arbitrary precision datatype. If you use fixed precision, you'll need to know how those floats work.

Pointless article, imho.

Re: 9999999999999999.0 – 9999999999999998.0

#13
Are there any mainstream languages that consider a decimal number to be a primitive type? I feel like floating point numbers are far less meaningful in every day programs. Even 2d graphics would be easier with decimal numbers. Unless you're using numbers that scale from very small to very large, like 3d games or scientific calculations, you don't actually want to use floating point.

Re: 9999999999999999.0 – 9999999999999998.0

#15
A useful website for these that I ran across recently: https://float.exposed/

For example, entering 9999999999999999.0 into "double" gives https://float.exposed/0x4341c37937e08000 and entering 9999999999999998.0 gives https://float.exposed/0x4341c37937e07fff

My wishlist for such a page would contain two additional features:

1. Allow entering expressions like "a OP b == c", so that one can enter "0.1 + 0.2 == 0.3" or "9999999999999999.0 - 9999999999999998.0 == 1.0" and see the terms on the left-hand side and right-hand side.

2. Show for each float the explicit actual range of real numbers that will be represented by that float. For example, show that every real number in the range [9999999999999999, 10000000000000001] is represented by 10000000000000000, and that every real number in the range (9999999999999997, 9999999999999999) is represented by 9999999999999998.

The author of this one has a blog post about it: https://ciechanow.ski/exposing-floating-point/ and I also like a shorter (unrelated) page that nicely explains the tradeoffs involved in floating-point representations and the IEEE 754 standard, by usefully starting with an 8-bit format: http://www.toves.org/books/float/

Re: 9999999999999999.0 – 9999999999999998.0

#16
post #9
post #3

2 with 64 bit floats, 0 with 32 bit floats.

I could understand 0, but how does it get 2?

The nearest doubles to each of these two decimal constants end up being roughly 2 apart. Whereas for fp32 both decimal constants are stored as the same float.

Re: 9999999999999999.0 – 9999999999999998.0

#17
post #15

A useful website for these that I ran across recently: https://float.exposed/ For example, entering 9999999999999999.0 into "double" gives https://float.exposed/0x4341c37937e08000 and entering 9999999999999998.0 gives https://float.exposed/0x4341c37937e07fff My wishlist for such a page would contain two additional features: 1. Allow entering expressions like "a OP b == c", so that one can enter "0.1 + 0.2 == 0.3" or…

OT: What a lovely tld .exposed is. I… really wonder about its majority userbase.

Re: 9999999999999999.0 – 9999999999999998.0

#19
post #9
post #3

2 with 64 bit floats, 0 with 32 bit floats.

I could understand 0, but how does it get 2?

These integers are so large that they cannot be precisely represented by 32 bit or 64 bit floats. So there's a rounding effect. https://stackoverflow.com/a/1848953

Re: 9999999999999999.0 – 9999999999999998.0

#20

$ php -v PHP 7.2.10 (cli) (built: Oct 9 2018 14:56:43) ( NTS ) $ php -r "echo 9999999999999999.0 - 9999999999999998.0;" 2 $ php -r "echo bcsub('9999999999999999.0', '9999999999999998.0', 1);" 1.0 bcmath - http://php.net/manual/en/function.bcsub.php

What happens with the bcmath extension enabled?
Post reply on HN