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

Comments

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

.de TLD offline due to DNSSEC?

https://dnssec-analyzer.verisignlabs.com/nic.de
522•warpspin•5h ago•242 comments

Accelerating Gemma 4: faster inference with multi-token prediction drafters

https://blog.google/innovation-and-ai/technology/developers-tools/multi-token-prediction-gemma-4/
443•amrrs•9h ago•198 comments

Computer Use is 45x more expensive than structured APIs

https://reflex.dev/blog/computer-use-is-45x-more-expensive-than-structured-apis/
309•palashawas•8h ago•174 comments

Three Inverse Laws of AI

https://susam.net/inverse-laws-of-robotics.html
351•blenderob•10h ago•244 comments

EEVblog: The 555 Timer is 55 years old [video]

https://www.youtube.com/watch?v=6JhK8iCQuqI
220•brudgers•9h ago•54 comments

Write some software, give it away for free

https://nonogra.ph/write-some-software-give-it-away-for-free-05-05-2026
127•nohell•4h ago•95 comments

Why most product tours get skipped

https://productonboarding.com/articles/why-product-tours-get-skipped
65•pancomplex•4h ago•54 comments

NPR finds "no sign" of Polymarket at its Panama HQ address

https://www.npr.org/2026/05/05/nx-s1-5807918/polymarket-panama-prediction-market
198•ilamont•3h ago•88 comments

Show HN: Explore color palettes inspired by 3000 master painter artworks

https://paletteinspiration.com/
102•ouli•7h ago•39 comments

GLM-5V-Turbo: Toward a Native Foundation Model for Multimodal Agents

https://arxiv.org/abs/2604.26752
112•gmays•7h ago•23 comments

Zuckerberg 'personally authorized' Meta's copyright infringement, publishers say

https://apnews.com/article/meta-mark-zuckerberg-ai-publishers-lawsuit-llama-5609846d4d840014974a8...
122•jethronethro•3h ago•34 comments

Past Ferrari Models, 1947–2023

https://www.ferrari.com/en-US/auto/past-model
18•NaOH•2d ago•3 comments

Agents for financial services and insurance

https://www.anthropic.com/news/finance-agents
196•louiereederson•10h ago•149 comments

Urban Birds Are Rising Earlier Because of Traffic Noise (2013)

https://www.audubon.org/news/urban-birds-are-rising-earlier-because-traffic-noise
28•thunderbong•2d ago•11 comments

Show HN: Airbyte Agents – context for agents across multiple data sources

92•mtricot•10h ago•23 comments

I'm scared about biological computing

https://kuber.studio/blog/Reflections/I%27m-Scared-About-Biological-Computing
141•kuberwastaken•9h ago•122 comments

I completed 100 Days of Java over 5 years and mapped the journey as a graph

https://mohibulsblog.netlify.app/java/100daysofjava/graph/
26•celurian92•2d ago•5 comments

Google Chrome silently installs a 4 GB AI model on your device without consent

https://www.thatprivacyguy.com/blog/chrome-silent-nano-install/
1242•john-doe•17h ago•840 comments

Today I've made the difficult decision to reduce the size of Coinbase by ~14%

https://twitter.com/brian_armstrong/status/2051616759145185723
256•adrianmsmith•13h ago•362 comments

California farmers to destroy 420k peach trees following Del Monte bankruptcy

https://www.sfgate.com/centralcoast/article/usda-aid-california-farmers-22240694.php
264•littlexsparkee•7h ago•320 comments

When everyone has AI and the company still learns nothing

https://www.robert-glaser.de/when-everyone-has-ai-and-the-company-still-learns-nothing/
309•youngbrioche•15h ago•218 comments

Should I run plain Docker Compose in production in 2026?

https://distr.sh/blog/running-docker-in-production/
356•pmig•5d ago•255 comments

Proliferate (YC S25) Is Hiring- 200k for junior engineers

https://www.ycombinator.com/companies/proliferate/jobs/L3copvK-founding-engineer
1•pablo24602•8h ago

IBM didn't want Microsoft to use the Tab key to move between dialog fields

https://devblogs.microsoft.com/oldnewthing/20260505-00/?p=112298
298•SeenNotHeard•8h ago•173 comments

Researchers print structural colour with an inkjet printer

https://physicsworld.com/a/researchers-print-structural-colour-with-an-inkjet-printer/
46•zeristor•2d ago•8 comments

iOS 27 is adding a 'Create a Pass' button to Apple Wallet

https://walletwallet.alen.ro/blog/ios-27-wallet-create-pass/
380•alentodorov•12h ago•288 comments

Zuckerberg 'Personally Authorized and Encouraged' Meta's Copyright Infringement

https://variety.com/2026/digital/news/meta-ai-mark-zuckerberg-copyright-infringement-lawsuit-publ...
248•spankibalt•7h ago•183 comments

Underwater robot tracks sperm whale conversations in real time

https://www.reuters.com/business/environment/underwater-robot-tracks-sperm-whale-conversations-re...
53•thedebuglife•2d ago•13 comments

The extended predicative Mahlo universe in Martin-Löf type theory

https://academic.oup.com/logcom/article/34/6/1032/7158523
24•danny00•2d ago•0 comments

Xbox CEO ends Copilot AI development and overhauls leadership

https://www.dexerto.com/gaming/xbox-ceo-ends-copilot-ai-development-overhauls-leadership-3361353/
47•gmays•2h ago•8 comments