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

Show HN: Gemini Pro 3 hallucinates the HN front page 10 years from now

https://dosaygo-studio.github.io/hn-front-page-2035/news
1843•keepamovin•10h ago•637 comments

PeerTube is recognized as a digital public good by Digital Public Goods Alliance

https://www.digitalpublicgoods.net/r/peertube
399•fsflover•8h ago•65 comments

Django: what’s new in 6.0

https://adamj.eu/tech/2025/12/03/django-whats-new-6.0/
150•rbanffy•5h ago•36 comments

Mistral releases Devstral2 and Mistral Vibe CLI

https://mistral.ai/news/devstral-2-vibe-cli
486•pember•10h ago•248 comments

If you're going to vibe code, why not do it in C?

https://stephenramsay.net/posts/vibe-coding.html
314•sramsay•8h ago•357 comments

10 Years of Let's Encrypt

https://letsencrypt.org/2025/12/09/10-years
454•SGran•6h ago•188 comments

Handsdown one of the coolest 3D websites

https://bruno-simon.com/
390•razzmataks•9h ago•102 comments

Pebble Index 01 – External memory for your brain

https://repebble.com/blog/meet-pebble-index-01-external-memory-for-your-brain
388•freshrap6•10h ago•391 comments

Italy's longest-serving barista reflects on six decades behind the counter

https://www.reuters.com/lifestyle/culture-current/anna-possi-six-decades-behind-counter-italys-ba...
63•NaOH•5d ago•15 comments

Qt, Linux and everything: Debugging Qt WebAssembly

http://qtandeverything.blogspot.com/2025/12/debugging-qt-webassembly-dwarf.html
42•speckx•4h ago•11 comments

Donating the Model Context Protocol and establishing the Agentic AI Foundation

https://www.anthropic.com/news/donating-the-model-context-protocol-and-establishing-of-the-agenti...
147•meetpateltech•8h ago•65 comments

Agentic AI Foundation

https://block.xyz/inside/block-anthropic-and-openai-launch-the-agentic-ai-foundation
62•thinkingkong•5h ago•12 comments

The stack circuitry of the Intel 8087 floating point chip, reverse-engineered

https://www.righto.com/2025/12/8087-stack-circuitry.html
79•elpocko•7h ago•31 comments

So you want to speak at software conferences?

https://dylanbeattie.net/2025/12/08/so-you-want-to-speak-at-software-conferences.html
121•speckx•6h ago•44 comments

LLM from scratch, part 28 – training a base model from scratch on an RTX 3090

https://www.gilesthomas.com/2025/12/llm-from-scratch-28-training-a-base-model-from-scratch
474•gpjt•1w ago•101 comments

Operando interlayer expansion of curved graphene for dense supercapacitors

https://www.nature.com/articles/s41467-025-63485-0
4•westurner•5d ago•0 comments

ULID: Universally Unique Lexicographically Sortable Identifier

https://packagemain.tech/p/ulid-identifier-golang-postgres
50•der_gopher•1w ago•37 comments

Kaiju – General purpose 3D/2D game engine in Go and Vulkan with built in editor

https://github.com/KaijuEngine/kaiju
149•discomrobertul8•10h ago•69 comments

Linux CVEs, more than you ever wanted to know

http://www.kroah.com/log/blog/2025/12/08/linux-cves-more-than-you-ever-wanted-to-know/
22•voxadam•2h ago•17 comments

OpenEvolve: Teaching LLMs to Discover Algorithms Through Evolution

https://algorithmicsuperintelligence.ai/blog/openevolve-overview/index.html
12•codelion•2h ago•5 comments

A supersonic engine core makes the perfect power turbine

https://boomsupersonic.com/flyby/ai-needs-more-power-than-the-grid-can-deliver-supersonic-tech-ca...
60•simonebrunozzi•9h ago•100 comments

Clearspace (YC W23) Is Hiring a Founding Designer

https://www.ycombinator.com/companies/clearspace/jobs/yamWTLr-founding-designer-at-clearspace
1•roycebranning•8h ago

My favourite small hash table

https://www.corsix.org/content/my-favourite-small-hash-table
124•speckx•10h ago•29 comments

Apple's slow AI pace becomes a strength as market grows weary of spending

https://finance.yahoo.com/news/apple-slow-ai-pace-becomes-104658095.html
236•bgwalter•10h ago•288 comments

30 Year Anniversary of WarCraft II: Tides of Darkness

https://www.jorsys.org/archive/december_2025.html#newsitem_2025-12-09T07:42:19Z
184•sjoblomj•16h ago•120 comments

The Mysterious Realm of JavaScriptCore (2021)

https://www.cyberark.com/resources/threat-research-blog/the-mysterious-realm-of-javascriptcore
27•program•5d ago•5 comments

The Joy of Playing Grandia, on Sega Saturn

https://www.segasaturnshiro.com/2025/11/27/the-joy-of-playing-grandia-on-sega-saturn/
178•tosh•15h ago•115 comments

Launch HN: Mentat (YC F24) – Controlling LLMs with Runtime Intervention

38•cgorlla•9h ago•31 comments

Transformers know more than they can tell: Learning the Collatz sequence

https://www.arxiv.org/pdf/2511.10811
108•Xcelerate•6d ago•42 comments

Rubio stages font coup: Times New Roman ousts Calibri

https://www.reuters.com/world/us/rubio-stages-font-coup-times-new-roman-ousts-calibri-2025-12-09/
32•italophil•1h ago•16 comments