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•1y ago

Comments

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

Mullvad exit IPs are surprisingly identifying

https://tmctmt.com/posts/mullvad-exit-ips-as-a-fingerprinting-vector/
117•RGBCube•1h ago•34 comments

Removing the modem and GPS from my 2024 RAV4 hybrid

https://arkadiyt.com/2026/05/13/removing-the-modem-and-gps-from-my-rav4/
688•arkadiyt•11h ago•400 comments

A few words on DS4

https://antirez.com/news/165
210•caust1c•5h ago•66 comments

First public macOS kernel memory corruption exploit on Apple M5

https://blog.calif.io/p/first-public-kernel-memory-corruption
299•quadrige•9h ago•54 comments

RTX 5090 and M4 MacBook Air: Can It Game?

https://scottjg.com/posts/2026-05-05-egpu-mac-gaming/
517•allenleee•12h ago•139 comments

Gyroflow: Video stabilization using gyroscope data

https://github.com/gyroflow/gyroflow
19•nateb2022•2d ago•1 comments

Codex is now in the ChatGPT mobile app

https://openai.com/index/work-with-codex-from-anywhere/
239•mikeevans•8h ago•116 comments

New Nginx Exploit

https://github.com/DepthFirstDisclosures/Nginx-Rift
319•hetsaraiya•10h ago•68 comments

Access to frontier AI will soon be limited by economic and security constraints

https://writing.antonleicht.me/p/cut-off
16•thoughtpeddler•3h ago•0 comments

Tesla Wall Connector bootloader bypasses the firmware downgrade ratchet

https://www.synacktiv.com/en/publications/exploiting-the-tesla-wall-connector-from-its-charge-por...
75•p_stuart82•7h ago•29 comments

RISC-V Router

https://router.start9.com/
93•janandonly•8h ago•51 comments

More than sixty percent of the United States is experiencing drought conditions

https://news.vt.edu/articles/2026/05/drought-united-states-la-nina-expert.html
134•littlexsparkee•5h ago•58 comments

OVMS: Open source electric vehicle remote monitoring, diagnosis and control

https://www.openvehicles.com/home
50•BHSPitMonkey•6h ago•5 comments

Porting 3D Movie Maker to Linux

https://benstoneonline.com/posts/porting-3d-movie-maker-to-linux/
93•speckx•3d ago•14 comments

New arXiv policy: 1-year ban for hallucinated references

https://twitter.com/tdietterich/status/2055000956144935055
370•gjuggler•7h ago•124 comments

HDD Firmware Hacking

https://icode4.coffee/?p=1465
148•jsploit•11h ago•17 comments

UFerris a Versatile Learner Board for Rust Embedded Beginners

https://www.theembeddedrustacean.com/uferris
13•stmw•3h ago•3 comments

Rewrite Bun in Rust has been merged

https://github.com/oven-sh/bun/pull/30412
535•Chaoses•19h ago•624 comments

Infracost (YC W21) Is Hiring Sr Dev Advocate to make agents cloud cost-aware

https://www.ycombinator.com/companies/infracost/jobs/NzwUQ7c-senior-developer-advocate
1•akh•7h ago

What's in a GGUF, besides the weights – and what's still missing?

https://nobodywho.ooo/posts/whats-in-a-gguf/
113•bashbjorn•10h ago•42 comments

Ontario auditors find doctors' AI note takers routinely blow basic facts

https://www.theregister.com/ai-ml/2026/05/14/ontario-auditors-find-doctors-ai-note-takers-routine...
158•sohkamyung•5h ago•75 comments

Show HN: GridTravel- A community based travel app for users to share routes

https://www.gridtravel.app
30•knuaym9•6h ago•14 comments

Computer Hobby Movement in Canada

https://museum.eecs.yorku.ca/exhibits/show/hobby_canada/hobby_canada
192•rbanffy•15h ago•74 comments

LLM Policy for Rust Compiler

https://github.com/rust-lang/rust-forge/pull/1040
24•liyanage•4h ago•9 comments

Velonus – Open-source AppSec scanner that deduplicates SAST noise

https://github.com/AliAmmar15/Velonus
9•AliAmmar15•3h ago•1 comments

The Power of a Free Popsicle (2018)

https://www.gsb.stanford.edu/insights/power-free-popsicle
80•NaOH•9h ago•35 comments

Show HN: Race to the Bottom

https://race-to-the-bottom.onrender.com
41•maxwellito•13h ago•28 comments

Find vendors used by any company

https://sub-processors.com/subprocessor/elasticsearch
5•chatmasta•2h ago•0 comments

A message from President Kornbluth about funding and the talent pipeline

https://president.mit.edu/writing-speeches/video-transcript-message-president-kornbluth-about-fun...
588•dmayo•13h ago•651 comments

Fossils show millipede and centipede ancestors evolved legs underwater

https://phys.org/news/2026-05-ancient-sea-fossils-millipede-centipede.html
80•gmays•3d ago•2 comments