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

You can't trust macOS Privacy and Security settings

https://eclecticlight.co/2026/04/10/why-you-cant-trust-privacy-security/
58•zdw•42m ago•11 comments

Helium Is Hard to Replace

https://www.construction-physics.com/p/helium-is-hard-to-replace
35•JumpCrisscross•1h ago•12 comments

WireGuard makes new Windows release following Microsoft signing resolution

https://lists.zx2c4.com/pipermail/wireguard/2026-April/009561.html
16•zx2c4•20m ago•5 comments

Code is run more than read (2023)

https://olano.dev/blog/code-is-run-more-than-read/
69•facundo_olano•1h ago•25 comments

CPU-Z and HWMonitor compromised

https://www.theregister.com/2026/04/10/cpuid_site_hijacked/
30•pashadee•2h ago•22 comments

Mysteries of Dropbox: Testing of a Distributed Sync Service (2016) [pdf]

https://www.cis.upenn.edu/~bcpierce/papers/mysteriesofdropbox.pdf
67•JackeJR•3d ago•15 comments

1D Chess

https://rowan441.github.io/1dchess/chess.html
16•burnt-resistor•33m ago•1 comments

FBI used iPhone notification data to retrieve deleted Signal messages

https://9to5mac.com/2026/04/09/fbi-used-iphone-notification-data-to-retrieve-deleted-signal-messa...
341•01-_-•4h ago•164 comments

Bluesky April 2026 Outage Post-Mortem

https://pckt.blog/b/jcalabro/april-2026-outage-post-mortem-219ebg2
5•jcalabro•19m ago•1 comments

How NASA built Artemis II’s fault-tolerant computer

https://cacm.acm.org/news/how-nasa-built-artemis-iis-fault-tolerant-computer/
530•speckx•1d ago•210 comments

I still prefer MCP over skills

https://david.coffee/i-still-prefer-mcp-over-skills/
356•gmays•14h ago•299 comments

A new trick brings stability to quantum operations

https://ethz.ch/en/news-and-events/eth-news/news/2026/04/a-new-trick-brings-stability-to-quantum-...
197•joko42•12h ago•46 comments

Show HN: Marimo pair – Reactive Python notebooks as environments for agents

https://github.com/marimo-team/marimo-pair
85•manzt•2d ago•19 comments

Penguin 'Toxicologists' Find PFAS Chemicals in Remote Patagonia

https://www.ucdavis.edu/health/news/penguin-toxicologists-find-pfas-chemicals-remote-patagonia
93•giuliomagnifico•9h ago•39 comments

France to ditch Windows for Linux to reduce reliance on US tech

https://techcrunch.com/2026/04/10/france-to-ditch-windows-for-linux-to-reduce-reliance-on-us-tech/
94•Teever•49m ago•34 comments

Deterministic Primality Testing for Limited Bit Width

https://www.jeremykun.com/2026/04/07/deterministic-miller-rabin/
11•ibobev•2d ago•0 comments

Native Instant Space Switching on macOS

https://arhan.sh/blog/native-instant-space-switching-on-macos/
589•PaulHoule•20h ago•288 comments

C++: Freestanding Standard Library

https://www.sandordargo.com/blog/2026/04/08/cpp-freestanding
9•ingve•2d ago•1 comments

We've raised $17M to build what comes after Git

https://blog.gitbutler.com/series-a
248•ellieh•14h ago•540 comments

Supply chain nightmare: How Rust will be attacked and what we can do to mitigate

https://kerkour.com/rust-supply-chain-nightmare
29•fanf2•1h ago•11 comments

DRAM has a design flaw from 1966. I bypassed it [video]

https://www.youtube.com/watch?v=KKbgulTp3FE
341•surprisetalk•2d ago•122 comments

US summons bank bosses over cyber risks from Anthropic's latest AI model

https://www.theguardian.com/technology/2026/apr/10/us-summoned-bank-bosses-to-discuss-cyber-risks...
42•ascold•2h ago•20 comments

"Negative" views of Broadcom driving VMware migrations, rival says

https://arstechnica.com/information-technology/2026/04/nutanix-claims-it-has-poached-30000-vmware...
26•breve•1h ago•4 comments

OpenAI backs Illinois bill that would limit when AI labs can be held liable

https://www.wired.com/story/openai-backs-bill-exempt-ai-firms-model-harm-lawsuits/
358•smurda•3h ago•254 comments

Generative art over the years

https://blog.veitheller.de/Generative_art_over_the_years.html
207•evakhoury•3d ago•56 comments

Show HN: Keeper – embedded secret store for Go (help me break it)

https://github.com/agberohq/keeper
52•babawere•7h ago•27 comments

Intel 486 CPU announced April 10, 1989

https://dfarq.homeip.net/intel-486-cpu-announced-april-10-1989/
115•jnord•4h ago•110 comments

CollectWise (YC F24) Is Hiring

https://www.ycombinator.com/companies/collectwise/jobs/Ktc6m6o-ai-agent-engineer
1•OBrien_1107•11h ago

Model-Based Testing for Dungeons & Dragons

https://www.loskutoff.com/blog/model-based-testing-dnd/
87•Firfi•3d ago•51 comments

Charcuterie – Visual similarity Unicode explorer

https://charcuterie.elastiq.ch/
283•rickcarlino•19h ago•66 comments