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

Comments

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

Sugar industry influenced researchers and blamed fat for CVD (2016)

https://www.ucsf.edu/news/2016/09/404081/sugar-papers-reveal-industry-role-shifting-national-hear...
438•aldarion•5h ago•281 comments

NPM to implement staged publishing after turbulent shift off classic tokens

https://socket.dev/blog/npm-to-implement-staged-publishing
54•feross•1h ago•4 comments

Shipmap.org

https://www.shipmap.org/
282•surprisetalk•5h ago•45 comments

Health care data breach affects over 600k patients, Illinois agency says

https://www.nprillinois.org/illinois/2026-01-06/health-care-data-breach-affects-600-000-patients-...
86•toomuchtodo•3h ago•36 comments

LaTeX Coffee Stains [pdf] (2021)

https://ctan.math.illinois.edu/graphics/pgf/contrib/coffeestains/coffeestains-en.pdf
225•zahrevsky•5h ago•45 comments

Creators of Tailwind laid off 75% of their engineering team

https://github.com/tailwindlabs/tailwindcss.com/pull/2388
580•kevlened•4h ago•353 comments

A4 Paper Stories

https://susam.net/a4-paper-stories.html
240•blenderob•7h ago•116 comments

Eat Real Food

https://realfood.gov
100•atestu•2h ago•228 comments

A tab hoarder's journey to sanity

https://twitter.com/borisandcrispin/status/2008709479068794989
51•borisandcrispin•2h ago•49 comments

US will ban Wall Street investors from buying single-family homes

https://www.reuters.com/world/us/us-will-ban-large-institutional-investors-buying-single-family-h...
134•kpw94•59m ago•110 comments

Many hells of WebDAV

https://candid.dev/blog/many-hells-of-webdav
75•candiddevmike•4h ago•49 comments

Native Amiga Filesystems on macOS / Linux / Windows with FUSE

https://github.com/reinauer/amifuse
25•doener•4d ago•0 comments

Meditation as Wakeful Relaxation: Unclenching Smooth Muscle

https://psychotechnology.substack.com/p/meditation-as-wakeful-relaxation
102•surprisetalk•5h ago•65 comments

The Case for Nushell (2023)

https://www.sophiajt.com/case-for-nushell/
52•ravenical•3h ago•32 comments

Building voice agents with Nvidia open models

https://www.daily.co/blog/building-voice-agents-with-nvidia-open-models/
37•kwindla•4h ago•1 comments

How Google got its groove back and edged ahead of OpenAI

https://www.wsj.com/tech/ai/google-ai-openai-gemini-chatgpt-b766e160
41•jbredeche•3h ago•32 comments

Show HN: I built a "Do not disturb" Device for my home office

https://apoorv.page/blogs/over-engineered-dnd
55•quacky_batak•4d ago•25 comments

BillG the Manager (2021)

https://hardcoresoftware.learningbyshipping.com/p/019-billg-the-manager
36•rbanffy•3h ago•15 comments

Polymarket refuses to pay bets that US would 'invade' Venezuela

https://www.ft.com/content/985ae542-1ab4-491e-8e6e-b30f6a3ab666
124•petethomas•17h ago•86 comments

Residues: Time, Change and Uncertainty in Software Architecture [video]

https://www.youtube.com/watch?v=D8qQUHrksrE
4•zdw•4d ago•0 comments

Becoming a Centenarian

https://www.newyorker.com/magazine/2025/12/22/becoming-a-centenarian
39•mrjaeger•4d ago•3 comments

Optery (YC W22) Hiring a CISO and Web Scraping Engineers (Node) (US and Latam)

https://www.optery.com/careers/
1•beyondd•8h ago

Texas A&M bans part of Plato's Symposium

https://dailynous.com/2026/01/06/texas-am-bans-plato/
123•loughnane•2h ago•43 comments

Show HN: Free and local browser tool for designing gear models for 3D printing

https://gears.dmtrkovalenko.dev
25•neogoose•11h ago•8 comments

“Stop Designing Languages. Write Libraries Instead” (2016)

https://lbstanza.org/purpose_of_programming_languages.html
206•teleforce•7h ago•191 comments

Sergey Brin's Unretirement

https://www.inc.com/jessica-stillman/google-co-founder-sergey-brins-unretirement-is-a-lesson-for-...
350•iancmceachern•6d ago•416 comments

Quake Brutalist Jam III

https://www.slipseer.com/index.php?resources/quake-brutalist-jam-iii.549/
150•Venn1•2d ago•21 comments

Dell's CES 2026 chat was the most pleasingly un-AI briefing I've had in 5 years

https://www.pcgamer.com/hardware/dells-ces-2026-chat-was-the-most-pleasingly-un-ai-briefing-ive-h...
110•mossTechnician•4h ago•65 comments

Opus 4.5 is not the normal AI agent experience that I have had thus far

https://burkeholland.github.io/posts/opus-4-5-change-everything/
783•tbassetto•1d ago•1182 comments

Vector graphics on GPU

https://gasiulis.name/vector-graphics-on-gpu/
145•gsf_emergency_6•4d ago•34 comments