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

Anthropic blocks third-party use of Claude Code subscriptions

https://github.com/anomalyco/opencode/issues/7410
174•sergiotapia•1h ago•100 comments

Why I Left iNaturalist

https://kueda.net/blog/2026/01/06/why-i-left-inat/
122•erutuon•4h ago•47 comments

How to Code Claude Code in 200 Lines of Code

https://www.mihaileric.com/The-Emperor-Has-No-Clothes/
404•nutellalover•9h ago•162 comments

Embassy: Modern embedded framework, using Rust and async

https://github.com/embassy-rs/embassy
148•birdculture•6h ago•60 comments

Sopro TTS: A 169M model with zero-shot voice cloning that runs on the CPU

https://github.com/samuel-vitorino/sopro
180•sammyyyyyyy•8h ago•78 comments

Hacking a Casio F-91W digital watch (2023)

https://medium.com/infosec-watchtower/how-i-hacked-casio-f-91w-digital-watch-892bd519bd15
25•jollyjerry•4d ago•5 comments

Anti-cheat evolution in Windows 11

https://www.andrea-allievi.com/blog/new-year-post-anti-cheat-evolution-in-windows-11/
33•davikr•5d ago•17 comments

Bose has released API docs and opened the API for its EoL SoundTouch speakers

https://arstechnica.com/gadgets/2026/01/bose-open-sources-its-soundtouch-home-theater-smart-speak...
2198•rayrey•14h ago•326 comments

The No Fakes Act Has a "Fingerprinting" Trap That Kills Open Source

https://old.reddit.com/r/LocalLLaMA/comments/1q7qcux/the_no_fakes_act_has_a_fingerprinting_trap_t...
17•guerrilla•30m ago•0 comments

Richard D. James aka Aphex Twin speaks to Tatsuya Takahashi (2017)

https://web.archive.org/web/20180719052026/http://item.warp.net/interview/aphex-twin-speaks-to-ta...
129•lelandfe•8h ago•35 comments

The Unreasonable Effectiveness of the Fourier Transform

https://joshuawise.com/resources/ofdm/
178•voxadam•10h ago•81 comments

The Jeff Dean Facts

https://github.com/LRitzdorf/TheJeffDeanFacts
435•ravenical•16h ago•161 comments

AI coding assistants are getting worse?

https://spectrum.ieee.org/ai-coding-degrades
268•voxadam•14h ago•417 comments

Google AI Studio is now sponsoring Tailwind CSS

https://twitter.com/OfficialLoganK/status/2009339263251566902
558•qwertyforce•10h ago•192 comments

Systematically Improving Espresso: Mathematical Modeling and Experiment (2020)

https://www.cell.com/matter/fulltext/S2590-2385(19)30410-2
19•austinallegro•6d ago•5 comments

On Getting Hacked

https://ahmeto.com/post/on-getting-hacked
4•ahmetomer•3d ago•0 comments

He was called a 'terrorist sympathizer.' Now his AI company is valued at $3B

https://sfstandard.com/2026/01/07/called-terrorist-sympathizer-now-ai-company-valued-3b/
128•newusertoday•11h ago•152 comments

Ushikuvirus: Newly discovered virus may offer clues to the origin of eukaryotes

https://www.tus.ac.jp/en/mediarelations/archive/20251219_9539.html
85•rustoo•1d ago•13 comments

Show HN: macOS menu bar app to track Claude usage in real time

https://github.com/richhickson/claudecodeusage
109•RichHickson•11h ago•38 comments

Dell admits consumers don't care about AI PCs

https://www.pcgamer.com/hardware/dells-ces-2026-chat-was-the-most-pleasingly-un-ai-briefing-ive-h...
475•mossTechnician•1d ago•342 comments

Fixing a Buffer Overflow in Unix v4 Like It's 1973

https://sigma-star.at/blog/2025/12/unix-v4-buffer-overflow/
95•vzaliva•11h ago•31 comments

Pole of Inaccessibility

https://en.wikipedia.org/wiki/Pole_of_inaccessibility
42•benbreen•5d ago•9 comments

Mux (YC W16) is hiring a platform engineer that cares about (internal) DX

https://www.mux.com/jobs
1•mmcclure•8h ago

Show HN: A geofence-based social network app 6 years in development

https://www.localvideoapp.com
49•Adrian-ChatLocl•8h ago•31 comments

Iran Goes Dark as Government Cuts Itself Off from Internet

https://www.kentik.com/analysis/iran-goes-dark-as-government-cuts-itself-off-from-internet/
9•m-hodges•4h ago•1 comments

Digital Red Queen: Adversarial Program Evolution in Core War with LLMs

https://sakana.ai/drq/
110•hardmaru•13h ago•14 comments

Making Magic Leap past Nvidia's secure bootchain and breaking Tesla Autopilots

https://fahrplan.events.ccc.de/congress/2025/fahrplan/event/making-the-magic-leap-past-nvidia-s-s...
50•rguiscard•1w ago•12 comments

I used Lego to design a farm for people who are blind – like me

https://www.bbc.co.uk/news/articles/c4g4zlyqnr0o
112•ColinWright•3d ago•45 comments

Logistics Is Dying; Or – Dude, Where's My Mail?

https://lagomor.ph/2026/01/logistics-is-dying-or-dude-wheres-my-mail/
24•ChilledTonic•3h ago•11 comments

Flint Confirms Biodegradable Paper Batteries Are Now in Production

https://audioxpress.com/news/flint-confirms-biodegradable-paper-batteries-are-now-in-production
37•rmason•7h ago•5 comments