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.

Google releases Gemma 4 open models

https://deepmind.google/models/gemma/gemma-4/
1365•jeffmcjunkin•15h ago•394 comments

Decisions that eroded trust in Azure – by a former Azure Core engineer

https://isolveproblems.substack.com/p/how-microsoft-vaporized-a-trillion
627•axelriet•15h ago•244 comments

Tailscale's new macOS home

https://tailscale.com/blog/macos-notch-escape
424•tosh•12h ago•208 comments

C89cc.sh – standalone C89/ELF64 compiler in pure portable shell

https://gist.github.com/alganet/2b89c4368f8d23d033961d8a3deb5c19
105•gaigalas•1d ago•23 comments

Cursor 3

https://cursor.com/blog/cursor-3
375•adamfeldman•13h ago•304 comments

Artemis II's toilet is a moon mission milestone

https://www.scientificamerican.com/article/artemis-iis-toilet-is-a-moon-mission-milestone/
219•1659447091•1d ago•89 comments

Qwen3.6-Plus: Towards real world agents

https://qwen.ai/blog?id=qwen3.6
498•pretext•16h ago•176 comments

The True Shape of Io's Steeple Mountain

https://www.weareinquisitive.com/news/hidden-in-the-shadow
10•carlosjobim•4d ago•0 comments

Show HN: Home Maker: Declare Your Dev Tools in a Makefile

https://thottingal.in/blog/2026/03/29/home-maker/
32•sthottingal•5d ago•16 comments

Good ideas do not need lots of lies in order to gain public acceptance (2008)

https://blog.danieldavies.com/2004/05/d-squared-digest-one-minute-mba.html
232•sedev•13h ago•91 comments

Vector Meson Dominance

https://johncarlosbaez.wordpress.com/2026/03/29/vector-meson-dominance/
18•chmaynard•4d ago•0 comments

LinkedIn is searching your browser extensions

https://browsergate.eu/
1667•digitalWestie•18h ago•696 comments

Show HN: Made a little Artemis II tracker

https://artemis-ii-tracker.com/
84•codingmoh•7h ago•31 comments

George Goble has died

https://www.legacy.com/us/obituaries/wlfi/name/george-goble-obituary?id=61144779
141•finaard•12h ago•27 comments

The Joy of Numbered Streets

https://humantransit.org/2026/03/the-joy-of-numbered-streets-or-call-it-39th-avenue.html
37•dmit•6d ago•20 comments

Significant progress made on Xbox 360 recompilation

https://readonlymemo.com/rexglue-xbox-360-recompilation-interview/
103•tetrisgm•4d ago•22 comments

A Few Good Magazines From the 70s and 80s

https://www.bi6.us/CO/MG.HTML
54•OhMeadhbh•7h ago•15 comments

OpenAI Acquires TBPN

https://openai.com/index/openai-acquires-tbpn/
198•surprisetalk•13h ago•159 comments

JSON Canvas Spec (2024)

https://jsoncanvas.org/spec/1.0/
101•tobr•3d ago•32 comments

Maze Algorithms (1997)

https://www.astrolog.org/labyrnth/algrithm.htm
41•marukodo•2d ago•5 comments

Inside Nepal's Fake Rescue Racket

https://kathmandupost.com/money/2026/03/27/inside-nepal-s-fake-rescue-racket
278•lode•19h ago•123 comments

ParadeDB (YC S23) Is Hiring Database Internal Engineers (Rust)

https://paradedb.notion.site/
1•philippemnoel•9h ago

Memo: A language that remembers only the last 12 lines of code

https://danieltemkin.com/Esolangs/Memo/
44•notem•8h ago•20 comments

Artemis computer running two instances of MS outlook; they can't figure out why

https://bsky.app/profile/nikigrayson.com/post/3miik2wzosk25
385•mooreds•16h ago•292 comments

Tor Alva: The Tallest 3D-Printed Building in the World

https://cacm.acm.org/blogcacm/tor-alva-the-tallest-3d-printed-building-in-the-world/
28•sohkamyung•7h ago•7 comments

Prefer do notation over Applicative operators when assembling records (2024)

https://haskellforall.com/2024/05/prefer-do-notation-over-applicative
42•wazHFsRy•2d ago•6 comments

Sweden goes back to basics, swapping screens for books in the classroom

https://undark.org/2026/04/01/sweden-schools-books/
810•novaRom•20h ago•398 comments

Post Mortem: axios NPM supply chain compromise

https://github.com/axios/axios/issues/10636
85•Kyro38•7h ago•47 comments

Lemonade by AMD: a fast and open source local LLM server using GPU and NPU

https://lemonade-server.ai
496•AbuAssar•20h ago•107 comments

Magic the Gathering Deck Shuffler

https://mtg.jessitron.honeydemo.io/
55•mooreds•3d ago•15 comments