Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Laya the open source version of Jev(convaiinnovations.com ↗)
    126comments
  2. A graphical desktop for the ZX Spectrum(github.com/mindbox77 ↗)
    39comments
  3. Tin: full-text search for Postgres(planetscale.com ↗)
    24comments
  4. AI-generated posters don’t have to be horrible(john.hartnup.uk ↗)
    430comments
  5. Human brain is two separate organs, Stanford Medicine-led research finds(stanford.edu ↗)
    176comments
  6. Leaving DigitalOcean, one site at a time(keith.is ↗)
    discuss
  7. Jobs Without LeetCode(noleet.lol ↗)
    discuss
  8. Black Holes or Black Hole Stars? Astronomers Spar over 'Little Red Dots'(quantamagazine.org ↗)
    11comments
  9. “The Secret Life of Circuits” is here(coredump.cx ↗)
    49comments
  10. Android 17 is the first since 3.x to add new APIs without releasing to the AOSP(grapheneos.social ↗)
    543comments
  11. I built the fastest PHP webserver in the world(qbixserver.com ↗)
    16comments
  12. Agreement between the USA and Denmark (1951,2004) [pdf](state.gov ↗)
    1comments
  13. Asking Authors About Their Own Papers(medium.com/tmlrorg ↗)
    29comments
  14. What Zig felt like, coming from Rust(besok.github.io ↗)
    97comments
  15. San Francisco Onion Futures Company(onionfutures.com ↗)
    105comments
  16. GPT-6 Astra Solves a WWI German Radio Cipher(prinzai.com ↗)
    126comments
  17. If math is more than proof, we need to better celebrate the rest of it(terrytao.wordpress.com ↗)
    186comments
  18. New evidence for hidden chambers beyond Tutankhamun's tomb(nature.com ↗)
    1comments
  19. Learning Another Language May Be One of the Best Ways to Keep Your Brain Healthy(theconversation.com ↗)
    33comments
  20. Cloudflare Quick Tunnels(cloudflare.com ↗)
    301comments
  21. How to Write with an LLM(sockpuppet.org ↗)
    360comments
  22. You can run Git on object storage if you re-make packfiles(tigrisdata.com ↗)
    23comments
  23. Communication by means of modulated Johnson noise(pnas.org ↗)
    18comments
  24. Saving another 100TB of RAM(cloudflare.com ↗)
    89comments
  25. SDCC – Small Device C Compiler(sourceforge.net ↗)
    23comments
  26. Ray Ozzie and the Optimism of Being Early(reproof.app ↗)
    9comments
  27. Science Is Open Software(jepedersen.dk ↗)
    50comments
  28. From Stonemasons to Carpenters(thelastsoftwareengineer.substack.com ↗)
    4comments
  29. Why building a Rust LSP is hard(rust-glancer.github.io ↗)
    44comments
  30. Ctenophores: Wonders of Biology(quantamagazine.org ↗)
    7comments

Rendering floating point numbers is hard

38 pointsby 15y agoserpentine.com
17 comments
15y agoHN ↗

Are logarithmic number systems a better alternative to floats?

15y agoHN ↗

Sometimes. :) They are faster to multiply, divide, exponentiate, and take roots of. But they are a lot harder to add and subtract, and of course it is somewhat less accurate.

15y agoHN ↗

"Grisu3 works on 99.49% of random IEEE doubles."

What a curious benchmark! It makes you wonder all kinds of things like how many IEEE doubles there are; how you sample from them randomly; what kind of coverage of the reals you get; and how relevant it all is.

15y agoHN ↗

IEEE doubles are just 64-bit words; so there are 2^64 and you sample randomly by picking a random 64-bit word.

(There are some subtleties: a "random 64-bit word interpreted as a double" is clearly not uniformly distributed over the reals; x86/amd64 uses 80-bit doubles for intermediate results, except when it doesn't; there are things like subnormals ("really small numbers"), Not-a-Number, Infinity, -Infinity, -0; but the above should give you the right general idea)

15y agoHN ↗

Sure, but to take an extreme example, suppose you have a division operator that fails to check for division-by-zero. Then your operator works in 100 * (1 - 2^63)% of all cases. That gives you 18 nines and sounds pretty convincing but it's hardly the point.

In the same way I'm wondering how meaningful it is to say that an algorithm works for 99.49% of all doubles, sampled uniformly. In other words, how could I use that benchmark to make a judgement about using grisu3?

15y agoHN ↗

Keeping everything in rational form would be nice, and easy to present.

15y agoHN ↗

Needs lazy evaluation. Just don't try to look at the whole number at once.

15y agoHN ↗

the Grisu family acts as the default rendering algorithms in both the V8 and Mozilla Javascript engines (replacing David Gay's 17-year-old dtoa code)

Hmm. I think maybe a weekend hack is in order. Perhaps dtoa in Python can be replaced in a similar fashion, since Python maintains David Gay's algorithm as an upstream source.

http://hg.python.org/cpython/file/fc831c49216d/Python/dtoa.c

EDIT: Looks like there has already been some gripes about the quality of David Gay's implementation.

http://bugs.python.org/issue9009