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

Comments

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

Ghostty is leaving GitHub

https://mitchellh.com/writing/ghostty-leaving-github
747•WadeGrimridge•1h ago•196 comments

OpenAI models coming to Amazon Bedrock: Interview with OpenAI and AWS CEOs

https://stratechery.com/2026/an-interview-with-openai-ceo-sam-altman-and-aws-ceo-matt-garman-abou...
83•translocator•1h ago•24 comments

A playable DOOM MCP app

https://chrisnager.com/blog/doom-runs-in-chatgpt-and-claude/
59•chrisnager•1h ago•24 comments

Warp is now Open-Source

https://github.com/warpdotdev/warp
107•doppp•3h ago•44 comments

I Won a Championship That Doesn't Exist

https://ron.stoner.com/How_I_Won_a_Championship_That_Doesnt_Exist/
7•SEJeff•24m ago•0 comments

CJIT: C, Just in Time

https://dyne.org/cjit/
44•smartmic•1h ago•6 comments

Intel Arc Pro B70 Review

https://www.pugetsystems.com/labs/articles/intel-arc-pro-b70-review/
21•zdw•4d ago•2 comments

GitHub RCE Vulnerability: CVE-2026-3854 Breakdown

https://www.wiz.io/blog/github-rce-vulnerability-cve-2026-3854
147•bo0tzz•4h ago•39 comments

Your phone is about to stop being yours

https://keepandroidopen.org/en/
628•doener•5h ago•344 comments

Waymo in Portland

https://waymo.com/blog/shorts/waymo-in-portland/
183•xnx•2h ago•228 comments

Claude.ai unavailable and elevated errors on the API

https://status.claude.com/incidents/9l93x2ht4s5w
218•shorsher•3h ago•180 comments

Patch applies fake diffs from commit messages

https://samizdat.dev/phantom-patch/
44•reconquestio•1d ago•9 comments

I have officially retired from Emacs

https://nullprogram.com/blog/2026/04/26/
141•Fudgel•2d ago•83 comments

Infisical (YC W23) Is Hiring Full Stack Software Engineers (Remote)

https://jobs.ashbyhq.com/infisical/782b9da8-20e1-48b2-919e-6c5430c58628
1•vmatsiiako•4h ago

Localsend: An open-source cross-platform alternative to AirDrop

https://github.com/localsend/localsend
693•bilsbie•9h ago•217 comments

Show HN: Drive any macOS app in the background without stealing the cursor

https://github.com/trycua/cua
12•frabonacci•4h ago•5 comments

UAE to leave OPEC

https://www.ft.com/content/8c354f2d-3e66-47f1-aad4-9b4aa30e386d
264•bazzmt•8h ago•377 comments

VibeVoice: Open-source frontier voice AI

https://github.com/microsoft/VibeVoice
290•tosh•9h ago•162 comments

Show HN: Live Sun and Moon Dashboard with NASA Footage

https://www.lumara-space.app/
145•beeswaxpat•7h ago•45 comments

AISLE Discovers 38 CVEs in OpenEMR Healthcare Software

https://aisle.com/blog/aisle-discovers-38-critical-security-vulnerabilities-in-healthcare-softwar...
157•mmsc•4h ago•100 comments

Warp is now open-source

https://www.warp.dev/blog/warp-is-now-open-source
90•meetpateltech•5h ago•35 comments

Laguna XS.2 and M.1

https://poolside.ai/blog/laguna-a-deeper-dive
82•tosh•4h ago•38 comments

GitHub Actions is the weakest link

https://nesbitt.io/2026/04/28/github-actions-is-the-weakest-link.html
175•dochtman•9h ago•60 comments

Talkie: a 13B vintage language model from 1930

https://talkie-lm.com/introducing-talkie
617•jekude•23h ago•247 comments

GitHub Copilot code review will start consuming GitHub Actions minutes

https://github.blog/changelog/2026-04-27-github-copilot-code-review-will-start-consuming-github-a...
217•whtsky•12h ago•149 comments

Things C++26 define_static_array can't do

https://quuxplusone.github.io/blog/2026/04/24/define-static-array/
36•jandeboevrie•2d ago•14 comments

ASML became the chokepoint for cutting-edge chips

https://worksinprogress.co/issue/the-worlds-most-complex-machine/
302•mellosouls•3d ago•183 comments

Drone pilot makes US rescind no-fly zones around unmarked, moving ICE vehicles

https://arstechnica.com/gadgets/2026/04/no-fly-zones-around-moving-ice-vehicles-this-drone-pilot-...
17•Bender•31m ago•2 comments

A good AGENTS.md is a model upgrade. A bad one is worse than no docs at all

https://www.augmentcode.com/blog/how-to-write-good-agents-dot-md-files
61•gmays•2h ago•19 comments

FCC Funding Application Notes Paramount Will Be 49.5% Foreign-Owned Post-Merger

https://deadline.com/2026/04/paramount-fcc-request-wbd-merger-middle-east-1236873732/
182•throw0101c•5h ago•119 comments