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

Comments

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

ASCII characters are not pixels: a deep dive into ASCII rendering

https://alexharri.com/blog/ascii-rendering
79•alexharri•1h ago•7 comments

ClickHouse acquires Langfuse

https://langfuse.com/blog/joining-clickhouse
82•tin7in•3h ago•20 comments

The 600-year-old origins of the word 'hello'

https://www.bbc.com/culture/article/20260113-hello-hiya-aloha-what-our-greetings-reveal
14•1659447091•50m ago•3 comments

The Dilbert Afterlife

https://www.astralcodexten.com/p/the-dilbert-afterlife
27•rendall•22h ago•8 comments

Map To Poster – Create Art of your favourite city

https://github.com/originalankur/maptoposter
41•originalankur•2h ago•21 comments

Show HN: Streaming gigabyte medical images from S3 without downloading them

https://github.com/PABannier/WSIStreamer
49•el_pa_b•3h ago•9 comments

US electricity demand surged in 2025 – solar handled 61% of it

https://electrek.co/2026/01/16/us-electricity-demand-surged-in-2025-solar-handled-61-percent/
71•doener•2h ago•28 comments

East Germany balloon escape

https://en.wikipedia.org/wiki/East_Germany_balloon_escape
551•robertvc•19h ago•217 comments

After 25 years, Wikipedia has proved that news doesn't need to look like news

https://www.niemanlab.org/2026/01/after-25-years-wikipedia-has-proved-that-news-doesnt-need-to-lo...
89•giuliomagnifico•2h ago•60 comments

Cloudflare acquires Astro

https://astro.build/blog/joining-cloudflare/
846•todotask2•22h ago•366 comments

Architecture for Disposable Systems

https://tuananh.net/2026/01/15/architecture-for-disposable-systems/
8•tuananh•1h ago•3 comments

Lies, Damned Lies and Proofs: Formal Methods Are Not Slopless

https://www.lesswrong.com/posts/rhAPh3YzhPoBNpgHg/lies-damned-lies-and-proofs-formal-methods-are-...
40•OgsyedIE•3d ago•19 comments

High-Level Is the Goal

https://bvisness.me/high-level/
167•tobr•2d ago•80 comments

Cursor's latest “browser experiment” implied success without evidence

https://embedding-shapes.github.io/cursor-implied-success-without-evidence/
590•embedding-shape•22h ago•257 comments

FLUX.2 [Klein]: Towards Interactive Visual Intelligence

https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence
166•GaggiX•12h ago•48 comments

Fitdrop: Personal exploration of fashion from 1980 to 2025

https://fitdrop.cc/
3•num42•1h ago•0 comments

6-Day and IP Address Certificates Are Generally Available

https://letsencrypt.org/2026/01/15/6day-and-ip-general-availability
427•jaas•21h ago•240 comments

AV1 Image File Format Specification Gets an Upgrade with AVIF v1.2.0

https://aomedia.org/blog%20posts/AV1-Image-File-Format-Specification-Gets-an-Upgrade-with-AVIF/
14•breve•1h ago•0 comments

Post-PARA: What survived 4 years of real use

https://cortwave.github.io/posts/post-para/
9•cortwave•4d ago•0 comments

LLM Structured Outputs Handbook

https://nanonets.com/cookbooks/structured-llm-outputs
277•vitaelabitur•1d ago•45 comments

Drone Hacking Part 1: Dumping Firmware and Bruteforcing ECC

https://neodyme.io/en/blog/drone_hacking_part_1/
86•tripdout•10h ago•10 comments

Releasing rainbow tables to accelerate Net-NTLMv1 protocol deprecation

https://cloud.google.com/blog/topics/threat-intelligence/net-ntlmv1-deprecation-rainbow-tables
127•linolevan•14h ago•72 comments

Dell UltraSharp 52 Thunderbolt Hub Monitor

https://www.dell.com/en-us/shop/dell-ultrasharp-52-thunderbolt-hub-monitor-u5226kw/apd/210-bthw/m...
239•cebert•19h ago•300 comments

PCs refuse to shut down after Microsoft patch

https://www.theregister.com/2026/01/16/patch_tuesday_secure_launch_bug_no_shutdown/
39•smurda•1h ago•40 comments

STFU

https://github.com/Pankajtanwarbanna/stfu
878•tanelpoder•19h ago•532 comments

Reading across books with Claude Code

https://pieterma.es/syntopic-reading-claude/
108•gmays•17h ago•23 comments

Gut micro-organisms associated with health, nutrition and dietary intervention

https://www.nature.com/articles/s41586-025-09854-7?lid=t94o71j7gslg
11•lonelyasacloud•1h ago•1 comments

Keifu – A TUI for navigating commit graphs with color and clarity

https://github.com/trasta298/keifu
53•indigodaddy•12h ago•8 comments

Show HN: Fun things to do with your VM/370 machine

https://rbanffy.github.io/fun-with-old-mainframes.github.io/fun-with-vm370.html
9•rbanffy•5d ago•3 comments

The five orders of ignorance (2000)

https://cacm.acm.org/opinion/the-five-orders-of-ignorance/
73•svilen_dobrev•4d ago•18 comments