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
2089•WadeGrimridge•9h ago•637 comments

Bugs Rust won't catch

https://corrode.dev/blog/bugs-rust-wont-catch/
91•lwhsiao•3h ago•20 comments

Before GitHub

https://lucumr.pocoo.org/2026/4/28/before-github/
352•mlex•8h ago•105 comments

How ChatGPT serves ads

https://www.buchodi.com/how-chatgpt-serves-ads-heres-the-full-attribution-loop/
227•lmbbuchodi•5h ago•147 comments

Show HN: Auto-Architecture: Karpathy's Loop, pointed at a CPU

https://github.com/FeSens/auto-arch-tournament/blob/main/docs/auto-arch-tournament-blog-post.md
58•fesens•12h ago•13 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...
220•translocator•10h ago•77 comments

We still don't have a more precise value for "Big G"

https://arstechnica.com/science/2026/04/we-still-dont-have-a-more-precise-value-for-big-g/
22•rbanffy•1d ago•12 comments

Regression: malware reminder on every read still causes subagent refusals

https://github.com/anthropics/claude-code/issues/49363
183•thomashobohm•5h ago•75 comments

I won a championship that doesn't exist

https://ron.stoner.com/How_I_Won_a_Championship_That_Doesnt_Exist/
115•SEJeff•8h ago•63 comments

GitHub RCE Vulnerability: CVE-2026-3854 Breakdown

https://www.wiz.io/blog/github-rce-vulnerability-cve-2026-3854
294•bo0tzz•13h ago•71 comments

Apple CMF (Color-Matching Functions) 2026

https://www.lttlabs.com/articles/2026/04/11/apple-studio-display-xdr-display-testing-results
30•HeyMeco•5h ago•0 comments

Behavioral timescale synaptic plasticity rewires the brain after an experience

https://www.quantamagazine.org/a-new-type-of-neuroplasticity-rewires-the-brain-after-a-single-exp...
79•ibobev•1d ago•1 comments

Intel Arc Pro B70 Review

https://www.pugetsystems.com/labs/articles/intel-arc-pro-b70-review/
134•zdw•5d ago•76 comments

Who owns the code Claude Code wrote?

https://legallayer.substack.com/p/who-owns-the-claude-code-wrote
312•senaevren•18h ago•329 comments

Nonlinearity Affects a Pendulum

https://www.johndcook.com/blog/2026/04/24/nonlinear-pendulum/
19•ibobev•1d ago•2 comments

Your phone is about to stop being yours

https://keepandroidopen.org/en/
1156•doener•14h ago•536 comments

When the Internet Was a Place

https://www.frontporchrepublic.com/2025/09/when-the-internet-was-a-place/
19•herbertl•3h ago•1 comments

We decreased our LLM costs with Opus

https://www.mendral.com/blog/frontier-model-lower-costs
72•shad42•4h ago•21 comments

Warp is now open-source

https://www.warp.dev/blog/warp-is-now-open-source
212•meetpateltech•13h ago•61 comments

Claude for Creative Work

https://www.anthropic.com/news/claude-for-creative-work
95•elsewhen•5h ago•57 comments

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

https://github.com/trycua/cua
79•frabonacci•13h ago•25 comments

Talkie: a 13B vintage language model from 1930

https://talkie-lm.com/introducing-talkie
655•jekude•1d ago•269 comments

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

https://github.com/localsend/localsend
779•bilsbie•17h ago•238 comments

I have officially retired from Emacs

https://nullprogram.com/blog/2026/04/26/
198•Fudgel•3d ago•139 comments

VibeVoice: Open-source frontier voice AI

https://github.com/microsoft/VibeVoice
344•tosh•17h ago•167 comments

UAE to leave OPEC

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

An update on GitHub availability

https://github.blog/news-insights/company-news/an-update-on-github-availability/
345•salkahfi•19h ago•222 comments

CJIT: C, Just in Time

https://dyne.org/cjit/
98•smartmic•10h ago•29 comments

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

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

Building a Hamiltonian Path Puzzle

https://www.4rknova.com//blog/2026/04/24/number-trail
5•ibobev•1d ago•0 comments