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

Gaussian Splatting – A$AP Rocky "Helicopter" music video

https://radiancefields.com/a-ap-rocky-releases-helicopter-music-video-featuring-gaussian-splatting
527•ChrisArchitect•11h ago•171 comments

Provide agents with automated feedback

https://banay.me/dont-waste-your-backpressure/
65•ghuntley•1d ago•19 comments

Flux 2 Klein pure C inference

https://github.com/antirez/flux2.c
270•antirez•11h ago•108 comments

A Social Filesystem

https://overreacted.io/a-social-filesystem/
333•icy•20h ago•147 comments

The Code-Only Agent

https://rijnard.com/blog/the-code-only-agent
27•emersonmacro•2h ago•10 comments

Dead Internet Theory

https://kudmitry.com/articles/dead-internet-theory/
156•skwee357•8h ago•195 comments

Fil-Qt: A Qt Base build with Fil-C experience

https://git.qt.io/cradam/fil-qt
53•pjmlp•2d ago•29 comments

Gas Town Decoded

https://www.alilleybrinker.com/mini/gas-town-decoded/
93•alilleybrinker•4d ago•79 comments

AVX-512: First Impressions on Performance and Programmability

https://shihab-shahriar.github.io//blog/2026/AVX-512-First-Impressions-on-Performance-and-Program...
25•shihab•5d ago•8 comments

At least 21 killed in Spain after crash involving high-speed trains

https://www.bbc.com/news/articles/cedw6ylpynyo
45•akyuu•5h ago•30 comments

Show HN: I quit coding years ago. AI brought me back

https://calquio.com/finance/compound-interest
33•ivcatcher•4h ago•21 comments

Using proxies to hide secrets from Claude Code

https://www.joinformal.com/blog/using-proxies-to-hide-secrets-from-claude-code/
49•drewgregory•5d ago•22 comments

Poking holes into bytecode with peephole optimisations

https://xnacly.me/posts/2026/purple-garden-first-optimisations/
17•xnacly•4d ago•0 comments

Show HN: Dock – Slack minus the bloat, tax, and 90-day memory loss

https://getdock.io/
83•yadavrh•8h ago•63 comments

The space and motion of communicating agents (2008) [pdf]

https://www.cl.cam.ac.uk/archive/rm135/Bigraphs-draft.pdf
11•dhorthy•3d ago•1 comments

Astrophotography visibility plotting and planning tool

https://airmass.org/
8•NKosmatos•3d ago•1 comments

Police Invested Millions in Shadowy Phone-Tracking Software Won't Say How Used

https://www.texasobserver.org/texas-police-invest-tangles-sheriff-surveillance/
273•nobody9999•8h ago•80 comments

Command-line Tools can be 235x Faster than your Hadoop Cluster (2014)

https://adamdrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html
332•tosh•20h ago•221 comments

Simulating the Ladybug Clock Puzzle

https://austinhenley.com/blog/ladybugclock.html
3•azhenley•1d ago•0 comments

Sins of the Children

https://asteriskmag.com/issues/07/sins-of-the-children
130•maxall4•12h ago•64 comments

The Cathedral, the Megachurch, and the Bazaar

https://opensourcesecurity.io/2026/01-cathedral-megachurch-bazaar/
144•todsacerdoti•5d ago•117 comments

Show HN: Lume 0.2 – Build and Run macOS VMs with unattended setup

https://cua.ai/docs/lume/guide/getting-started/introduction
104•frabonacci•11h ago•29 comments

All your OpenCodes belong to us

https://johncodes.com/archive/2026/01-18-all-your-opencodes/
19•jpmcb•2h ago•3 comments

Predicting OpenAI's ad strategy

https://ossa-ma.github.io/blog/openads
512•calcifer•14h ago•448 comments

Wine 11.0

https://gitlab.winehq.org/wine/wine/-/releases/wine-11.0
289•zdw•5d ago•60 comments

A free and open-source rootkit for Linux

https://lwn.net/SubscriberLink/1053099/19c2e8180aeb0438/
182•jwilk•19h ago•36 comments

Show HN: Beats, a web-based drum machine

https://beats.lasagna.pizza
52•kinduff•8h ago•12 comments

CD Projekt issue DMCA takedown notice against popular Cyberpunk VR mod

https://www.patreon.com/posts/another-one-dust-148437771
27•wjdp•2h ago•7 comments

ASCII characters are not pixels: a deep dive into ASCII rendering

https://alexharri.com/blog/ascii-rendering
1210•alexharri•1d ago•132 comments

Ultrathink is deprecated & How to enable 2x thinking tokens in Claude Code

https://decodeclaude.com/ultrathink-deprecated/
14•moona3k•6h ago•1 comments