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•12mo ago

Comments

LegionMammal978•12mo 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•12mo 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•12mo 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.

Deterministic Fully-Static Whole-Binary Translation Without Heuristics

https://arxiv.org/abs/2605.08419
158•matt_d•4h ago•34 comments

Restore full BambuNetwork support for Bambu Lab printers

https://github.com/FULU-Foundation/OrcaSlicer-bambulab
416•Murfalo•11h ago•177 comments

The vi family

https://lpar.ATH0.com/posts/2026/05/the-vi-family/
155•hggh•1w ago•83 comments

Googlebook

https://googlebook.google/
769•tambourine_man•15h ago•1284 comments

SecurityBaseline.eu

https://internetcleanup.foundation/2026/05/european-governments-3000-tracking-sites-1000-phpmyadm...
135•aequitas•2h ago•53 comments

Show HN: Needle: We Distilled Gemini Tool Calling into a 26M Model

https://github.com/cactus-compute/needle
450•HenryNdubuaku•15h ago•151 comments

"Cannot be explained" – New ultra stainless steel stuns researchers

https://www.sciencedaily.com/releases/2026/05/260510030950.htm
22•HardwareLust•2d ago•0 comments

"I applied to be pope"

https://www.thestandard.com.hk/world/article/331886/I-applied-to-be-pope-Losing-grip-on-reality-w...
29•hansmayer•2h ago•20 comments

How to make your text look futuristic (2016)

https://typesetinthefuture.com/2016/02/18/futuristic/
334•_vaporwave_•12h ago•43 comments

Kraftwerk's radical 1976 track

https://www.bbc.com/culture/article/20260511-kraftwerks-radical-1976-track-radioactivity-became-a...
152•tcp_handshaker•10h ago•101 comments

Why senior developers fail to communicate their expertise

https://www.nair.sh/guides-and-opinions/communicating-your-expertise/why-senior-developers-fail-t...
555•nilirl•18h ago•244 comments

CERT is releasing six CVEs for serious security vulnerabilities in dnsmasq

https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2026q2/018471.html
312•chizhik-pyzhik•15h ago•145 comments

Traceway: MIT-licensed observability stack you can self-host in ~90s

https://github.com/tracewayapp/traceway
98•sebakubisz•2d ago•6 comments

What if there was no BASIC in EndBASIC? – by Julio Merino

https://blogsystem5.substack.com/p/no-basic-in-endbasic
20•rbanffy•3d ago•1 comments

My graduation cap runs Rust

https://ericswpark.com/blog/2026/2026-05-12-my-graduation-cap-runs-rust/
150•ericswpark•9h ago•47 comments

Rendering the Sky, Sunsets, and Planets

https://blog.maximeheckel.com/posts/on-rendering-the-sky-sunsets-and-planets/
472•ibobev•19h ago•38 comments

Scrcpy v4.0

https://github.com/Genymobile/scrcpy/releases/tag/v4.0
172•xnx•12h ago•27 comments

Quack: The DuckDB Client-Server Protocol

https://duckdb.org/2026/05/12/quack-remote-protocol
279•aduffy•15h ago•56 comments

When "idle" isn't idle: how a Linux kernel optimization became a QUIC bug

https://blog.cloudflare.com/quic-death-spiral-fix/
85•sbulaev•9h ago•6 comments

Up in Smoke

https://thebaffler.com/odds-and-ends/the-profession-that-does-not-exist-symposium
20•NaOH•2d ago•1 comments

Referer Reality

https://www.robinsloan.com/lab/referer/
39•tobr•2d ago•11 comments

The Future of Obsidian Plugins

https://obsidian.md/blog/future-of-plugins/
371•xz18r•17h ago•140 comments

Reimagining the mouse pointer for the AI era

https://deepmind.google/blog/ai-pointer/
196•devhouse•15h ago•165 comments

Fc, a lossless compressor for floating-point streams

https://github.com/xtellect/fc
64•enduku•2d ago•13 comments

Tell NYT, Atlantic, USA Today to keep Wayback Machine

https://www.savethearchive.com/newsleaders/
327•doener•10h ago•88 comments

As researchers age, they produce less disruptive work

https://nautil.us/is-this-why-science-advances-one-funeral-at-a-time-1280650
67•Brajeshwar•15h ago•62 comments

Starship V3

https://www.spacex.com/updates#starship-v3
215•fprog•7h ago•304 comments

I made rust's cargo copy but for CPP

https://github.com/user-with-username/crow
10•anybodyy•2d ago•2 comments

Bambu Lab is abusing the open source social contract

https://www.jeffgeerling.com/blog/2026/bambu-lab-abusing-open-source-social-contract/
1253•rubenbe•18h ago•393 comments

Show HN: Agentic interface for mainframes and COBOL

https://www.hypercubic.ai/hopper
72•sai18•16h ago•41 comments