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.

Conway's Game of Life, in real life

https://lcamtuf.substack.com/p/conways-game-of-life-in-real-life
116•surprisetalk•6h ago•28 comments

Nvidia greenboost: transparently extend GPU VRAM using system RAM/NVMe

https://gitlab.com/IsolatedOctopi/nvidia_greenboost
322•mmastrac•3d ago•67 comments

Warranty Void If Regenerated

https://nearzero.software/p/warranty-void-if-regenerated
338•Stwerner•13h ago•191 comments

OpenRocket

https://openrocket.info/
555•zeristor•3d ago•99 comments

Austin’s surge of new housing construction drove down rents

https://www.pew.org/en/research-and-analysis/articles/2026/03/18/austins-surge-of-new-housing-con...
533•matthest•9h ago•626 comments

A sufficiently detailed spec is code

https://haskellforall.com/2026/03/a-sufficiently-detailed-spec-is-code
353•signa11•7h ago•191 comments

LotusNotes

https://computer.rip/2026-03-14-lotusnotes.html
75•TMWNN•4d ago•36 comments

Autoresearch for SAT Solvers

https://github.com/iliazintchenko/agent-sat
124•chaisan•9h ago•24 comments

Stdwin: Standard window interface by Guido Van Rossum [pdf]

https://ir.cwi.nl/pub/5998/5998D.pdf
10•ivanbelenky•1d ago•3 comments

Wander – A tiny, decentralised tool to explore the small web

https://susam.net/wander/
276•susam•1d ago•69 comments

Why Cloudflare rule order matters?

https://www.brzozowski.io/web-applications/2025/03/11/why-cloudflare-rule-order-matters.html
23•redfr0g•3d ago•3 comments

Show HN: Duplicate 3 layers in a 24B LLM, logical deduction .22→.76. No training

https://github.com/alainnothere/llm-circuit-finder
113•xlayn•12h ago•37 comments

Nvidia NemoClaw

https://github.com/NVIDIA/NemoClaw
306•hmokiguess•18h ago•211 comments

RX – a new random-access JSON alternative

https://github.com/creationix/rx
84•creationix•9h ago•34 comments

Cook: A simple CLI for orchestrating Claude Code

https://rjcorwin.github.io/cook/
194•staticvar•7h ago•46 comments

The math that explains why bell curves are everywhere

https://www.quantamagazine.org/the-math-that-explains-why-bell-curves-are-everywhere-20260316/
127•ibobev•2d ago•67 comments

Show HN: I built 48 lightweight SVG backgrounds you can copy/paste

https://www.svgbackgrounds.com/set/free-svg-backgrounds-and-patterns/
264•visiwig•18h ago•53 comments

Eniac, the First General-Purpose Digital Computer, Turns 80

https://spectrum.ieee.org/eniac-80-ieee-milestone
13•baruchel•4h ago•6 comments

Show HN: Will my flight have Starlink?

224•bblcla•16h ago•289 comments

Mozilla to launch free built-in VPN in upcoming Firefox 149

https://cyberinsider.com/mozilla-to-launch-free-built-in-vpn-in-upcoming-firefox-149/
125•adrianwaj•6h ago•82 comments

Show HN: Pano, a bookmarking tool built around shareable shelves

https://www.panoit.com
13•uelbably•4d ago•4 comments

Show HN: Browser grand strategy game for hundreds of players on huge maps

https://borderhold.io/play
30•sgolem•3d ago•14 comments

Book: The Emerging Science of Machine Learning Benchmarks

https://mlbenchmarks.org/00-preface.html
120•jxmorris12•4d ago•6 comments

What 81,000 people want from AI

https://www.anthropic.com/features/81k-interviews
122•dsr12•4h ago•101 comments

OpenAI Has New Focus (on the IPO)

https://om.co/2026/03/17/openai-has-new-focus-on-the-ipo/
228•aamederen•23h ago•206 comments

Rob Pike’s Rules of Programming (1989)

https://www.cs.unc.edu/~stotts/COMP590-059-f24/robsrules.html
931•vismit2000•23h ago•432 comments

Czech Man's Stone in Barn's Foundations Is Rare Bronze Age Spearhead Mold

https://www.smithsonianmag.com/smart-news/a-czech-man-used-this-stone-in-his-barns-foundations-it...
43•bookofjoe•2d ago•8 comments

CVE-2026-3888: Important Snap Flaw Enables Local Privilege Escalation to Root

https://blog.qualys.com/vulnerabilities-threat-research/2026/03/17/cve-2026-3888-important-snap-f...
133•askl•18h ago•86 comments

An x86-64 back end for raven-uxn

https://www.mattkeeter.com/blog/2026-03-15-uxn/
32•dcre•3d ago•6 comments

What’s on HTTP?

https://whatsonhttp.com/
61•elixx•11h ago•27 comments