frontpage.
newsnewestaskshowjobs

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•1y ago

Comments

LegionMammal978•1y 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•1y 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•1y 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.

AMD acquires Taalas to boost inference performance by etching models in silicon

https://www.theregister.com/systems/2026/08/06/amd-acquires-ai-chip-startup-taalas-to-boost-infer...
79•itvision•1h ago•38 comments

NSF Inouye Solar Telescope Enables Major Discovery of a Hidden Solar Process

https://nso.edu/press-release/nsf-inouye-solar-telescope-enables-major-discovery-of-a-hidden-sola...
74•neversaydie•1d ago•9 comments

Qwen3.8 Max now ranked as the best overall model by agentic index

https://artificialanalysis.ai/?intelligence=agentic-index
303•apitman•2h ago•184 comments

Mario Meets Pareto

https://www.mayerowitz.io/blog/mario-meets-pareto
788•theanonymousone•10h ago•139 comments

Quake – 30th Anniversary Update

https://slayersclub.bethesda.net/en-US/news/quake-30th-anniversary-update
115•dsubburam•1h ago•51 comments

Launch HN: ProvenMetal (YC S26) delivers circuit boards in days instead of weeks

https://provenmetal.com
157•willcarkner•5h ago•107 comments

Almost no skill required to cook a steak

https://blog.sydorets.com/en/posts/almost-no-skill-required-to-cook-a-steak/
218•yusyd•6h ago•252 comments

Can you reverse engineer an ASIC?

https://blog.janestreet.com/can-you-reverse-engineer-an-asic/
32•bschne•2h ago•10 comments

Herdr is joining Y Combinator. The runtime stays open

https://herdr.dev/blog/herdr-is-joining-y-combinator/
67•collinmanderson•2h ago•44 comments

Improving GPT‑5.6 Sol in ChatGPT, expanding GPT‑5.6 Luna access for free users

https://openai.com/index/improving-gpt-5-6-sol-in-chatgpt/
87•tedsanders•4h ago•65 comments

Learn how chips are made with this Rollercoaster Tycoon-inspired animation

https://laurentiugabriel.github.io/ChipTycoon/
62•laurentiurad•6d ago•11 comments

Civilians under siege by Mexican cartel fight back with AK-47s, grenades

https://www.pbs.org/newshour/world/civilians-that-were-under-siege-by-a-mexican-cartel-fight-back...
25•starkparker•44m ago•0 comments

Crime Pays but Botany Doesn't

https://www.crimepaysbutbotanydoesnt.com/reading-list
615•DarkContinent•16h ago•190 comments

The simple elegance of the integrated timing belt loopback fastener

https://danielmangum.com/posts/integrated-timing-belt-loopback-fastener/
82•hasheddan•4d ago•17 comments

Taste Is All That's Left

https://notashelf.dev/posts/taste-is-all-thats-left
95•tsak•4h ago•76 comments

How to Make a Nintendo 64 Game in 2026

https://phoboslab.org/log/2026/08/xibalba64-making-of
433•atan2•2d ago•200 comments

GitHub Actions and Pages are experiencing degraded availability

https://www.githubstatus.com/incidents/qcvjkzcs7j74
227•Footkerchief•5h ago•198 comments

Show HN: The Channels SDK – Bring Any Agent to Any Channel (Slack, MS Teams)

https://github.com/CopilotKit/channels-sdk
74•davidmckayv•5h ago•19 comments

Building Progressively Enhanced Forms Using htmx

https://www.rafa.ee/articles/progressive-enhanced-forms-htmx/
38•mpweiher•6d ago•6 comments

Pareto Front

https://en.wikipedia.org/wiki/Pareto_front
208•binyu•1w ago•88 comments

State-oriented consistency: Why we stopped looking for one right answer

https://keel-iot.eu/blog/state-oriented-consistency.html
4•fcravio•1h ago•1 comments

The Triangle Game, from Zero

https://muchmirul.github.io/conjectures/multicolor-ramsey/
7•jdkee•4d ago•1 comments

Discovery Loop

https://www.discoveryloop.com/
902•xtreak29•1d ago•569 comments

Humans missed 1 in 3 threats approving AI agent commands across 40k game runs

https://scalex.dev/blog/ai-agent-permissions-stats/
218•Wirbelwind•9h ago•177 comments

Astronomers capture highest-resolution image ever of the Sun's surface

https://physicsworld.com/a/astronomers-capture-highest-resolution-image-ever-of-the-suns-surface/
19•layer8•47m ago•1 comments

Changes at Google DeepMind: Demis Hassabis from CEO to Chair, Jeff Dean departs

https://blog.google/company-news/inside-google/message-ceo/next-chapter-ai-momentum/
817•colesantiago•1d ago•871 comments

Towards Bottom-Up Enumeration in miniKanren via Pruning and Memoization

https://arxiv.org/abs/2607.25373
4•Jimmc414•3d ago•0 comments

Zapscape (CVE-2026-64561): Guest-to-Host Escape in KVM/x86

https://github.com/V4bel/Zapscape
53•john_strinlai•5h ago•8 comments

Federal Communications Commission scraps limit on broadcast TV ownership

https://www.nbcnews.com/business/media/federal-communications-commission-scraps-limit-broadcast-t...
85•pseudolus•3h ago•70 comments

Unearthing my 1996 windowed OS in machine code for Am29000 homebrew computer

https://nanochess.org/the_am29000_computer.html
148•nanochess•5d ago•32 comments