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•1y ago

Comments

LegionMammal978•1y 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•1y 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•1y 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.

Microsoft degrades functionality of perpetually-licensed offline products

https://consumerrights.wiki/w/Microsoft_Office_2019_and_2021_for_Mac_view-only_conversion_(2026)
360•antipurist•2h ago•119 comments

Domain expertise has always been the real moat

https://www.brethorsting.com/blog/2026/05/domain-expertise-has-always-been-the-real-moat/
298•aaronbrethorst•5h ago•181 comments

Anyone can build a platform now. Almost nobody can get people to find it

https://claudefolio.com/blog/anyone-can-build-a-platform-now-almost-nobody-can-get-people-to-find-it
34•misterinfo•1h ago•16 comments

I found a seashell in the middle of the desert

https://github.com/Hawzen/I-found-a-seashell-in-the-middle-of-the-desert
220•Hawzen•1d ago•64 comments

Shantell Sans

https://shantellsans.com/process
76•aleda145•4h ago•7 comments

Accenture to acquire Ookla

https://newsroom.accenture.com/news/2026/accenture-to-acquire-ookla-to-strengthen-network-intelli...
242•Garbage•9h ago•125 comments

wolfSSL releases a new product; wolfCOSE a zero alloc C embbedded COSE stack

https://github.com/wolfSSL/wolfCOSE
66•aidangarske•5h ago•12 comments

Jef Raskin, the Visionary Behind the Mac (2013)

https://lowendmac.com/2013/jef-raskin-the-visionary-behind-the-mac/
72•tylerdane•6h ago•36 comments

Cheese Paper: a text editor specifically designed for writing

https://brie.gay/cheese-paper/
49•sohkamyung•3h ago•8 comments

Zig ELF Linker Improvements Devlog

https://ziglang.org/devlog/2026/#2026-05-30
172•kristoff_it•8h ago•49 comments

Voxel Space (2017)

https://s-macke.github.io/VoxelSpace/
252•davikr•11h ago•56 comments

Parallel Reconstruction of Lawful TLS Wiretapping

https://remyhax.xyz/posts/reproducing-lawful-tls-wiretapping/
57•jerrythegerbil•6h ago•28 comments

OpenRouter raises $113M Series B

https://openrouter.ai/announcements/series-b
359•freeCandy•8h ago•177 comments

Racket v9.2 is now available

https://blog.racket-lang.org/2026/05/racket-v9-2.html
16•spdegabrielle•2d ago•1 comments

Openrsync: An implementation of rsync, by the OpenBSD team

https://github.com/kristapsdz/openrsync
322•sph•15h ago•141 comments

Dusklight – GC Twilight Princess Decompiled

https://twilitrealm.dev/
66•shepherdjerred•5h ago•6 comments

Gustav Klimt and Egon Schiele in Conversation (2018)

https://www.theparisreview.org/blog/2018/01/31/the-drawings-of-klimt-and-schiele/
18•rballpug•2d ago•3 comments

Show HN: 500 years of Joseon court omens as an observability dashboard

https://ajin.im/is/building/omen.ops/
79•poppypetalmask•6h ago•12 comments

Design Engineering Magazine

https://interfaces.dev/
58•hnhsh•5h ago•5 comments

Microcode inside the Intel 8087 floating-point chip: register exchange

https://www.righto.com/2026/05/microcode-inside-intel-8087-floating.html
85•pwg•8h ago•16 comments

90% of the T Distribution

https://entropicthoughts.com/ninety-percent-of-the-t-distribution
25•ibobev•3d ago•7 comments

Pandoc Templates

https://pandoc-templates.org/
362•ankitg12•16h ago•48 comments

Rotary GPU: Exploring Local Execution for Large MoE Models Under Limited VRAM

https://arxiv.org/abs/2605.29135
21•dryarzeg•5h ago•3 comments

C++ CLI for folder encryption with AES-256-GCM and USB-based key loading

9•nextma•2d ago•3 comments

Zig: Build System Reworked

https://ziglang.org/devlog/2026/#2026-05-26
321•tosh•17h ago•210 comments

Tsplat – Run Gaussian splatting in your terminal

https://github.com/darshanmakwana412/tsplat
28•martianvoid•2d ago•7 comments

Navier-Stokes fluid simulation explained with Godot game engine

https://myzopotamia.dev/navier-stokes-fluid-simulation-explained-with-godot
186•myzek•4d ago•24 comments

Werner Herzog in conversation with Paul Cronin (2014)

https://fsgworkinprogress.com/2014/09/26/insignificant-bullets-evil-poachers-and-l-a-culture/
75•Michelangelo11•10h ago•24 comments

Leo's first encyclical attacks technological messianism

https://www.economist.com/europe/2026/05/28/leos-first-encyclical-attacks-technological-messianism
184•1vuio0pswjnm7•15h ago•207 comments

Show HN: Open Envelope – an open schema for defining AI agent teams

https://openenvelope.org/docs/schema/
27•ashconway•2d ago•2 comments