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

Comments

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

Cloudflare outage on November 18, 2025 post mortem

https://blog.cloudflare.com/18-november-2025-outage/
515•eastdakota•4h ago•321 comments

Gemini 3

https://blog.google/products/gemini/gemini-3/
1216•preek•12h ago•791 comments

Google Antigravity

https://antigravity.google/
737•Fysi•12h ago•777 comments

Pebble, Rebble, and a path forward

https://ericmigi.com/blog/pebble-rebble-and-a-path-forward/
343•phoronixrly•10h ago•165 comments

Blender 5.0

https://www.blender.org/download/releases/5-0/
534•FrostKiwi•6h ago•160 comments

Show HN: Browser-based interactive 3D Three-Body problem simulator

https://trisolarchaos.com/?pr=O_8(0.6)&n=3&s=5.0&so=0.00&im=rk4&dt=1.00e-4&rt=1.0e-6&at=1.0e-8&bs...
28•jgchaos•12h ago•13 comments

The code and open-source tools I used to produce a science fiction anthology

https://compellingsciencefiction.com/posts/the-code-and-open-source-tools-i-used-to-produce-a-sci...
95•mojoe•11h ago•11 comments

Gemini 3 Pro Model Card [pdf]

https://storage.googleapis.com/deepmind-media/Model-Cards/Gemini-3-Pro-Model-Card.pdf
185•virgildotcodes•16h ago•311 comments

Better pre-commit, re-engineered in Rust

https://prek.j178.dev/
13•nikolay•4d ago•1 comments

Rebecca Heineman – from homelessness to porting Doom (2022)

https://corecursive.com/doomed-to-fail-with-burger-becky/
141•birdculture•4h ago•24 comments

Lucent 7 R/E 5ESS Telephone Switch Rescue (2024)

http://kev009.com/wp/2024/07/Lucent-5ESS-Rescue/
29•gjvc•3h ago•10 comments

Cloudflare Global Network experiencing issues

https://www.cloudflarestatus.com/incidents/8gmgl950y3h7
2324•imdsm•16h ago•1595 comments

I am stepping down as the CEO of Mastodon

https://blog.joinmastodon.org/2025/11/my-next-chapter-with-mastodon/
367•Tomte•9h ago•269 comments

GitHub: Git operation failures

https://www.githubstatus.com/incidents/5q7nmlxz30sk
341•wilhelmklopp•7h ago•283 comments

OrthoRoute – GPU-accelerated autorouting for KiCad

https://bbenchoff.github.io/pages/OrthoRoute.html
125•wanderingjew•8h ago•12 comments

Fizz Buzz without conditionals or booleans

https://evanhahn.com/fizz-buzz-without-conditionals-or-booleans/
16•ingve•5d ago•12 comments

What I learned about creativity from a man painting on a treadmill (2024)

https://quinnmaclay.com/texts/lets-paint
32•8organicbits•4d ago•6 comments

Bild AI (YC W25) is hiring – Make housing affordable

https://www.ycombinator.com/companies/bild-ai/jobs/m2ilR5L-founding-engineer-applied-ai
1•rooppal•6h ago

Show HN: RowboatX – open-source Claude Code for everyday automations

https://github.com/rowboatlabs/rowboat
68•segmenta•9h ago•15 comments

Solving a million-step LLM task with zero errors

https://arxiv.org/abs/2511.09030
142•Anon84•11h ago•45 comments

DOE gives Microsoft partner $1B loan to restart Three Mile Island reactor

https://techcrunch.com/2025/11/18/trump-doe-gives-microsoft-partner-1b-loan-to-restart-three-mile...
31•pseudolus•1h ago•13 comments

Monotype font licencing shake-down

https://www.insanityworks.org/randomtangent/2025/11/14/monotype-font-licencing-shake-down
114•evolve2k•5h ago•32 comments

Google boss says AI investment boom has 'elements of irrationality'

https://www.bbc.com/news/articles/cwy7vrd8k4eo
193•jillesvangurp•21h ago•368 comments

Nearly all UK drivers say headlights are too bright

https://www.bbc.com/news/articles/c1j8ewy1p86o
693•YeGoblynQueenne•13h ago•706 comments

Microsoft-backed Veir is bringing superconductors to data centers

https://techcrunch.com/2025/11/12/microsoft-backed-veir-targets-data-centers-for-its-megawatt-cla...
14•sudonanohome•5d ago•2 comments

Short Little Difficult Books

https://countercraft.substack.com/p/short-little-difficult-books
154•crescit_eundo•13h ago•87 comments

Mysterious holes in the Andes may have been an ancient marketplace

https://www.sydney.edu.au/news-opinion/news/2025/11/10/mysterious-holes-in-the-andes-may-have-bee...
39•gmays•6d ago•14 comments

Show HN: A subtly obvious e-paper room air monitor

https://www.nicolin-dora.ch/blog/en-epaper-room-air-monitor-part-1/
41•nomarv•20h ago•10 comments

Trying out Gemini 3 Pro with audio transcription and a new pelican benchmark

https://simonwillison.net/2025/Nov/18/gemini-3/
131•nabla9•8h ago•47 comments

Show HN: Guts – convert Golang types to TypeScript

https://github.com/coder/guts
77•emyrk•9h ago•21 comments