11 ms·
Float Exposed
- slater 1y agoWhy tf is there a .exposed TLD?
- shoo 1y ago> THE .EXPOSED TLD This TLD is attractive and useful to end-users as it better facilitates search, self-expression, information sharing and the provision of legitimate goods and services. Along with the other TLDs in the Donuts family, this TLD will provide Internet users with opportunities for online identities and expression that do not currently exist. In doing so, the TLD will introduce significant consumer choice and competition to the Internet namespace – the very purpose of ICANN’s new TLD program. > .EXPOSED will be utilized by registrants seeking new avenues for expression on the Internet. There is a deep history of progressivity and societal advancement resulting from the online free expressions of criticism. Individuals and groups will register names in .EXPOSED when interested in editorializing, providing input, revealing new facts or views, interacting with other communities, and publishing commentary. -- https://icannwiki.org/.exposed https://icannwiki.org/.exposed
- Joker_vD 1y ago> better facilitates... the provision of legitimate goods and services. Like what? A risque lingerie shop at balls.exposed or something? And new TLDs don't in any way facilitate "better search", you know, nor "information sharing". > Along with the other TLDs in the Donuts family Sorry, the what family? > online identities and expression that do not currently exist. What does this phrase even mean? > the TLD will introduce significant consumer choice and competition to the Internet namespace – the very purpose of ICANN’s new TLD program. "Considered harmful" etc. > Individuals and groups will register names in .EXPOSED when interested in editorializing, providing input, revealing new facts or views, interacting with other communities, and publishing commentary. Still not sure how "provision of legitimate goods" fits into this. Or the floating point formats, for that matter.
- maxbond 1y agoFor the same reason there's a .sucks TLD. There's a market for it.
- magackame 1y agoSo windows.sucks and linux.sucks are available and 2000 USD/year, emacs.sucks is 200 USD/year and vi.sucks is already registered (but no website unfortunately)! On the other hand linux.rocks and windows.rocks are taken (no website), vi.rocks is 200 USD/year and emacs.rocks is just 14 USD/year. microsoft.sucks redirects to microsoft.com, but microsoft.rocks is just taken :thinking:
- 8cvor6j844qw_d6 1y agoPretty sure there's a domain monitoring service for similarly or something along these lines that buys up domains like these to prevent usage. On that note, I've been trying to see if GoDaddy will buy a domain and resell for higher price by searching for some plausibly nice domain names on their site. They haven't took the "bait" yet.
- 15155 1y agoMarkMonitor
- SomaticPirate 1y agoThis came during my OMSCS Game AI course as an example of the dangers of using floats to represent game object location. If you get further from the origin point (or another game element you are referencing from) you are losing precision as the float needs to use more of the significand to store the larger value.
- mwkaufma 1y agoDefine boundary conditions -- how much precision do you need? Then you can compute the min/max distances. If the "world" needs to be larger, then prepare to divide it into sectors, and have separate global/local coordinates (e.g. No Man's Sky works this way). Really though, games are theater tech, not science. Double-Precision will be more than enough for anything but the most exotic use-case. The most important thing is just to remember not to add very-big and very-small numbers together.
- skeezyboy 1y ago> Define boundary conditions -- how much precision do you need? imagine if integer arithmetic gave wrong answers in certain conditions lol why did we choose the current compromise?
- ForOldHack 1y agoCompromises. We had BCD for finance, binary for games, and floating point for math. I wrote a sample 'make change' using floating, BCD, and integer( normalizing by multiplying by 100). The integer ripped thru it, but surprisingly BCD kept up with FP, and with compiler optimizations, in certain edge cases and unit tests was significantly faster. You get surprising things with common place problems.
- cindyllm 1y ago[dead]
- kbolino 1y ago
- vismit2000 1y agoThis remains one of the best explanations on the topic: https://fabiensanglard.net/floating_point_visually_explained/ https://fabiensanglard.net/floating_point_visually_explained... Saw this when I just started using HN and such posts only inspired me to stick to it: https://news.ycombinator.com/item?id=29368529 https://news.ycombinator.com/item?id=29368529
- deleted 1y ago[deleted]
- nesk_ 1y agoI've never seen this topic so well explained, thank you for sharing!
- Etherlord87 1y agoFrom just scanning through the article quickly, I don't see there the mantissa similarly easily explained, but there is a very intuitive way to think of it. Because the mantissa (like everything else) is encoded in binary, the first explicit (because there's implicit 1. at the beginning) digit of it means either 0/2 or 1/2 (just like in decimal the first digit after the dot means either 0/10 or 1/10 or 2/10...), the next digit is (0/2² = 0/4) or 1/4, third digit is 0/8 or 1/8 etc. You can visualize this by starting at the beginning of the "window", and then you divide the window into 2 halves: now the first digit of the mantissa tells you if you stay at the beginning of the first half, or move to the beginning of the 2nd half. Now whatever half you picked, you divide it into 2 halves again, and use the next bit of mantissa to tell you if you should advance to the next half. So you just keep subdividing, and so the more bits in the mantissa you have, the more you can subdivide the window, and if the exponent (after applying bias) is equal exactly the number of explicit bits in the mantissa, the smallest subdivision cell has length equal exactly 1. Incrementing exponent by 1 will now double the window size, and without additional subdivision each cell has length equal exactly 2 meaning each next float number now increments by 2. (keep in mind there is a subnormal range where there's implicit 0. at the beginning of the mantissa instead) To reiterate, increasing the exponent by 1 doubles the window size, so the exponent describes how many times the window size was doubled while the number of bits of mantissa describes how many times you can do the reverse and "half" it, hence the exponent to mantissa bits relation.
- omoikane 1y agoPreviously I was using this site to explore floating point representations: https://www.h-schmidt.net/FloatConverter/IEEE754.html https://www.h-schmidt.net/FloatConverter/IEEE754.html This one has the extra feature of showing the conversion error, but it doesn't support double precision.
- Etherlord87 1y agoI was looking through the comments to see if someone already mentioned it. Great webpage! However the one in OP has an amazing graph intuitively explaining the numeric space partitioning - the vertical axis is logarithmic, and the horizontal is linear for each row on its own, but rows are normalized to fit the range between the logarithmic values on the vertical axis. I guess it's obvious once you're comfortably understanding floats and could do with some explanations for those still learning it.
- ridiculous_fish 1y agoMy favorite FP Fun Fact is that float comparisons can (almost) use integer comparisons. To determine if a > b, reinterpret a and b as signed ints and just compare those like any old ints. It (almost) works! The implication is that the next biggest float is (almost) always what you get when you reinterpret its bits as an integer, and add one. For example, start with the zero float: all bits zero. Add one using integer arithmetic. In int-speak it's just one; in float-speak it's a tiny-mantissa denormal. But that's the next float; and `nextafter` is implemented using integer arithmetic. Learning that floats are ordered according to integer comparisons makes it feel way more natural. But of course there's the usual asterisks: this fails with NaNs, infinities, and negative zero. We get a few nice things, but only a few.
- Sniffnoy 1y agoThis isn't accurate. It's true for positive numbers, and when comparing a positive to a negative, but false for comparisons between negative numbers. Standard floating point uses sign-magnitude representation, while signed integers these days use 2s-complement. On negative numbers, comparisons are reversed between these two encodings. Incrementing a float as if it were an integer will, in ordinary circumstances, get you the next one larger in magnitude, but with the same sign -- i.e., you go up for positives but down for negatives. Whereas with signed integers, you always go up except when there's an overflow into the sign bit. A more correct version of the statement would be that comparison is the same as on sign-magnitude integers. Of course, this still has the caveats you already mentioned.
- adgjlsfhk1 1y agoOne of the unambiguously nice things about Posits (unlike floats) is that they use a 2s compliment scheme which makes it actually true for all values that they sort like integers.
- Sniffnoy 1y agoI was going to say "well, you've still got NaR", but apparently that's been defined to sort less than all other posits? Huh, OK.
- deleted 1y ago[deleted]
- dorianmariecom 1y agonot obvious you need to press enter to change the value
- CraigJPerry 1y agoThe award for "most fun integer" in 32 bit float is 16777217 (and 9007199254740992 for 64bit). It's sometimes fun to have these kinds of edge cases up your sleeve when testing things.
- simonask 1y agoYou mean ±9,007,199,254,740,993.0 for 64-bit floats. :-) For other curious readers, these are one beyond the largest integer values that can be represented accurately. In other words, the next representable value away from zero after ±16,777,216.0 is ±16,777,218.0 in 32 bits -- the value ±16,777,217.0 cannot be represented, and will be rounded somewhat hand-wavingly (usually towards zero). Precision rounding is one of those things that people often overlook.
- lifthrasiir 1y agoFor 64-bit, 9007199254740991 is also known as `Number.MAX_SAFE_INTEGER` in JavaScript. Note that this value is not even; the next integer, ..0992 is still safe to represent by its own, but it can't be distinguished from a definitely unsafe integer ..0993 rounded to ..0992.
- GistNoesis 1y agoFor a .exposed domain, it's not really shocking. The real shocking fact about floating point is that they are even used at all. It's throwing out of the window the most basic property operations on number should have : "associativity" and all that for a gain in dynamic range which is not necessary most of the time. The associativity we expect to hold is (a+b)+c == a+(b+c) and (ab)c == a(bc) and these don't hold for floats even though most math formulas and compiler optimizations rely on these to hold. It's a sad miracle that everything somehow still works out OK most of the time. You lose determinism most of the time with respect to compiler optimizations, and platform reproducibility if processor don't exactly respect IEE-754 (or is it IEE-854). The real problem comes when you want to use parallelism. With things like atomic operations and multiple processor doing things out of order, you lose determinism and reproducibility, or add a need for synchronisation or casting operations everywhere. Even more problematic, is that because number operations are used so often, they are set in "stone", and are implemented at the hardware level. And they use much more transistor because they are more complex than integer arithmetic. Real programmers don't use floating points, only sloppy lazy ones do. Real programmers use fixed point representation and make sure the bounds don't overflow/underflow unexpectedly. Let's ban all hardware floating-point implementation : Just imagine future alien archeologists having a laugh at us when they look at our chips and think "no wonder they were doomed they can't even do a+b right : its foundations were built on sand".
- librasteve 1y agotry rotating & shading triangles in 3D with integer math … FPUs have earned their place
- GistNoesis 1y agohttps://en.wikipedia.org/wiki/Fixed-point_arithmetic https://en.wikipedia.org/wiki/Fixed-point_arithmetic : allows you to have some thing which is integer math but works like floats. It's integer operations and bit shifts so really fast. The limitation is the minimal quantization level. But for a 3d engine let's say your base increment is nanometers. Then you set your maximum dimension let's say 1000km. You only have to be able to represent number up 10^20 so 64-bit fixed point number is good enough. Do everything in 128-bit fixed point numbers, and float are no more problem for anything scientific.
- librasteve 1y agofantastic explanation and very nice to see both the decimal and binary representations together https://raku.org https://raku.org defaults to Rationals (Rats) and provides FatRat for arbitrary precision otherwise even relatively normal calculations (eg what’s the mass of electron in quectogram) fail
- saghm 1y ago"FatRat" is a hilarious name for a numeric type (and I mean this in a purely positive way). I've always had an impression of Perl as a language with a bit of a quirky, fun community, and it's nice to see that might have carried over to Raku as well.
- librasteve 1y agowell Larry (Wall) was a linguist and adept at coining memorable memes
- saghm 1y agoFor sure! I've honestly never written Perl, but I still often end up sharing the "three virtues" with junior engineers I work with. There's a certain timeless quality to a lot of the stuff he's come up with. (Plus, those of us who don't write Perl still owe him a debt of gratitude even just for the `patch` utility!)
- yuvadam 1y agoThis is cool, looks visually a lot like a CIDR range calculator [1] I built a few years ago to help me understand network ranges better. These types of visualizations are super useful. [1] - https://cidr.xyz https://cidr.xyz
- deleted 1y ago[deleted]
- rwmj 1y agoGood job on showing the hexadecimal version. I recently had a challenging C bug where I was using printf("%a") to show the underlying representation, which uses hexadecimal, and it was a little confusing at first. This site would have been helpful.
- jjcob 1y agoOne problem I was struggling with: What's the shortest, unambiguous decimal representation of a float? For example, if you use single precision floats, then you need up to 9 digits of decimal precision to uniquely identify a float. So you would need to use a printf pattern like %.9g to print it. But then 0.1 would be output as 0.100000001, which is ugly. So a common approach is to round to 6 decimal digits: If you use %.6g, you are guaranteed that any decimal input up to 6 significant digits will be printed just like you stored it. But you would no longer be round-trip safe when the number is the result of a calculation. This is important when you do exact comparisons between floats (eg. to check if data has changed). So one idea I had was to try printing the float with 6 digits, then scanning it and seeing if it resulted in the same binary representation. If not, try using 7 digits, and so on, up to 9 digits. Then I would have the shortest decimal representation of a float. This is my algorithm: int out_length; char buffer[32]; for (int prec = 6; prec<=9; prec++) { out_length = sprintf(buffer, "%.*g", prec, floatValue); if (prec == 9) { break; } float checked_number; sscanf(buffer, "%g", &checked_number); if (checked_number == floatValue) { break; } } I wonder if there is a more efficient way to determine that shortest representation rather than running printf/scanf in a loop?
- forrestthewoods 1y agostd::numeric_limits<float>::max_digits10 https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10.html https://en.cppreference.com/w/cpp/types/numeric_limits/max_d...
- lifthrasiir 1y agoYour problem is practically important as it can be considered as the "canonical" string representation of given floating point number (after adding the closestness requirement). There are many efficient algorithms as a result, selected algorithms include Dragon4, Grisu3, Ryu and Dragonbox. See also Google's double-conversion library which implements first two of them.
- jjcob 1y agoThank you for pointing me to all the prior work on this! I am surprised how complex the issue seems to be. I assumed there might be an elegant solution, but the problem seems to be a lot harder than I thought.
- burnt-resistor 1y agoFar too superficial because it lacks explanation of non-normal conditions (denormals, zeroes, infinities, sNaNs, and qNaNs) and the complete mapping of values. This isn't properly educational.
- ForOldHack 1y ago"An sNaN (signaling Not-a-Number) is a special floating-point value that is designed to trigger a hardware trap or exception when it is used in an arithmetic operation. This differs from a qNaN (quiet Not-a-Number), which propagates through calculations without causing an immediate exception. Handling sNaNs requires a more deliberate approach that involves enabling floating-point traps and writing a custom trap handler." Just learned something. Thanks.
- tempodox 1y agoFantastic. A visual interactive explanation of how floating-point representation works.
- fnord77 1y agoassuming this is IEEE 754
- llm_nerd 1y agoThe best explanation on floats - https://dennisforbes.ca/blog/features/floating_point/understanding-floating-point-numbers/ https://dennisforbes.ca/blog/features/floating_point/underst...
- elvircrn 1y agoGood stuff. Having fp8/fp4 would be great, too!
- lifthrasiir 1y agoThere are too many fp8/fp4 formats out there, many with different trade-offs. At least fp16 is standardized...
- elvircrn 1y agoYes, all of them would be great.
- lifthrasiir 1y agoHmm, you successfully nerd-sniped me. AFAIK there are at least: - 8-bit floating point types: (S1)E4M3 (finite only, has no-negative-zero variant), (S1)E5M2 (has no-negative-zero variant), E8M0 - 6-bit floating point types: (S1)E2M3, (S1)E3M2 - 4-bit floating point types: (S1)E2M1, NF4 - Block floating point types: MXFP8 (E5M2/E4M3*32+E8M0), MXFP6 (E3M2/E2M3*32+E8M0), MXFP4 (E2M1*32+E8M0), NXFP [1] [1] https://arxiv.org/pdf/2412.19821 https://arxiv.org/pdf/2412.19821 Do you have anything to add on?
- elvircrn 1y agoNothing to add, I was simply saying that it would be useful to have an FP8 toy website out there covering all of these formats.
- makeworld 1y agoSee also https://integer.exposed/ https://integer.exposed/
- pmarreck 1y agoI'm glad this exists, except for the fact that IEEE754 is the devil, and posits are better (not assuming hardware support). (Even better than both are bignum rationals, but those are the slowest.)
- the__alchemist 1y agoIt's a compromise that works well in a broad range of approaches. All the alternatives perform better in some domains, and worse in others.
- pmarreck 1y agoFair enough. I just don't like the element of surprising inaccuracy.
- noxa 1y agoWould be cool if this supported the various fp8 formats that have been shipped on GPUs recently!
- KingLancelot 1y ago[dead]
- porker 1y agoIt doesn't seem to have been shared in this thread but my favourite site on this topic is https://0.30000000000000004.com/ https://0.30000000000000004.com/
- emergie 1y agoIt would be nice if the site had an explanation why the decimal 0.1 has no finite representation in base-2 system. In short it's about factorization of the base of the system - base-2 lacks 5 that is present in base-10. It is analogous to 1/3 or 1/7 not having a finite representation in base-10 dot notation of a fraction.