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•9mo 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•9mo 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•9mo 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.

Tony Hoare has died

https://blog.computationalcomplexity.org/2026/03/tony-hoare-1934-2026.html
1321•speckx•8h ago•182 comments

After outages, Amazon to make senior engineers sign off on AI-assisted changes

https://arstechnica.com/ai/2026/03/after-outages-amazon-to-make-senior-engineers-sign-off-on-ai-a...
306•ndr42•9h ago•319 comments

U+237C ⍼ Is Azimuth

https://ionathan.ch/2026/02/16/angzarr.html
19•cokernel_hacker•30m ago•3 comments

RISC-V Is Sloooow

https://marcin.juszkiewicz.com.pl/2026/03/10/risc-v-is-sloooow/
126•todsacerdoti•2h ago•101 comments

Agents that run while I sleep

https://www.claudecodecamp.com/p/i-m-building-agents-that-run-while-i-sleep
170•aray07•3h ago•117 comments

Yann LeCun raises $1B to build AI that understands the physical world

https://www.wired.com/story/yann-lecun-raises-dollar1-billion-to-build-ai-that-understands-the-ph...
258•helloplanets•14h ago•293 comments

HyperCard discovery: Neuromancer, Count Zero, Mona Lisa Overdrive (2022)

https://macintoshgarden.org/apps/neuromancer-count-zero-mona-lisa-overdrive
78•naves•3h ago•22 comments

Cloudflare Crawl Endpoint

https://developers.cloudflare.com/changelog/post/2026-03-10-br-crawl-endpoint/
11•jeffpalmer•37m ago•1 comments

Launch HN: RunAnywhere (YC W26) – Faster AI Inference on Apple Silicon

https://github.com/RunanywhereAI/rcli
162•sanchitmonga22•5h ago•74 comments

Debian decides not to decide on AI-generated contributions

https://lwn.net/SubscriberLink/1061544/125f911834966dd0/
252•jwilk•8h ago•202 comments

Invoker Commands API

https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API
32•maqnius•2d ago•6 comments

FFmpeg-over-IP – Connect to remote FFmpeg servers

https://github.com/steelbrain/ffmpeg-over-ip
88•steelbrain•4h ago•39 comments

Universal vaccine against respiratory infections and allergens

https://med.stanford.edu/news/all-news/2026/02/universal-vaccine.html
23•phony-account•30m ago•7 comments

Billion-Parameter Theories

https://www.worldgov.org/complexity.html
84•seanlinehan•5h ago•54 comments

Levels of Agentic Engineering

https://www.bassimeledath.com/blog/levels-of-agentic-engineering
90•bombastic311•14h ago•48 comments

Redox OS has adopted a Certificate of Origin policy and a strict no-LLM policy

https://gitlab.redox-os.org/redox-os/redox/-/blob/master/CONTRIBUTING.md
356•pjmlp•14h ago•357 comments

Intel Demos Chip to Compute with Encrypted Data

https://spectrum.ieee.org/fhe-intel
208•sohkamyung•9h ago•81 comments

Show HN: What's my JND? – a colour guessing game

https://www.keithcirkel.co.uk/whats-my-jnd/?r=ARUjKP__-ve-
20•Keithamus•13h ago•21 comments

Exploring the ocean with Raspberry Pi–powered marine robots

https://www.raspberrypi.com/news/exploring-the-ocean-with-raspberry-pi-powered-marine-robots/
25•Brajeshwar•3d ago•3 comments

Online age-verification tools for child safety are surveilling adults

https://www.cnbc.com/2026/03/08/social-media-child-safety-internet-ai-surveillance.html
490•bilsbie•10h ago•287 comments

Open Weights isn't Open Training

https://www.workshoplabs.ai/blog/open-weights-open-training
70•addiefoote8•23h ago•20 comments

I put my whole life into a single database

https://howisfelix.today/
402•lukakopajtic•12h ago•193 comments

Rebasing in Magit

https://entropicthoughts.com/rebasing-in-magit
174•ibobev•9h ago•119 comments

Show HN: How I Topped the HuggingFace Open LLM Leaderboard on Two Gaming GPUs

https://dnhkng.github.io/posts/rys/
237•dnhkng•9h ago•79 comments

Meta acquires Moltbook

https://www.axios.com/2026/03/10/meta-facebook-moltbook-agent-social-network
363•mmayberry•8h ago•228 comments

Launch HN: Didit (YC W26) – Stripe for Identity Verification

48•rosasalberto•7h ago•45 comments

Show HN: Joha – a free browser-based drawing playground with preset shape tools

https://joha-app.pages.dev/
4•smlee•2d ago•0 comments

I built a programming language using Claude Code

https://ankursethi.com/blog/programming-language-claude-code/
96•GeneralMaximus•6h ago•138 comments

We are building data breach machines and nobody cares

https://idealloc.me/posts/we-are-building-data-breach-machines-and-nobody-cares/
82•idealloc_haris•8h ago•27 comments

The Gervais Principle, or the Office According to “The Office” (2009)

https://www.ribbonfarm.com/2009/10/07/the-gervais-principle-or-the-office-according-to-the-office/
282•janandonly•3d ago•119 comments