frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Filing the corners off my MacBooks

https://kentwalters.com/posts/corners/
808•normanvalentine•11h ago•400 comments

Optimal Strategy for Connect 4

https://2swap.github.io/WeakC4/explanation/
27•marvinborner•2d ago•7 comments

Starfling: A one-tap endless orbital slingshot game in a single HTML file

https://playstarfling.com
170•iceberger2001•2d ago•51 comments

1D Chess

https://rowan441.github.io/1dchess/chess.html
814•burnt-resistor•18h ago•142 comments

Artemis II safely splashes down

https://www.cbsnews.com/live-updates/artemis-ii-splashdown-return/
892•areoform•9h ago•278 comments

Installing every* Firefox extension

https://jack.cab/blog/every-firefox-extension
388•RohanAdwankar•12h ago•49 comments

Chimpanzees in Uganda locked in eight-year 'civil war', say researchers

https://www.bbc.com/news/articles/cr71lkzv49po
332•neversaydie•14h ago•192 comments

Volunteers turn a fan's recordings of 10K concerts into an online treasure trove

https://apnews.com/article/aadam-jacobs-collection-concerts-internet-archive-chicago-b1c9c4466a2d...
58•geox•3d ago•3 comments

AI assistance when contributing to the Linux kernel

https://github.com/torvalds/linux/blob/master/Documentation/process/coding-assistants.rst
322•hmokiguess•15h ago•217 comments

WireGuard makes new Windows release following Microsoft signing resolution

https://lists.zx2c4.com/pipermail/wireguard/2026-April/009561.html
477•zx2c4•18h ago•140 comments

Industrial design files for Keychron keyboards and mice

https://github.com/Keychron/Keychron-Keyboards-Hardware-Design
372•stingraycharles•17h ago•114 comments

20 years on AWS and never not my job

https://www.daemonology.net/blog/2026-04-11-20-years-on-AWS-and-never-not-my-job.html
143•cperciva•4h ago•22 comments

Sybilproof reputation mechanisms (2005) [pdf]

https://dl.acm.org/doi/pdf/10.1145/1080192.1080202
4•perfmode•3d ago•0 comments

Bevy game development tutorials and in-depth resources

https://taintedcoders.com/
80•GenericCanadian•2d ago•15 comments

CPU-Z and HWMonitor compromised

https://www.theregister.com/2026/04/10/cpuid_site_hijacked/
332•pashadee•20h ago•92 comments

JSON formatter Chrome plugin now closed and injecting adware

https://github.com/callumlocke/json-formatter
220•jkl5xx•15h ago•110 comments

The Seasons Are Wrong

https://kentwalters.com/posts/seasons/
29•NikxDa•5h ago•36 comments

Helium is hard to replace

https://www.construction-physics.com/p/helium-is-hard-to-replace
317•JumpCrisscross•18h ago•217 comments

A practical guide for setting up Zettelkasten method in Obsidian

https://desktopcommander.app/blog/zettelkasten-obsidian/
52•rkrizanovskis•2d ago•26 comments

Moooooonitoring the Cow.txt Herd

https://moooo.farm/
15•pabs3•3h ago•5 comments

Quien – A better WHOIS lookup tool

https://github.com/retlehs/quien/
44•bretthopper•6h ago•11 comments

Productive Procrastination

https://www.maxvanijsselmuiden.nl/blog/productive-procrastination/
22•maxvij•4h ago•9 comments

The Bra-and-Girdle Maker That Fashioned the Impossible for NASA

https://thereader.mitpress.mit.edu/the-bra-and-girdle-maker-that-fashioned-the-impossible-for-nasa/
88•sohkamyung•1d ago•4 comments

Italo Calvino: A traveller in a world of uncertainty

https://www.historytoday.com/archive/portrait-author-historian/italo-calvino-traveller-world-unce...
73•lermontov•10h ago•14 comments

Watgo – A WebAssembly Toolkit for Go

https://eli.thegreenplace.net/2026/watgo-a-webassembly-toolkit-for-go/
95•ibobev•14h ago•7 comments

Investigating Split Locks on x86-64

https://chipsandcheese.com/p/investigating-split-locks-on-x86
57•ingve•3d ago•19 comments

What is RISC-V and why it matters to Canonical

https://ubuntu.com/blog/risc-v-101-what-is-it-and-what-does-it-mean-for-canonical
129•fork-bomber•2d ago•89 comments

Launch HN: Twill.ai (YC S25) – Delegate to cloud agents, get back PRs

https://twill.ai
67•danoandco•17h ago•66 comments

A compelling title that is cryptic enough to get you to take action on it

https://ericwbailey.website/published/a-compelling-title-that-is-cryptic-enough-to-get-you-to-tak...
233•mooreds•17h ago•125 comments

Intel 486 CPU announced April 10, 1989

https://dfarq.homeip.net/intel-486-cpu-announced-april-10-1989/
167•jnord•21h ago•155 comments
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.