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.

Meta’s renewed commitment to jemalloc

https://engineering.fb.com/2026/03/02/data-infrastructure/investing-in-infrastructure-metas-renew...
237•hahahacorn•3h ago•101 comments

The “small web” is bigger than you might think

https://kevinboone.me/small_web_is_big.html
213•speckx•3h ago•81 comments

My Journey to a reliable and enjoyable locally hosted voice assistant (2025)

https://community.home-assistant.io/t/my-journey-to-a-reliable-and-enjoyable-locally-hosted-voice...
262•Vaslo•8h ago•87 comments

Language Model Teams as Distrbuted Systems

https://arxiv.org/abs/2603.12229
46•jryio•3h ago•11 comments

Why I love FreeBSD

https://it-notes.dragas.net/2026/03/16/why-i-love-freebsd/
281•enz•9h ago•111 comments

Nvidia Launches Vera CPU, Purpose-Built for Agentic AI

https://nvidianews.nvidia.com/news/nvidia-launches-vera-cpu-purpose-built-for-agentic-ai
50•lewismenelaws•1h ago•21 comments

AnswerThis (YC F25) Is Hiring

https://www.ycombinator.com/companies/answerthis/jobs/CNdatw5-founding-engineering-lead
1•ayush4921•16m ago

Launch HN: Voygr (YC W26) – A better maps API for agents and AI apps

50•ymarkov•4h ago•26 comments

Beyond Meat CEO 'It's Just Not the Moment for Plant-Based Meat' After Rebrand

https://plantbasednews.org/news/alternative-protein/beyond-meat-not-the-moment-rebrand/
9•rmason•16m ago•0 comments

Apideck CLI – An AI-agent interface with much lower context consumption than MCP

https://www.apideck.com/blog/mcp-server-eating-context-window-cli-alternative
96•gertjandewilde•5h ago•89 comments

Show HN: Claude Code skills that build complete Godot games

https://github.com/htdt/godogen
58•htdt•5h ago•19 comments

Polymarket gamblers threaten to kill me over Iran missile story

https://www.timesofisrael.com/gamblers-trying-to-win-a-bet-on-polymarket-are-vowing-to-kill-me-if...
1123•defly•9h ago•733 comments

On The Need For Understanding

https://blog.information-superhighway.net/on-the-need-for-understanding
40•zdw•4d ago•11 comments

Starlink Mini as a failover

https://www.jackpearce.co.uk/posts/starlink-failover/
128•jkpe•13h ago•124 comments

Corruption erodes social trust more in democracies than in autocracies

https://www.frontiersin.org/journals/political-science/articles/10.3389/fpos.2026.1779810/full
598•PaulHoule•9h ago•305 comments

US Job Market Visualizer

https://karpathy.ai/jobs/
340•andygcook•6h ago•272 comments

Home Assistant waters my plants

https://finnian.io/blog/home-assistant-waters-my-plants/
222•finniananderson•4d ago•115 comments

Launch HN: Chamber (YC W26) – An AI Teammate for GPU Infrastructure

https://www.usechamber.io/
18•jshen96•4h ago•4 comments

Lazycut: A simple terminal video trimmer using FFmpeg

https://github.com/emin-ozata/lazycut
119•masterpos•9h ago•41 comments

Cert Authorities Check for DNSSEC from Today

https://www.grepular.com/Cert_Authorities_Check_for_DNSSEC_From_Today
69•zdw•23h ago•125 comments

AirPods Max 2

https://www.apple.com/airpods-max/
137•ssijak•7h ago•257 comments

Lies I was told about collaborative editing, Part 2: Why we don't use Yjs

https://www.moment.dev/blog/lies-i-was-told-pt-2
159•antics•3d ago•90 comments

Kona EV Hacking

http://techno-fandom.org/~hobbit/cars/ev/
97•AnnikaL•4d ago•56 comments

MoD sources warn Palantir role at heart of government is threat to UK security

https://www.thenerve.news/p/palantir-technologies-uk-mod-sources-government-data-insights-securit...
520•vrganj•9h ago•207 comments

The bureaucracy blocking the chance at a cure

https://www.writingruxandrabio.com/p/the-bureaucracy-blocking-the-chance
56•item•1d ago•80 comments

Speed at the cost of quality: Study of use of Cursor AI in open source projects (2025)

https://arxiv.org/abs/2511.04427
68•wek•4h ago•30 comments

Palestinian boy, 12, describes how Israeli forces killed his family in car

https://www.bbc.com/news/articles/c70n2x7p22do
576•tartoran•2h ago•151 comments

Where does engineering go? Retreat findings and insights [pdf]

https://www.thoughtworks.com/content/dam/thoughtworks/documents/report/tw_future%20_of_software_d...
62•danebalia•5d ago•23 comments

Comparing Python Type Checkers: Typing Spec Conformance

https://pyrefly.org/blog/typing-conformance-comparison/
76•ocamoss•8h ago•23 comments

Even faster asin() was staring right at me

https://16bpp.net/blog/post/even-faster-asin-was-staring-right-at-me/
92•def-pri-pub•8h ago•44 comments