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

Comments

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

Ladybird: Closing this as we are no longer pursuing Swift adoption

https://github.com/LadybirdBrowser/ladybird/issues/933
153•thewavelength•2h ago•89 comments

Sizing chaos

https://pudding.cool/2026/02/womens-sizing/
255•zdw•4h ago•133 comments

27-year-old Apple iBooks can connect to Wi-Fi and download official updates

https://old.reddit.com/r/MacOS/comments/1r8900z/macos_which_officially_supports_27_year_old/
129•surprisetalk•4h ago•69 comments

Cosmologically Unique IDs

https://jasonfantl.com/posts/Universal-Unique-IDs/
274•jfantl•6h ago•81 comments

Zero-day CSS: CVE-2026-2441 exists in the wild

https://chromereleases.googleblog.com/2026/02/stable-channel-update-for-desktop_13.html
246•idoxer•9h ago•134 comments

Tailscale Peer Relays is now generally available

https://tailscale.com/blog/peer-relays-ga
316•sz4kerto•8h ago•170 comments

DNS-Persist-01: A New Model for DNS-Based Challenge Validation

https://letsencrypt.org/2026/02/18/dns-persist-01.html
185•todsacerdoti•7h ago•91 comments

R3forth: A concatenative language derived from ColorForth

https://github.com/phreda4/r3/blob/main/doc/r3forth_tutorial.md
51•tosh•6h ago•8 comments

Show HN: Rebrain.gg – Doom learn, don't doom scroll

40•FailMore•13h ago•21 comments

Making a font with ligatures to display thirteenth-century monk numerals

https://digitalseams.com/blog/making-a-font-with-9999-ligatures-to-display-thirteenth-century-mon...
36•a7b3fa•3d ago•6 comments

The Perils of ISBN

https://rygoldstein.com/posts/perils-of-isbn
61•evakhoury•7h ago•31 comments

All Look Same?

https://alllooksame.com/
30•mirawelner•2h ago•14 comments

Portugal: The First Global Empire (2015)

https://www.historytoday.com/archive/first-global-empire
53•Thevet•17h ago•42 comments

Learning Lean: Part 1

https://rkirov.github.io/posts/lean1/
77•vinhnx•3d ago•7 comments

Metriport (YC S22) is hiring a security engineer to harden healthcare infra

https://www.ycombinator.com/companies/metriport/jobs/XC2AF8s-senior-security-engineer
1•dgoncharov•4h ago

Roads to Rome (2015)

https://benedikt-gross.de/projects/roads-to-rome/
6•robin_reala•3d ago•0 comments

What is happening to writing? Cognitive debt, Claude Code, the space around AI

https://resobscura.substack.com/p/what-is-happening-to-writing
93•benbreen•10h ago•68 comments

Pocketbase lost its funding from FLOSS fund

https://github.com/pocketbase/pocketbase/discussions/7287
115•Onavo•9h ago•79 comments

A solver for Semantle

https://victoriaritvo.com/blog/semantle-solver/
32•evakhoury•6h ago•5 comments

What Every Experimenter Must Know About Randomization

https://spawn-queue.acm.org/doi/pdf/10.1145/3778029
38•underscoreF•6h ago•16 comments

Cistercian Numbers

https://www.omniglot.com/language/numbers/cistercian-numbers.htm
64•debo_•8h ago•12 comments

Microsoft offers guide to pirating Harry Potter series for LLM training

https://devblogs.microsoft.com/azure-sql/langchain-with-sqlvectorstore-example/
151•anonymous908213•2h ago•86 comments

Discrete Structures [pdf]

https://kyleormsby.github.io/files/113spring26/113full_text.pdf
43•mathgenius•6h ago•2 comments

Show HN: VectorNest responsive web-based SVG editor

https://ekrsulov.github.io/vectornest/
67•ekrsulov•9h ago•23 comments

When interfaces become disposable

https://chrisloy.dev/post/2026/02/14/when-interfaces-become-disposable
15•chrisloy•3d ago•5 comments

If you’re an LLM, please read this

https://annas-archive.li/blog/llms-txt.html
758•soheilpro•18h ago•357 comments

The true history of the Minotaur: what archaeology reveals

https://www.nationalgeographic.fr/histoire/la-veritable-histoire-du-minotaure-ce-que-revele-arche...
34•joebig•3d ago•12 comments

Assigning Open Problems in Class

https://blog.computationalcomplexity.org/2026/02/assigning-open-problems-in-class.html
11•baruchel•2d ago•5 comments

Garment Notation Language: Formal descriptive language for clothing construction

https://github.com/khalildh/garment-notation
131•prathyvsh•9h ago•36 comments

Native FreeBSD Kerberos/LDAP with FreeIPA/IDM

https://vermaden.wordpress.com/2026/02/18/native-freebsd-kerberos-ldap-with-freeipa-idm/
110•vermaden•15h ago•54 comments