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.

Pebble Watch software is now 100% open source

https://ericmigi.com/blog/pebble-watch-software-is-now-100percent-open-source
511•Larrikin•4h ago•95 comments

Claude Advanced Tool Use

https://www.anthropic.com/engineering/advanced-tool-use
230•lebovic•3h ago•85 comments

Claude Opus 4.5

https://www.anthropic.com/news/claude-opus-4-5
637•adocomplete•4h ago•281 comments

Shai-Hulud Returns: Over 300 NPM Packages Infected

https://helixguard.ai/blog/malicious-sha1hulud-2025-11-24
780•mrdosija•12h ago•660 comments

Three Years from GPT-3 to Gemini 3

https://www.oneusefulthing.org/p/three-years-from-gpt-3-to-gemini
124•JumpCrisscross•1d ago•73 comments

Cool-retro-term: terminal emulator which mimics look and feel of the old CRTs

https://github.com/Swordfish90/cool-retro-term
128•michalpleban•5h ago•56 comments

The Bitter Lesson of LLM Extensions

https://www.sawyerhood.com/blog/llm-extension
64•sawyerjhood•4h ago•24 comments

Unpowered SSDs slowly lose data

https://www.xda-developers.com/your-unpowered-ssd-is-slowly-losing-your-data/
41•amichail•3h ago•16 comments

Neopets.com Changed My Life (2019)

https://annastreetman.com/2019/05/19/how-neopets-com-changed-my-life/
19•bariumbitmap•5d ago•7 comments

Show HN: I built an interactive HN Simulator

https://news.ysimulator.run/news
97•johnsillings•5h ago•43 comments

Moving from OpenBSD to FreeBSD for firewalls

https://utcc.utoronto.ca/~cks/space/blog/sysadmin/OpenBSDToFreeBSDMove
118•zdw•5d ago•54 comments

PS5 now costs less than 64GB of DDR5 memory. RAM jumps to $600 due to shortage

https://www.tomshardware.com/pc-components/ddr5/64gb-of-ddr5-memory-now-costs-more-than-an-entire...
184•speckx•3h ago•124 comments

You can see a working Quantum Computer in IBM's London office

https://www.ianvisits.co.uk/articles/you-can-see-a-working-quantum-computer-in-ibms-london-office...
21•thinkingemote•2d ago•3 comments

TSMC Arizona outage saw fab halt, Apple wafers scrapped

https://www.culpium.com/p/tsmc-arizona-outage-saw-fab-halt
129•speckx•4h ago•55 comments

Bytes before FLOPS: your algorithm is (mostly) fine, your data isn't

https://www.bitsdraumar.is/bytes-before-flops/
26•bofersen•1d ago•6 comments

Show HN: OCR Arena – A playground for OCR models

https://www.ocrarena.ai/battle
24•kbyatnal•3d ago•2 comments

Chrome Jpegxl Issue Reopened

https://issues.chromium.org/issues/40168998
193•markdog12•10h ago•74 comments

Corvus Robotics (YC S18): Hiring Head of Mfg/Ops, Next Door to YC Mountain View

1•robot_jackie•5h ago

What OpenAI did when ChatGPT users lost touch with reality

https://www.nytimes.com/2025/11/23/technology/openai-chatgpt-users-risks.html
51•nonprofiteer•17h ago•50 comments

Inside Rust's std and parking_lot mutexes – who wins?

https://blog.cuongle.dev/p/inside-rusts-std-and-parking-lot-mutexes-who-win
115•signa11•4d ago•45 comments

Building the largest known Kubernetes cluster

https://cloud.google.com/blog/products/containers-kubernetes/how-we-built-a-130000-node-gke-cluster/
86•TangerineDream•3d ago•61 comments

Implications of AI to schools

https://twitter.com/karpathy/status/1993010584175141038
123•bilsbie•5h ago•118 comments

Fifty Shades of OOP

https://lesleylai.info/en/fifty_shades_of_oop/
25•todsacerdoti•13h ago•3 comments

Mind-reading devices can now predict preconscious thoughts

https://www.nature.com/articles/d41586-025-03714-0
95•srameshc•4h ago•70 comments

Launch HN: Karumi (YC F25) – Personalized, agentic product demos

http://karumi.ai/
18•tonilopezmr•4h ago•8 comments

GrapheneOS migrates server infrastructure from France

https://www.privacyguides.org/news/2025/11/22/grapheneos-migrates-server-infrastructure-from-fran...
157•01-_-•4h ago•59 comments

NSA and IETF, part 3: Dodging the issues at hand

https://blog.cr.yp.to/20251123-dodging.html
283•upofadown•10h ago•152 comments

The history of Indian science fiction

https://altermag.com/articles/the-secret-history-of-indian-science-fiction
58•adityaathalye•2d ago•5 comments

DoGE "cut muscle, not fat"; 26K experts rehired after brutal cuts

https://arstechnica.com/tech-policy/2025/11/doge-doesnt-exist-anymore-but-expert-says-its-still-n...
68•jnord•47m ago•9 comments

We stopped roadmap work for a week and fixed bugs

https://lalitm.com/fixits-are-good-for-the-soul/
242•lalitmaganti•1d ago•306 comments