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.

Doing gigabit Ethernet over my British phone wires

https://thehftguy.com/2026/01/22/doing-gigabit-ethernet-over-my-british-phone-wires/
119•user5994461•2h ago•64 comments

Show HN: I built a space travel calculator using Vanilla JavaScript

https://cosmic-odometer.vercel.app/
32•captainnemo729•2h ago•20 comments

Internet Archive's Storage

https://blog.dshr.org/2026/01/internet-archives-storage.html
181•zdw•3d ago•41 comments

Show HN: Coi – A language that compiles to WASM, beats React/Vue

64•io_eric•3d ago•25 comments

Unrolling the Codex agent loop

https://openai.com/index/unrolling-the-codex-agent-loop/
356•tosh•15h ago•164 comments

80386 Multiplication and Division

https://nand2mario.github.io/posts/2026/80386_multiplication_and_division/
54•nand2mario•6h ago•9 comments

Proof of Corn

https://proofofcorn.com/
401•rocauc•18h ago•276 comments

Modetc: Move your dotfiles from kernel space

https://maxwell.eurofusion.eu/git/rnhmjoj/modetc
20•todsacerdoti•4h ago•8 comments

Traintrackr – Live LED Maps

https://www.traintrackr.co.uk/
58•recursion•5d ago•22 comments

Extracting verified C++ from the Rocq theorem prover at Bloomberg

https://bloomberg.github.io/crane/
63•clarus•4d ago•4 comments

Gas Town's agent patterns, design bottlenecks, and vibecoding at scale

https://maggieappleton.com/gastown
346•pavel_lishin•20h ago•352 comments

“Let people help” – Advice that made a big difference to a grieving widow

https://www.npr.org/2026/01/20/nx-s1-5683170/let-them-the-small-bit-of-advice-that-made-a-big-dif...
72•NaOH•9h ago•11 comments

Management Time: Who's Got the Monkey? [pdf]

https://www.med.unc.edu/uncaims/wp-content/uploads/sites/764/2014/03/Oncken-_-Wass-Who_s-Got-the-...
6•rintrah•4d ago•1 comments

Banned C++ features in Chromium

https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-features.md
188•szmarczak•15h ago•156 comments

Telli (YC F24) is hiring eng, design, growth [on-site, Berlin]

https://careers.telli.com/
1•sebselassie•5h ago

Comma openpilot – Open source driver-assistance

https://comma.ai
292•JumpCrisscross•11h ago•158 comments

Microsoft gave FBI set of BitLocker encryption keys to unlock suspects' laptops

https://techcrunch.com/2026/01/23/microsoft-gave-fbi-a-set-of-bitlocker-encryption-keys-to-unlock...
884•bookofjoe•18h ago•569 comments

Some C habits I employ for the modern day

https://www.unix.dog/~yosh/blog/c-habits-for-me.html
167•signa11•5d ago•99 comments

Ask HN: What's the current best local/open speech-to-speech setup?

175•dsrtslnd23•1d ago•42 comments

New YC homepage

https://www.ycombinator.com/
262•sarreph•18h ago•130 comments

Booting from a vinyl record (2020)

https://boginjr.com/it/sw/dev/vinyl-boot/
323•yesturi•1d ago•110 comments

Unveiling Firestore Pipeline operations – Firestore's powerful new query engine

https://firebase.blog/posts/2026/01/firestore-enterprise-pipeline-operations
6•reimertz•5d ago•2 comments

Mental Models (2018)

https://fs.blog/mental-models/
104•hahahacorn•15h ago•14 comments

Proton spam and the AI consent problem

https://dbushell.com/2026/01/22/proton-spam/
523•dbushell•1d ago•372 comments

KORG phase8 – Acoustic Synthesizer

https://www.korg.com/us/products/dj/phase8/
239•bpierre•21h ago•105 comments

The tech monoculture is finally breaking

http://www.jasonwillems.com/technology/2025/12/17/Tech-Is-Fun-Again/
205•at1as•21h ago•270 comments

Route leak incident on January 22, 2026

https://blog.cloudflare.com/route-leak-incident-january-22-2026/
150•nomaxx117•18h ago•48 comments

Air traffic control: the IBM 9020

https://computer.rip/2026-01-17-air-traffic-control-9020.html
41•pinewurst•5d ago•4 comments

Show HN: Whosthere: A LAN discovery tool with a modern TUI, written in Go

https://github.com/ramonvermeulen/whosthere
252•rvermeulen98•1d ago•84 comments

Wilson Lin on FastRender: a browser built by parallel agents

https://simonwillison.net/2026/Jan/23/fastrender/
62•lumpa•13h ago•25 comments