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.

Capital One to acquire Brex for $5.15B

https://www.reuters.com/legal/transactional/capital-one-buy-fintech-firm-brex-515-billion-deal-20...
241•personjerry•7h ago•176 comments

Talking to LLMs has improved my thinking

https://philipotoole.com/why-talking-to-llms-has-improved-my-thinking/
20•otoolep•1h ago•9 comments

GPTZero finds 100 new hallucinations in NeurIPS 2025 accepted papers

https://gptzero.me/news/neurips/
771•segmenta•13h ago•414 comments

Show HN: isometric.nyc – giant isometric pixel art map of NYC

https://cannoneyed.com/isometric-nyc/
764•cannoneyed•12h ago•165 comments

Why does SSH send 100 packets per keystroke?

https://eieio.games/blog/ssh-sends-100-packets-per-keystroke/
368•eieio•9h ago•226 comments

I was banned from Claude for scaffolding a Claude.md file?

https://hugodaniel.com/posts/claude-code-banned-me/
434•hugodan•10h ago•325 comments

Turso is an in-process SQL database, compatible with SQLite

https://github.com/tursodatabase/turso
78•marklit•3d ago•39 comments

Qwen3-TTS family is now open sourced: Voice design, clone, and generation

https://qwen.ai/blog?id=qwen3tts-0115
517•Palmik•15h ago•164 comments

Bugs Apple Loves

https://www.bugsappleloves.com
336•nhod•2h ago•117 comments

The lost art of XML

https://marcosmagueta.com/blog/the-lost-art-of-xml/
31•Curiositry•1h ago•22 comments

Improving the usability of C libraries in Swift

https://www.swift.org/blog/improving-usability-of-c-libraries-in-swift/
76•timsneath•5h ago•3 comments

Douglas Adams on the English–American cultural divide over "heroes"

https://shreevatsa.net/post/douglas-adams-cultural-divide/
380•speckx•15h ago•374 comments

Captive Wi-Fi

https://en.wikipedia.org/wiki/Captive_portal
10•nomilk•4d ago•5 comments

Scaling PostgreSQL to power 800M ChatGPT users

https://openai.com/index/scaling-postgresql/
102•mustaphah•7h ago•33 comments

Your app subscription is now my weekend project

https://rselbach.com/your-sub-is-now-my-weekend-project
278•robteix•4d ago•205 comments

Launch HN: Constellation Space (YC W26) – AI for satellite mission assurance

33•kmajid•12h ago•15 comments

My first year in sales as technical founder

https://www.fabiandietrich.com/blog/first-year-in-sales.html
98•f3b5•5d ago•45 comments

CSS Optical Illusions

https://alvaromontoro.com/blog/68091/css-optical-illusions
157•ulrischa•11h ago•13 comments

Show HN: Text-to-video model from scratch (2 brothers, 2 years, 2B params)

https://huggingface.co/collections/Linum-AI/linum-v2-2b-text-to-video
57•schopra909•12h ago•11 comments

Recent discoveries on the acquisition of the highest levels of human performance

https://www.science.org/doi/abs/10.1126/science.adt7790
118•colincooke•11h ago•54 comments

Why medieval city-builder video games are historically inaccurate (2020)

https://www.leidenmedievalistsblog.nl/articles/why-medieval-city-builder-video-games-are-historic...
92•benbreen•4h ago•52 comments

The Cscript Style Guide – CScript is the standard C

https://github.com/domenukk/CScript
7•domenukk•1h ago•4 comments

'Active' sitting is better for brain health: review of studies

https://www.sciencealert.com/not-all-sitting-is-equal-one-type-was-just-linked-to-better-brain-he...
84•mikhael•10h ago•34 comments

Writing First, Tooling Second

https://susam.net/writing-first-tooling-second.html
3•blenderob•3d ago•0 comments

Stunnel

https://www.stunnel.org/
46•firesteelrain•4h ago•11 comments

Compiling Scheme to WebAssembly

https://eli.thegreenplace.net/2026/compiling-scheme-to-webassembly/
82•chmaynard•5d ago•11 comments

Show HN: BrowserOS – "Claude Cowork" in the browser

https://github.com/browseros-ai/BrowserOS
47•felarof•12h ago•23 comments

Anthropic Economic Index economic primitives

https://www.anthropic.com/research/anthropic-economic-index-january-2026-report
75•malshe•7h ago•43 comments

In Europe, wind and solar overtake fossil fuels

https://e360.yale.edu/digest/europe-wind-solar-fossil-fuels
527•speckx•15h ago•539 comments

AnswerThis (YC F25) Is Hiring

https://www.ycombinator.com/companies/answerthis/jobs/r5VHmSC-ai-agent-orchestration
1•ayush4921•12h ago