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

Keep Android Open

https://f-droid.org/2026/02/20/twif.html
1628•LorenDB•18h ago•587 comments

I Verified My LinkedIn Identity. Here's What I Handed Over

https://thelocalstack.eu/posts/linkedin-identity-verification-privacy/
161•ColinWright•5h ago•42 comments

Andrej Karpathy talks about "Claws"

https://simonwillison.net/2026/Feb/21/claws/
113•helloplanets•2h ago•150 comments

Turn Dependabot off

https://words.filippo.io/dependabot/
500•todsacerdoti•15h ago•142 comments

I found a Vulnerability. They found a Lawyer

https://dixken.de/blog/i-found-a-vulnerability-they-found-a-lawyer
651•toomuchtodo•17h ago•299 comments

Facebook is cooked

https://pilk.website/3/facebook-is-absolutely-cooked
1164•npilk•18h ago•642 comments

Padlet (YC W13) Is Hiring in San Francisco and Singapore

https://padlet.jobs
1•coffeebite•45m ago

Ggml.ai joins Hugging Face to ensure the long-term progress of Local AI

https://github.com/ggml-org/llama.cpp/discussions/19759
753•lairv•22h ago•193 comments

Wikipedia deprecates Archive.today, starts removing archive links

https://arstechnica.com/tech-policy/2026/02/wikipedia-bans-archive-today-after-site-executed-ddos...
471•nobody9999•18h ago•280 comments

Understanding Std:Shared_mutex from C++17

https://www.cppstories.com/2026/shared_mutex/
19•ibobev•3d ago•1 comments

CERN rebuilt the original browser from 1989 (2019)

https://worldwideweb.cern.ch
191•tylerdane•13h ago•66 comments

Lean 4: How the theorem prover works and why it's the new competitive edge in AI

https://venturebeat.com/ai/lean4-how-the-theorem-prover-works-and-why-its-the-new-competitive-edg...
49•tesserato•3d ago•22 comments

Coccinelle: The Linux kernel's source-to-source transformation tool

https://github.com/coccinelle/coccinelle
24•anon111332142•4h ago•6 comments

What Is OAuth?

https://leaflet.pub/p/did:plc:3vdrgzr2zybocs45yfhcr6ur/3mfd2oxx5v22b
140•cratermoon•11h ago•48 comments

LibreOffice blasts OnlyOffice for working with Microsoft to lock users in

https://www.neowin.net/news/libreoffice-blasts-fake-open-source-onlyoffice-for-working-with-micro...
74•XzetaU8•3h ago•48 comments

Acme Weather

https://acmeweather.com/blog/introducing-acme-weather
78•cryptoz•5h ago•56 comments

Every company building your AI assistant is now an ad company

https://juno-labs.com/blogs/every-company-building-your-ai-assistant-is-an-ad-company
207•ajuhasz•17h ago•106 comments

Gitas – A tool for Git account switching

https://github.com/letmutex/gitas
18•letmutex•4d ago•14 comments

Cord: Coordinating Trees of AI Agents

https://www.june.kim/cord
105•gfortaine•11h ago•47 comments

Index, Count, Offset, Size

https://tigerbeetle.com/blog/2026-02-16-index-count-offset-size/
98•ingve•3d ago•36 comments

Large Language Model Reasoning Failures

https://arxiv.org/abs/2602.06176
15•T-A•3h ago•8 comments

Blue light filters don't work – controlling total luminance is a better bet

https://www.neuroai.science/p/blue-light-filters-dont-work
178•pminimax•18h ago•187 comments

The path to ubiquitous AI (17k tokens/sec)

https://taalas.com/the-path-to-ubiquitous-ai/
756•sidnarsipur•1d ago•418 comments

OpenScan

https://openscan.eu/pages/scan-gallery
175•joebig•15h ago•13 comments

When etcd crashes, check your disks first

https://nubificus.co.uk/blog/etcd/
13•_ananos_•5h ago•5 comments

Show HN: Mines.fyi – all the mines in the US in a leaflet visualization

https://mines.fyi/
85•irasigman•15h ago•42 comments

24 Hour Fitness won't let you unsubscribe from marketing spam, so I fixed it

https://ahmedkaddoura.com/projects/24hf-unsubscribe
67•daem•4h ago•22 comments

EU mandates replaceable batteries by 2027 (2023)

https://environment.ec.europa.eu/news/new-law-more-sustainable-circular-and-safe-batteries-enters...
159•cyrusmg•4h ago•116 comments

AI uBlock Blacklist

https://github.com/alvi-se/ai-ublock-blacklist
7•rdmuser•4h ago•4 comments

The bare minimum for syncing Git repos

https://alexwlchan.net/2026/bare-git/
7•speckx•3d ago•4 comments