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

Comments

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

Show HN: A game where you build a GPU

https://jaso1024.com/mvidia/
729•Jaso1024•16h ago•154 comments

Introduction to Computer Music (2009) [pdf]

https://composerprogrammer.com/introductiontocomputermusic.pdf
148•luu•7h ago•46 comments

OpenScreen is an open-source alternative to Screen Studio

https://github.com/siddharthvaddem/openscreen
278•jskopek•4d ago•49 comments

German implementation of eIDAS will require an Apple/Google account to function

https://bmi.usercontent.opencode.de/eudi-wallet/wallet-development-documentation-public/latest/ar...
228•DyslexicAtheist•10h ago•156 comments

Lisette a little language inspired by Rust that compiles to Go

https://lisette.run/
28•jspdown•2h ago•13 comments

LLM Wiki – example of an "idea file"

https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f
182•tamnd•16h ago•53 comments

Rubysyn: Clarifying Ruby's Syntax and Semantics

https://github.com/squadette/rubysyn/blob/master/README.md
38•petalmind•3d ago•2 comments

Zml-smi: universal monitoring tool for GPUs, TPUs and NPUs

https://zml.ai/posts/zml-smi/
42•steeve•4d ago•6 comments

How many products does Microsoft have named 'Copilot'?

https://teybannerman.com/strategy/2026/03/31/how-many-microsoft-copilot-are-there.html
630•gpi•13h ago•298 comments

Scientists Figured Out How Eels Reproduce (2022)

https://www.intelligentliving.co/scientists-finally-figured-out-how-eels-reproduce/
17•thunderbong•3d ago•0 comments

AWS engineer reports PostgreSQL perf halved by Linux 7.0, fix may not be easy

https://www.phoronix.com/news/Linux-7.0-AWS-PostgreSQL-Drop
274•crcastle•9h ago•80 comments

Show HN: I built a small app for FSI German Course

https://detawk.com/
28•syedmsawaid•2d ago•10 comments

Aegis – open-source FPGA silicon

https://github.com/MidstallSoftware/aegis
16•rosscomputerguy•3h ago•1 comments

Show HN: Contrapunk – Real-time counterpoint harmony from guitar input, in Rust

https://contrapunk.com/
64•waveywaves•8h ago•25 comments

Nvim-treesitter (13K+ Stars) is Archived

https://github.com/nvim-treesitter/nvim-treesitter/discussions/8627
116•RohanAdwankar•9h ago•35 comments

Modern Generic SVGA driver for Windows 3.1

https://github.com/PluMGMK/vbesvga.drv
34•userbinator•3h ago•5 comments

Show HN: sllm – Split a GPU node with other developers, unlimited tokens

https://sllm.cloud
158•jrandolf•17h ago•78 comments

Show HN: I made open source, zero power PCB hackathon badges

https://github.com/KaiPereira/Overglade-Badges
95•kaipereira•18h ago•10 comments

Components of a Coding Agent

https://magazine.sebastianraschka.com/p/components-of-a-coding-agent
232•MindGods•20h ago•73 comments

The Indie Internet Index – submit your favorite sites

https://iii.social
143•freshman_dev•18h ago•28 comments

Ruckus: Racket for iOS

https://ruckus.defn.io/
125•nsm•2d ago•11 comments

Electrical transformer manufacturing is throttling the electrified future

https://www.bloomberg.com/features/2025-bottlenecks-transformers/
85•toomuchtodo•3d ago•74 comments

Advice to young people, the lies I tell myself (2024)

https://jxnl.co/writing/2024/06/01/advice-to-young-people/
102•mooreds•9h ago•29 comments

Apple approves driver that lets Nvidia eGPUs work with Arm Macs

https://www.theverge.com/tech/907003/apple-approves-driver-that-lets-nvidia-egpus-work-with-arm-macs
427•naves•17h ago•189 comments

Show HN: M. C. Escher spiral in WebGL inspired by 3Blue1Brown

https://static.laszlokorte.de/escher/
75•laszlokorte•13h ago•12 comments

Show HN: TurboQuant-WASM – Google's vector quantization in the browser

https://github.com/teamchong/turboquant-wasm
153•teamchong•18h ago•6 comments

Embarrassingly simple self-distillation improves code generation

https://arxiv.org/abs/2604.01193
590•Anon84•22h ago•177 comments

The CMS is dead, long live the CMS

https://next.jazzsequence.com/posts/the-cms-is-dead-long-live-the-cms
142•taubek•21h ago•88 comments

Breaking Enigma with Index of Coincidence on a Commodore 64

https://imapenguin.com/2026/03/breaking-enigma-with-index-of-coincidence-on-a-commodore-64/
41•saganus•4d ago•4 comments

Demonstrating Real Time AV2 Decoding on Consumer Laptops

http://aomedia.org/blog%20posts/Demonstrating-Real-Time-AV2-Decoding-on-Consumer-Laptops/
16•breve•7h ago•1 comments