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•8mo ago

Comments

LegionMammal978•8mo 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•8mo 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•8mo 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.

Antirender: remove the glossy shine on architectural renderings

https://antirender.com/
1503•iambateman•18h ago•377 comments

We have ipinfo at home or how to geolocate IPs in your CLI using latency

https://blog.globalping.io/we-have-ipinfo-at-home-or-how-to-geolocate-ips-in-your-cli-using-latency/
81•jimaek•5h ago•27 comments

NASA's WB-57 crash lands at Houston

https://arstechnica.com/space/2026/01/one-of-nasas-three-wb-57-aircraft-just-did-a-belly-landing-...
33•verzali•3d ago•5 comments

Guix System First Impressions as a Nix User

https://nemin.hu/guix.html
28•todsacerdoti•3h ago•1 comments

Sumerian Star Map Recorded the Impact of an Asteroid (2024)

https://archaeologyworlds.com/5500-year-old-sumerian-star-map-recorded/
90•griffzhowl•7h ago•30 comments

Show HN: I trained a 9M speech model to fix my Mandarin tones

https://simedw.com/2026/01/31/ear-pronunication-via-ctc/
312•simedw•13h ago•104 comments

Quaternion Algebras

https://jvoight.github.io/quat.html
28•teleforce•4d ago•9 comments

Euro firms must ditch Uncle Sam's clouds and go EU-native

https://www.theregister.com/2026/01/30/euro_firms_must_ditch_us/
379•jamesblonde•4h ago•335 comments

A Step Behind the Bleeding Edge: A Philosophy on AI in Dev

https://somehowmanage.com/2026/01/22/a-step-behind-the-bleeding-edge-monarchs-philosophy-on-ai-in...
79•Ozzie_osman•2d ago•21 comments

Insane Growth Goldbridge (YC F25) Is Hiring a Forward Deployed Engineer

https://www.ycombinator.com/companies/goldbridge/jobs/78gGEHh-forward-deployed-engineer
1•alvinsalehi•2h ago

My Ridiculously Robust Photo Management System (Immich Edition)

https://jaisenmathai.com/articles/my-ridiculously-robust-photo-management-system-immich-edition/
91•jmathai•3d ago•36 comments

Peerweb: Decentralized website hosting via WebTorrent

https://peerweb.lol/
293•dtj1123•18h ago•103 comments

Moltbook

https://www.moltbook.com/
1548•teej•1d ago•727 comments

HTTP Cats

https://http.cat/
437•surprisetalk•1d ago•76 comments

Implementing the Transcendental Functions in Ivy

https://commandcenter.blogspot.com/2026/01/implementing-transcendental-functions.html
6•chmaynard•5d ago•0 comments

An anecdote about backward compatibility

https://blog.plover.com/2026/01/26/#wrterm
61•speckx•4d ago•11 comments

Show HN: Phage Explorer

https://phage-explorer.org/
88•eigenvalue•9h ago•18 comments

Naples' 1790s civil war was intensified by moral panic over Real Analysis (2023)

https://lareviewofbooks.org/article/foundational-anxieties-modern-mathematics-and-the-political-i...
69•OgsyedIE•10h ago•15 comments

Kimi K2.5 Technical Report [pdf]

https://github.com/MoonshotAI/Kimi-K2.5/blob/master/tech_report.pdf
327•vinhnx•22h ago•127 comments

Archyl – The modern platform for C4 model documentation

https://www.archyl.com/
15•eko•4d ago•5 comments

Disrupting the largest residential proxy network

https://cloud.google.com/blog/topics/threat-intelligence/disrupting-largest-residential-proxy-net...
182•cdrnsf•2d ago•168 comments

Surely the crash of the US economy has to be soon

https://wilsoniumite.com/2026/01/27/surely-it-has-to-be-soon/
387•Wilsoniumite•1d ago•500 comments

CERN accepts $1B in private cash towards Future Circular Collider

https://physicsworld.com/a/cern-accepts-1bn-in-private-cash-towards-future-circular-collider/
64•zeristor•4h ago•39 comments

Designing a Passively Safe API

https://www.danealbaugh.com/articles/passively-safe-apis
43•dalbaugh•4d ago•14 comments

Show HN: SF Microclimates

https://github.com/solo-founders/sf-microclimates
41•weisser•5d ago•32 comments

Ashcan Comic

https://en.wikipedia.org/wiki/Ashcan_comic
43•benbreen•1d ago•14 comments

Automatic Programming

https://antirez.com/news/159
156•dvrp•4h ago•146 comments

US reportedly investigate claims that Meta can read encrypted WhatsApp messages

https://www.theguardian.com/technology/2026/jan/31/us-authorities-reportedly-investigate-claims-t...
8•echelon_musk•1h ago•1 comments

Stonebraker on CAP theorem and Databases (2010)

https://perspectives.mvdirona.com/2010/04/stonebraker-on-cap-theorem-and-databases/
71•onurkanbkrc•15h ago•32 comments

The engineer who invented the Mars rover suspension in his garage [video]

https://www.youtube.com/watch?v=QKSPk_0N4Jc
348•UltraSane•4d ago•51 comments