frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Comparing floating-point numbers (2012)

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
26•sph•10mo ago

Comments

LegionMammal978•10mo ago
I'd argue that any equality comparison of floating-point numbers is asking for trouble, unless you're specifically working with small dyadic fractions (using exact comparison) or testing a purely heuristic 'closeness' condition (using fuzzy comparison).

Of course, inequalities show up in a lot more places, but are similarly fraught with difficulty, since mathematical statements may fail to translate to floating-point inequalities. E.g., in computational geometry, people have written entire papers about optimizing correct orientation predicates [0], since the naive method can easily break at small angles. This sort of thing is what often shows up as tiny seams in 3D video-game geometry.

[0] https://www.cs.cmu.edu/~quake/robust.html

mtklein•10mo ago
My preferred way to compare floats as being interchangeably equivalent in unit tests is

    bool equiv(float x, float y) {
        return (x <= y && y <= x)
            || (x != x && y != y);
    }
This handles things like ±0 and NaNs (while NaNs can't be IEEE-754-equal per se, they're almost always interchangeable), and convinces -Wfloat-equal you kinda know what you're doing. Also everything visually lines up real neat and tidy, which I find makes it easy to remember.

Outside unit tests... I haven't really encountered many places where float equality is actually what I want to test. It's usually some < or <= condition instead.

sph•10mo ago
I have built a production Javascript library with decent amounts of users that incorporates the following hack to deal with float error (avert your eyes if you're sensitive):

  // 1.2 - 1.0 === 0.19999999999999996
  // fixFloatError(1.2 - 1.0) === 0.2
  var fixFloatError = function (n) {
    return parseFloat(n.toPrecision(12));
  };
It felt correct at the time, but after reading the article, I cringe at how fundamentally broken it is. I got away with it because the library is used to convert betting odds, which are mostly small floating point numbers, so the error is often < 10^-12.

OpenCode – Open source AI coding agent

https://opencode.ai/
921•rbanffy•16h ago•439 comments

Mamba-3

https://www.together.ai/blog/mamba-3
171•matt_d•3d ago•24 comments

How BYD Got EV Chargers to Work Almost as Fast as Gas Pumps

https://www.wired.com/story/how-byds-ev-charger-got-even-faster-and-it-might-not-matter-as-much-a...
29•Brajeshwar•1h ago•31 comments

FFmpeg 101 (2024)

https://blogs.igalia.com/llepage/ffmpeg-101/
127•vinhnx•10h ago•3 comments

Atuin v18.13 – better search, a PTY proxy, and AI for your shell

https://blog.atuin.sh/atuin-v18-13/
51•cenanozen•2h ago•31 comments

A Japanese glossary of chopsticks faux pas (2022)

https://www.nippon.com/en/japan-data/h01362/
320•cainxinth•16h ago•255 comments

We give every user SQL access to a shared ClickHouse cluster

https://trigger.dev/blog/how-trql-works
21•eallam•3d ago•12 comments

Molly Guard

https://bookofjoe2.blogspot.com/2026/02/molly-guard.html
136•surprisetalk•22h ago•57 comments

Fujifilm X RAW STUDIO webapp clone

https://github.com/eggricesoy/filmkit
83•notcodingtoday•2d ago•32 comments

Blocking Internet Archive Won't Stop AI, but Will Erase Web's Historical Record

https://www.eff.org/deeplinks/2026/03/blocking-internet-archive-wont-stop-ai-it-will-erase-webs-h...
137•pabs3•5h ago•27 comments

Ghostling

https://github.com/ghostty-org/ghostling
244•bjornroberg•15h ago•45 comments

Padel Chess – tactical simulator for padel

https://www.padelchess.me/
46•AlexGerasim•3d ago•22 comments

Linux Applications Programming by Example: The Fundamental APIs (2nd Edition)

https://github.com/arnoldrobbins/LinuxByExample-2e
118•teleforce•13h ago•14 comments

We rewrote our Rust WASM parser in TypeScript and it got faster

https://www.openui.com/blog/rust-wasm-parser
238•zahlekhan•15h ago•148 comments

The Story of Marina Abramovic and Ulay (2020)

https://www.sydney-yaeko.com/artsandculture/marina-and-ulay
12•NaOH•2d ago•4 comments

The Los Angeles Aqueduct Is Wild

https://practical.engineering/blog/2026/3/17/the-los-angeles-aqueduct-is-wild
377•michaefe•3d ago•183 comments

Attention Residuals

https://github.com/MoonshotAI/Attention-Residuals
192•GaggiX•18h ago•25 comments

Meta's Omnilingual MT for 1,600 Languages

https://ai.meta.com/research/publications/omnilingual-mt-machine-translation-for-1600-languages/?...
16•j0e1•3d ago•0 comments

The worst volume control UI in the world (2017)

https://uxdesign.cc/the-worst-volume-control-ui-in-the-world-60713dc86950
162•andsoitis•3d ago•80 comments

Show HN: We built a terminal-only Bluesky / AT Proto client written in Fortran

https://github.com/FormerLab/fortransky
103•FormerLabFred•15h ago•50 comments

The Ugliest Airplane: An Appreciation

https://www.smithsonianmag.com/air-space-magazine/ugliest-airplane-appreciation-180978708/
86•randycupertino•2d ago•47 comments

Cryptography in Home Entertainment (2004)

https://mathweb.ucsd.edu/~crypto/Projects/MarkBarry/
56•rvnx•2d ago•31 comments

Turing Award Honors Bennett and Brassard for Quantum Information Science

https://amturing.acm.org
45•throw0101d•3d ago•0 comments

An industrial piping contractor on Claude Code [video]

https://twitter.com/toddsaunders/status/2034243420147859716
70•mighty-fine•2d ago•30 comments

France's aircraft carrier located in real time by Le Monde through fitness app

https://www.lemonde.fr/en/international/article/2026/03/20/stravaleaks-france-s-aircraft-carrier-...
584•MrDresden•1d ago•472 comments

VisiCalc Reconstructed

https://zserge.com/posts/visicalc/
213•ingve•4d ago•79 comments

Lent and Lisp

https://leancrew.com/all-this/2026/02/lent-and-lisp/
64•surprisetalk•3d ago•3 comments

ArXiv declares independence from Cornell

https://www.science.org/content/article/arxiv-pioneering-preprint-server-declares-independence-co...
767•bookstore-romeo•1d ago•267 comments

Entso-E final report on Iberian 2025 blackout

https://www.entsoe.eu/publications/blackout/28-april-2025-iberian-blackout/
205•Rygian•1d ago•99 comments

Our commitment to Windows quality

https://blogs.windows.com/windows-insider/2026/03/20/our-commitment-to-windows-quality/
564•hadrien01•18h ago•1008 comments