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

Zig – Type Resolution Redesign and Language Changes

https://ziglang.org/devlog/2026/#2026-03-10
232•Retro_Dev•9h ago•78 comments

Building a TB-303 from Scratch

https://loopmaster.xyz/tutorials/tb303-from-scratch
32•stagas•3d ago•7 comments

Create value for others and don’t worry about the returns

https://geohot.github.io//blog/jekyll/update/2026/03/11/running-69-agents.html
344•ppew•4h ago•189 comments

U+237C ⍼ Is Azimuth

https://ionathan.ch/2026/02/16/angzarr.html
311•cokernel_hacker•11h ago•32 comments

Cloudflare crawl endpoint

https://developers.cloudflare.com/changelog/post/2026-03-10-br-crawl-endpoint/
314•jeffpalmer•11h ago•119 comments

TADA: Fast, Reliable Speech Generation Through Text-Acoustic Synchronization

https://www.hume.ai/blog/opensource-tada
44•smusamashah•4h ago•8 comments

Julia Snail – An Emacs Development Environment for Julia Like Clojure's Cider

https://github.com/gcv/julia-snail
74•TheWiggles•3d ago•8 comments

Tony Hoare has died

https://blog.computationalcomplexity.org/2026/03/tony-hoare-1934-2026.html
1798•speckx•19h ago•230 comments

Yann LeCun raises $1B to build AI that understands the physical world

https://www.wired.com/story/yann-lecun-raises-dollar1-billion-to-build-ai-that-understands-the-ph...
476•helloplanets•1d ago•384 comments

AutoKernel: Autoresearch for GPU Kernels

https://github.com/RightNow-AI/autokernel
27•frozenseven•2h ago•3 comments

Agents that run while I sleep

https://www.claudecodecamp.com/p/i-m-building-agents-that-run-while-i-sleep
334•aray07•15h ago•367 comments

RISC-V Is Sloooow

https://marcin.juszkiewicz.com.pl/2026/03/10/risc-v-is-sloooow/
246•todsacerdoti•14h ago•246 comments

SSH Secret Menu

https://twitter.com/rebane2001/status/2031037389347406054
213•piccirello•1d ago•79 comments

Writing my own text editor, and daily-driving it

https://blog.jsbarretto.com/post/text-editor
108•todsacerdoti•8h ago•30 comments

When the chain becomes the product: Seven years inside a token-funded venture

https://markmhendrickson.com/posts/when-the-chain-becomes-the-product/
6•mhendric•3d ago•1 comments

Launch HN: RunAnywhere (YC W26) – Faster AI Inference on Apple Silicon

https://github.com/RunanywhereAI/rcli
215•sanchitmonga22•17h ago•130 comments

Debian decides not to decide on AI-generated contributions

https://lwn.net/SubscriberLink/1061544/125f911834966dd0/
334•jwilk•19h ago•254 comments

Levels of Agentic Engineering

https://www.bassimeledath.com/blog/levels-of-agentic-engineering
192•bombastic311•1d ago•88 comments

Universal vaccine against respiratory infections and allergens

https://med.stanford.edu/news/all-news/2026/02/universal-vaccine.html
258•phony-account•11h ago•84 comments

Mesh over Bluetooth LE, TCP, or Reticulum

https://github.com/torlando-tech/columba
97•khimaros•15h ago•10 comments

Standardizing source maps

https://bloomberg.github.io/js-blog/post/standardizing-source-maps/
34•Timothee•5h ago•4 comments

Surpassing vLLM with a Generated Inference Stack

https://infinity.inc/case-studies/qwen3-optimization
38•lukebechtel•19h ago•14 comments

I'm going to build my own OpenClaw, with blackjack and bun

https://github.com/rcarmo/piclaw
35•rcarmo•2h ago•29 comments

Roblox is minting teen millionaires

https://www.bloomberg.com/news/articles/2026-03-06/roblox-s-teen-millionaires-are-disrupting-the-...
141•petethomas•3d ago•156 comments

Support for Aquantia AQC113 and AQC113C Ethernet Controllers on FreeBSD

https://github.com/Aquantia/aqtion-freebsd/issues/32
8•justinclift•4d ago•6 comments

Pike: To Exit or Not to Exit

https://tomjohnell.com/pike-solving-the-should-we-stop-here-or-gamble-on-the-next-exit-problem/
24•dnw•2d ago•3 comments

FFmpeg-over-IP – Connect to remote FFmpeg servers

https://github.com/steelbrain/ffmpeg-over-ip
190•steelbrain•16h ago•59 comments

Google to Provide Pentagon with AI Agents

https://www.bloomberg.com/news/articles/2026-03-10/google-to-provide-pentagon-with-ai-agents-for-...
12•1vuio0pswjnm7•56m ago•4 comments

Meta acquires Moltbook

https://www.axios.com/2026/03/10/meta-facebook-moltbook-agent-social-network
500•mmayberry•19h ago•337 comments

Launch HN: Didit (YC W26) – Stripe for Identity Verification

71•rosasalberto•19h ago•60 comments