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.

The Age Verification Trap: Verifying age undermines everyone's data protection

https://spectrum.ieee.org/age-verification
340•oldnetguy•2h ago•260 comments

Ladybird Browser adopts Rust

https://ladybird.org/posts/adopting-rust/
612•adius•4h ago•315 comments

The peculiar case of Japanese web design (2022)

https://sabrinas.space
106•montenegrohugo•1h ago•36 comments

A simple web we own

https://rsdoiel.github.io/blog/2026/02/21/a_simple_web_we_own.html
20•speckx•25m ago•4 comments

Elsevier shuts down its finance journal citation cartel

https://www.chrisbrunet.com/p/elsevier-shuts-down-its-finance-journal
352•qsi•8h ago•63 comments

Sub-$200 Lidar could reshuffle auto sensor economics

https://spectrum.ieee.org/solid-state-lidar-microvision-adas
256•mhb•4d ago•343 comments

Magical Mushroom – Europe's first industrial-scale mycelium packaging producer

https://magicalmushroom.com/index
189•microflash•8h ago•64 comments

I built Timeframe, our family e-paper dashboard

https://hawksley.org/2026/02/17/timeframe.html
1352•saeedesmaili•21h ago•324 comments

0 A.D. Release 28: Boiorix

https://play0ad.com/new-release-0-a-d-release-28-boiorix/
238•jonbaer•3d ago•80 comments

femtolisp: A lightweight, robust, scheme-like Lisp implementation

https://github.com/JeffBezanson/femtolisp
48•tosh•3h ago•7 comments

Emulating Goto in Scheme with Continuations

https://terezi.pyrope.net/ccgoto/
10•usually•3d ago•0 comments

SETI@home: Data Acquisition and Front-End Processing (2025)

https://iopscience.iop.org/article/10.3847/1538-3881/ade5a7
49•tosh•6h ago•6 comments

Pipelined Relational Query Language, Pronounced "Prequel"

https://prql-lang.org/
47•dmit•2d ago•35 comments

Loops is a federated, open-source TikTok

https://joinloops.org/
517•Gooblebrai•21h ago•344 comments

What Is a Centipawn Advantage?

https://win-vector.com/2026/02/19/what-is-a-centipawn-advantage/
29•jmount•3d ago•8 comments

Show HN: CIA World Factbook Archive (1990–2025), searchable and exportable

https://cia-factbook-archive.fly.dev/
420•MilkMp•19h ago•86 comments

Benchmarks for concurrent hash map implementations in Go

https://github.com/puzpuzpuz/go-concurrent-map-bench
11•platzhirsch•21h ago•0 comments

Show HN: AI Timeline – 171 LLMs from Transformer (2017) to GPT-5.3 (2026)

https://llm-timeline.com/
48•ai_bot•7h ago•30 comments

If AI makes human labor obsolete, who decides who gets to eat?

https://www.theguardian.com/business/2026/feb/23/ai-how-will-we-be-fed
12•n1b0m•32m ago•9 comments

Bitmovin (YC S15) Is Hiring Interns in AI for Summer 2026 in Austria

https://bitmovin.com/careers/8023403002/
1•slederer•9h ago

Hetzner (European hosting provider) to increase prices by up to 38%

https://old.reddit.com/r/BuyFromEU/comments/1rce0lf/hetzner_european_hosting_provider_to_increase/
341•doener•4h ago•282 comments

Pope tells priests to use their brains, not AI, to write homilies

https://www.ewtnnews.com/vatican/pope-leo-xiv-tells-priests-to-use-their-brains-not-ai-to-write-h...
396•josephcsible•8h ago•332 comments

My journey to the microwave alternate timeline

https://www.lesswrong.com/posts/8m6AM5qtPMjgTkEeD/my-journey-to-the-microwave-alternate-timeline
309•jstanley•4d ago•133 comments

NASA uses Mars Helicopter's SoC for rover navigation upgrade

https://www.theregister.com/2026/02/23/perseverance_rover_soc_navigation_upgrade/
12•LorenDB•1h ago•3 comments

How in the Hell Did Joann Fabrics Die While Best Buy Survived? It Wasn't Amazon

https://www.governance.fyi/p/how-in-the-hell-did-joann-fabrics
16•crescit_eundo•2h ago•25 comments

Microspeak: Escrow

https://devblogs.microsoft.com/oldnewthing/20260217-00/?p=112067
9•ibobev•4d ago•4 comments

First, They Came for the Journalists

https://www.codastory.com/disinformation/first-they-came-for-the-journalists/
12•cdrnsf•33m ago•0 comments

VTT Test Donut Lab Battery Reaches 80% Charge in Under 10 Minutes [pdf]

https://pub-fee113bb711e441db5c353d2d31abbb3.r2.dev/VTT_CR_00092_26.pdf
74•sagyam•3h ago•59 comments

Man accidentally gains control of 7k robot vacuums

https://www.popsci.com/technology/robot-vacuum-army/
373•Brajeshwar•1d ago•201 comments

Crawling a billion web pages in just over 24 hours, in 2025

https://andrewkchan.dev/posts/crawler.html
90•pseudolus•12h ago•30 comments