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.

Resizing windows on macOS Tahoe – the saga continues

https://noheger.at/blog/2026/02/12/resizing-windows-on-macos-tahoe-the-saga-continues/
67•erickhill•1h ago•33 comments

GPT‑5.3‑Codex‑Spark

https://openai.com/index/introducing-gpt-5-3-codex-spark/
529•meetpateltech•7h ago•216 comments

Gemini 3 Deep Think

https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-3-deep-think/
624•tosh•8h ago•377 comments

AWS Adds support for nested virtualization

https://github.com/aws/aws-sdk-go-v2/commit/3dca5e45d5ad05460b93410087833cbaa624754e
34•sitole•1h ago•10 comments

An AI agent published a hit piece on me

https://theshamblog.com/an-ai-agent-published-a-hit-piece-on-me/
1406•scottshambaugh•8h ago•600 comments

Ring cancels its partnership with Flock Safety after surveillance backlash

https://www.theverge.com/news/878447/ring-flock-partnership-canceled
98•c420•1h ago•39 comments

My Grandma Was a Fed – Lessons from Digitizing Hours of Childhood

https://sampatt.com/blog/2025-12-13-my-grandma-was-a-fed-lessons-from-digitizing-hundreds-of-hour...
22•SamPatt•4d ago•1 comments

Polis: Open-source platform for large-scale civic deliberation

https://pol.is/home2
165•mefengl•6h ago•66 comments

Improving 15 LLMs at Coding in One Afternoon. Only the Harness Changed

http://blog.can.ac/2026/02/12/the-harness-problem/
550•kachapopopow•11h ago•221 comments

Major European payment processor can't send email to Google Workspace users

https://atha.io/blog/2026-02-12-viva
447•thatha7777•10h ago•300 comments

Recoverable and Irrecoverable Decisions

https://herbertlui.net/recoverable-and-irrecoverable-decisions/
23•herbertl•2h ago•6 comments

Beginning fully autonomous operations with the 6th-generation Waymo driver

https://waymo.com/blog/2026/02/ro-on-6th-gen-waymo-driver
149•ra7•9h ago•142 comments

Launch HN: Omnara (YC S25) – Run Claude Code and Codex from anywhere

94•kmansm27•8h ago•123 comments

Rari – Rust-powered React framework

https://rari.build/
94•bvanvugt•5h ago•48 comments

Apache Arrow is 10 years old

https://arrow.apache.org/blog/2026/02/12/arrow-anniversary/
182•tosh•12h ago•45 comments

Fixing retail with land value capture

https://worksinprogress.co/issue/fixing-retail-with-land-value-capture/
53•marojejian•4h ago•93 comments

How to Have a Bad Career – David Patterson (2016) [video]

https://www.youtube.com/watch?v=Rn1w4MRHIhc
52•rombr•6h ago•14 comments

Anthropic raises $30B in Series G funding at $380B post-money valuation

https://www.anthropic.com/news/anthropic-raises-30-billion-series-g-funding-380-billion-post-mone...
243•ryanhn•6h ago•264 comments

How a Cat Debugged Stable Diffusion (2023)

https://blog.dwac.dev/posts/cat-debugging/
4•lukasgelbmann•4d ago•0 comments

A brief history of barbed wire fence telephone networks (2024)

https://loriemerson.net/2024/08/31/a-brief-history-of-barbed-wire-fence-telephone-networks/
126•keepamovin•10h ago•35 comments

Partial 8-Piece Tablebase

https://lichess.org/@/Lichess/blog/op1-partial-8-piece-tablebase-available/1ptPBDpC
33•qsort•3d ago•0 comments

ICE, CBP Knew Facial Recognition App Couldn't Do What DHS Says It Could

https://www.techdirt.com/2026/02/12/ice-cbp-knew-facial-recognition-app-couldnt-do-what-dhs-says-...
142•cdrnsf•4h ago•37 comments

Welcoming Discord users amidst the challenge of Age Verification

https://matrix.org/blog/2026/02/welcome-discord/
213•foresto•4h ago•104 comments

The "Crown of Nobles" Noble Gas Tube Display (2024)

https://theshamblog.com/the-crown-of-nobles-noble-gas-tube-display/
122•Ivoah•12h ago•27 comments

Show HN: Geo Racers – Race from London to Tokyo on a single bus pass

https://geo-racers.com/
94•pattle•14h ago•71 comments

Shut Up: Comment Blocker

https://rickyromero.com/shutup/
82•mefengl•8h ago•33 comments

The Future for Tyr, a Rust GPU Driver for Arm Mali Hardware

https://lwn.net/Articles/1055590/
116•todsacerdoti•10h ago•35 comments

Culture Is the Mass-Synchronization of Framings

https://aethermug.com/posts/culture-is-the-mass-synchronization-of-framings
124•mrcgnc•10h ago•74 comments

Discord Just Killed Anonymity

https://michael-dev-tech.github.io/Website/matrix.html
99•f0r3st•2h ago•95 comments

ai;dr

https://www.0xsid.com/blog/aidr
571•ssiddharth•8h ago•220 comments