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

Comments

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

Gemini 3

https://blog.google/products/gemini/gemini-3/
573•preek•4h ago•470 comments

Google Antigravity

https://antigravity.google/
292•Fysi•3h ago•377 comments

Pebble, Rebble, and a Path Forward

https://ericmigi.com/blog/pebble-rebble-and-a-path-forward/
127•phoronixrly•1h ago•36 comments

A day at Hetzner online in the Falkenstein data center

https://www.igorslab.de/en/a-day-at-hetzner-online-in-the-falkenstein-data-center-insights-into-s...
102•speckx•3h ago•25 comments

Cloudflare Global Network experiencing issues

https://www.cloudflarestatus.com/?t=1
2140•imdsm•7h ago•1383 comments

Strix Halo's Memory Subsystem: Tackling iGPU Challenges

https://chipsandcheese.com/p/strix-halos-memory-subsystem-tackling
37•PaulHoule•2h ago•14 comments

Solving a Million-Step LLM Task with Zero Errors

https://arxiv.org/abs/2511.09030
55•Anon84•2h ago•20 comments

How Quake.exe got its TCP/IP stack

https://fabiensanglard.net/quake_chunnel/index.html
386•billiob•11h ago•87 comments

Nearly all UK drivers say headlights are too bright

https://www.bbc.com/news/articles/c1j8ewy1p86o
509•YeGoblynQueenne•5h ago•494 comments

Show HN: Guts – convert Golang types to TypeScript

https://github.com/coder/guts
30•emyrk•1h ago•8 comments

Do not put your site behind Cloudflare if you don't need to

https://huijzer.xyz/posts/123/do-not-put-your-site-behind-cloudflare-if-you-dont
367•huijzer•6h ago•274 comments

Short Little Difficult Books

https://countercraft.substack.com/p/short-little-difficult-books
102•crescit_eundo•5h ago•60 comments

Show HN: RowboatX – open-source Claude Code for everyday automations

https://github.com/rowboatlabs/rowboat
10•segmenta•33m ago•0 comments

Show HN: Optimizing LiteLLM with Rust – When Expectations Meet Reality

https://github.com/neul-labs/fast-litellm
23•ticktockten•2h ago•5 comments

Gemini 3 Pro Model Card

https://pixeldrain.com/u/hwgaNKeH
412•Topfi•7h ago•269 comments

Google CEO: If an AI bubble pops, no one is getting out clean

https://arstechnica.com/ai/2025/11/googles-sundar-pichai-warns-of-irrationality-in-trillion-dolla...
40•doctorshady•1h ago•21 comments

The Miracle of Wörgl

https://scf.green/story-of-worgl-and-others/
100•simonebrunozzi•8h ago•57 comments

Mathematics and Computation (2019) [pdf]

https://www.math.ias.edu/files/Book-online-Aug0619.pdf
53•nill0•6h ago•10 comments

Experiment: Making TypeScript Immutable-by-Default

https://evanhahn.com/typescript-immutability-experiment/
59•ingve•5h ago•53 comments

Beauty in/of mathematics: tessellations and their formulas

https://www.tandfonline.com/doi/full/10.1080/00036811.2025.2510472
21•QueensGambit•5d ago•0 comments

When 1+1+1 Equals 1

https://mathenchant.wordpress.com/2024/12/19/when-111-equals-1/
4•surprisetalk•4d ago•0 comments

NPR to get $36M in settlement to operate US public radio system

https://apnews.com/article/trump-npr-lawsuit-2cc4abfa8cf00fe6f89e387e63eb4a2a
32•geox•1h ago•10 comments

A squeaky nail, or the wheel that sticks out

https://prashanth.world/squeaky-nail/
7•mangoman•1w ago•6 comments

Ruby 4.0.0 Preview2 Released

https://www.ruby-lang.org/en/news/2025/11/17/ruby-4-0-0-preview2-released/
166•pansa2•5h ago•60 comments

I've Wanted to Play That 'Killer Shark' Arcade Game Briefly Seen in 'Jaws'

https://www.remindmagazine.com/article/15694/jaws-arcade-video-game-killer-shark-atari-sega-elect...
30•speckx•4d ago•14 comments

How many video games include a marriage proposal? At least one

https://32bits.substack.com/p/under-the-microscope-ncaa-basketball
311•bbayles•5d ago•75 comments

Looking for Hidden Gems in Scientific Literature

https://elicit.com/blog/literature-based-discovery
14•ravenical•6d ago•1 comments

GoSign Desktop RCE flaws affecting users in Italy

https://www.ush.it/2025/11/14/multiple-vulnerabilities-gosign-desktop-remote-code-execution/
45•ascii•6h ago•21 comments

Langfuse (YC W23) Hiring OSS Support Engineers in Berlin and SF

https://jobs.ashbyhq.com/langfuse/5ff18d4d-9066-4c67-8ecc-ffc0e295fee6
1•clemo_ra•12h ago

Azure hit by 15 Tbps DDoS attack using 500k IP addresses

https://www.bleepingcomputer.com/news/microsoft/microsoft-aisuru-botnet-used-500-000-ips-in-15-tb...
461•speckx•1d ago•289 comments