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
368•ChrisArchitect•6h ago•124 comments

Flux 2 Klein pure C inference

https://github.com/antirez/flux2.c
188•antirez•5h ago•82 comments

A Social Filesystem

https://overreacted.io/a-social-filesystem/
221•icy•15h ago•105 comments

Wine 11.0

https://gitlab.winehq.org/wine/wine/-/releases/wine-11.0
101•zdw•4d ago•17 comments

Simple GIS on Potato

https://github.com/blue-monads/potato-apps/tree/master/cimple-gis
9•born-jre•1h 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/
144•nobody9999•2h ago•27 comments

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

https://getdock.io/
24•yadavrh•3h ago•20 comments

Breaking the Zimmermann Telegram (2018)

https://medium.com/lapsed-historian/breaking-the-zimmermann-telegram-b34ed1d73614
49•tony-allan•4h ago•3 comments

jQuery 4

https://blog.jquery.com/2026/01/17/jquery-4-0-0/
692•OuterVale•19h ago•226 comments

The Cathedral, the Megachurch, and the Bazaar

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

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

https://cua.ai/docs/lume/guide/getting-started/introduction
76•frabonacci•5h ago•18 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
281•tosh•14h ago•195 comments

Stirling Cycle Machine Analysis

https://ohioopen.library.ohio.edu/opentextbooks/9/
13•akshatjiwan•3h ago•5 comments

Predicting OpenAI's ad strategy

https://ossa-ma.github.io/blog/openads
457•calcifer•9h ago•390 comments

Show HN: Xenia – A monospaced font built with a custom Python engine

https://github.com/Loretta1982/xenia
49•xeniafont•13h ago•15 comments

Show HN: Beats, a web-based drum machine

https://beats.lasagna.pizza
22•kinduff•2h ago•7 comments

A free and open-source rootkit for Linux

https://lwn.net/SubscriberLink/1053099/19c2e8180aeb0438/
151•jwilk•14h ago•33 comments

Prediction markets are ushering in a world in which news becomes about gambling

https://www.msn.com/en-us/money/markets/america-is-slow-walking-into-a-polymarket-disaster/ar-AA1...
125•krustyburger•5h ago•119 comments

Sins of the Children (Adrian Tchaikovsky)

https://asteriskmag.com/issues/07/sins-of-the-children
93•maxall4•6h ago•46 comments

Overlapping Markup

https://en.wikipedia.org/wiki/Overlapping_markup
49•ripe•13h ago•10 comments

Cardputer uLisp Machine (2024)

http://www.ulisp.com/show?52G4
18•tosh•3d ago•2 comments

Starting from scratch: Training a 30M Topological Transformer

https://www.tuned.org.uk/posts/013_the_topological_transformer_training_tauformer
119•tuned•12h ago•31 comments

More sustainable epoxy thanks to phosphorus

https://www.empa.ch/web/s604/flamm-hemmendes-epoxidharz-nachhaltiger-machen
69•JeanKage•4d ago•28 comments

60% of Legal Searches Now End Without a Click

https://talk24.ai/blog/ai-killing-legal-search
27•atreeleaf•5h ago•24 comments

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

https://alexharri.com/blog/ascii-rendering
1163•alexharri•1d ago•127 comments

ThinkNext Design

https://thinknextdesign.com/home.html
223•__patchbit__•17h ago•109 comments

Software engineers can no longer neglect their soft skills

https://www.qu8n.com/posts/most-important-software-engineering-skill-2026
142•quanwinn•10h ago•183 comments

Keystone (YC S25) Is Hiring

1•pablo24602•11h ago

Show HN: HTTP:COLON – A quick HTTP header/directive inspector and reference

https://httpcolon.dev/
19•ultimoo•5h ago•3 comments

Show HN: Figma-use – CLI to control Figma for AI agents

https://github.com/dannote/figma-use
92•dannote•17h ago•35 comments