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.

Kagi Small Web

https://kagi.com/smallweb/
225•trueduke•2h ago•45 comments

Kagi Translate now supports LinkedIn Speak as an output language

https://translate.kagi.com/?from=en&to=LinkedIn+speak
769•smitec•7h ago•191 comments

Reddit User Uncovers Who Is Behind Meta's $2B Lobbying for Age Verification Tech

https://www.gadgetreview.com/reddit-user-uncovers-who-is-behind-metas-2b-lobbying-for-invasive-ag...
175•doener•1h ago•38 comments

Building a Shell

https://healeycodes.com/building-a-shell
49•ingve•2h ago•12 comments

Leanstral: Open-source agent for trustworthy coding and formal proof engineering

https://mistral.ai/news/leanstral
605•Poudlardo•15h ago•129 comments

Grace Hopper's Revenge

https://www.thefuriousopposites.com/p/grace-hoppers-revenge
42•ashirviskas•2h ago•32 comments

The unlikely story of Teardown Multiplayer

https://blog.voxagon.se/2026/03/13/teardown-multiplayer.html
129•lairv•3d ago•20 comments

Reverse-engineering Viktor and making it Open Source

https://matijacniacki.com/blog/openviktor
50•zggf•4h ago•16 comments

What CI looks like at a 100-person team (PostHog)

https://www.mendral.com/blog/ci-at-scale
34•shad42•4d ago•10 comments

Font Smuggler – copy hidden brand fonts into Google Docs

https://brianmoore.com/fontsmuggler/
17•lanewinfield•3d ago•4 comments

Gummy Geometry

https://newkrok.github.io/nape-js/examples.html?open=soft-body&mode=3d&outline=0
20•memalign•3d ago•3 comments

Meta’s renewed commitment to jemalloc

https://engineering.fb.com/2026/03/02/data-infrastructure/investing-in-infrastructure-metas-renew...
458•hahahacorn•18h ago•200 comments

The American Healthcare Conundrum

https://github.com/rexrodeo/american-healthcare-conundrum
384•rexroad•19h ago•353 comments

The “small web” is bigger than you might think

https://kevinboone.me/small_web_is_big.html
456•speckx•19h ago•192 comments

Sci-Fi Short Film “There Is No Antimemetics Division” [video]

https://www.youtube.com/watch?v=3v8AsTHfAG0
136•Anon84•4d ago•31 comments

Every layer of review makes you 10x slower

https://apenwarr.ca/log/20260316
304•greyface-•9h ago•176 comments

US SEC preparing to scrap quarterly reporting requirement

https://www.reuters.com/business/finance/us-sec-preparing-eliminate-quarterly-reporting-requireme...
607•djoldman•12h ago•335 comments

Gitana 18: the new flying Ultim trimaran

https://www.boatnews.com/story/50717/gitana-18-radical-technical-choices-for-the-new-flying-ultim...
51•divbzero•4d ago•23 comments

Pyodide: a Python distribution based on WebAssembly

https://github.com/pyodide/pyodide
108•tosh•3d ago•25 comments

Ryugu asteroid samples contain all DNA and RNA building blocks

https://phys.org/news/2026-03-ryugu-asteroid-samples-dna-rna.html
11•bookofjoe•24m ago•2 comments

Fatal Core Dump Game

https://www.robopenguins.com/core-dump-game/
15•pabs3•4d ago•3 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...
382•Vaslo•23h ago•118 comments

Why I love FreeBSD

https://it-notes.dragas.net/2026/03/16/why-i-love-freebsd/
454•enz•1d ago•223 comments

Beyond has dropped “meat” from its name and expanded its high-protein drink line

https://plantbasednews.org/news/alternative-protein/beyond-meat-not-the-moment-rebrand/
147•rmason•15h ago•352 comments

Show HN: Oxyde – Pydantic-native async ORM with a Rust core

https://github.com/mr-fatalyst/oxyde
123•mr_Fatalyst•3d ago•63 comments

Starlink Mini as a failover

https://www.jackpearce.co.uk/posts/starlink-failover/
273•jkpe•1d ago•205 comments

Claude Tips for 3D Work

https://www.davesnider.com/posts/claude-3d
115•snide•3d ago•26 comments

Monkey Island for Commodore 64 Ground Up

https://pixeldust.se/monkey-island-project
154•aresant•8h ago•59 comments

AirPods Max 2

https://www.apple.com/airpods-max/
292•ssijak•23h ago•483 comments

AnswerThis (YC F25) Is Hiring

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