frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Comparing floating-point numbers (2012)

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
15•sph•2d ago

Comments

LegionMammal978•8h 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•7h 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.

BuyMeACoffee silently dropped support for many countries, and nobody cares

https://zverok.space/blog/2024-08-08-bmac-snafu.html
129•beeburrt•1h ago•77 comments

Baby is healed with first personalized gene-editing treatment

https://www.nytimes.com/2025/05/15/health/gene-editing-personalized-rare-disorders.html
799•jbredeche•13h ago•326 comments

Ollama's new engine for multimodal models

https://ollama.com/blog/multimodal-models
162•LorenDB•6h ago•25 comments

A leap year check in three instructions

https://hueffner.de/falk/blog/a-leap-year-check-in-three-instructions.html
295•gnabgib•9h ago•99 comments

The Awful German Language (1880)

https://faculty.georgetown.edu/jod/texts/twain.german.html
52•nalinidash•3h ago•110 comments

Teal – A statically-typed dialect of Lua

https://teal-language.org/
115•generichuman•7h ago•54 comments

Cracked - method chaining/CSS-style selector web audio library

https://github.com/billorcutt/i_dropped_my_phone_the_screen_cracked
47•stephenhandley•5h ago•14 comments

Wasmer (YC S19) Is Hiring a Rust Compiler Engineer

https://www.workatastartup.com/jobs/15822
1•syrusakbary•56m ago

The unreasonable effectiveness of an LLM agent loop with tool use

https://sketch.dev/blog/agent-loop
329•crawshaw•12h ago•214 comments

Initialization in C++ is bonkers (2017)

https://blog.tartanllama.xyz/initialization-is-bonkers/
143•todsacerdoti•10h ago•118 comments

Náhuatl and Mayan Language Renaissance Occurring in Mexico

https://yucatanmagazine.com/mayan-language-renaissance/
34•bryanrasmussen•2d ago•1 comments

Comma 3X: Initial Impressions

https://beesbuzz.biz/blog/14719-Comma-3X-Initial-impressions
21•surprisetalk•3d ago•1 comments

Coinbase 8K SEC filing for breach

https://www.sec.gov/ix?doc=/Archives/edgar/data/1679788/000167978825000094/coin-20250514.htm
26•weinzierl•51m ago•0 comments

Lock-Free Rust: How to Build a Rollercoaster While It's on Fire

https://yeet.cx/blog/lock-free-rust/
68•r3tr0•2d ago•20 comments

Archisuits (2005–2006)

https://insecurespaces.net/archisuits-2005-2006/
10•internet_points•2d ago•1 comments

Launch HN: Tinfoil (YC X25): Verifiable Privacy for Cloud AI

121•FrasiertheLion•15h ago•87 comments

Bringing 3D shoppable products online with generative AI

https://research.google/blog/bringing-3d-shoppable-products-online-with-generative-ai/
20•bookofjoe•2d ago•10 comments

Tek – A music making program for 24-bit Unicode terminals

https://codeberg.org/unspeaker/tek
122•smartmic•11h ago•13 comments

Material 3 Expressive: Better, Easier, Emotional UX

https://design.google/library/expressive-material-design-google-research
3•meetpateltech•2d ago•0 comments

NASA keeps ancient Voyager 1 spacecraft alive with Hail Mary thruster fix

https://www.theregister.com/2025/05/15/voyager_1_survives_with_thruster_fix/
245•nullhole•7h ago•41 comments

GTK Krell Monitors

https://gkrellm.srcbox.net/
57•Deeg9rie9usi•3d ago•16 comments

The current state of TLA⁺ development

https://ahelwer.ca/post/2025-05-15-tla-dev-status/
115•todsacerdoti•13h ago•26 comments

Windsurf SWE-1: Our First Frontier Models

https://windsurf.com/blog/windsurf-wave-9-swe-1
65•arittr•13h ago•10 comments

A Tiny Boltzmann Machine

https://eoinmurray.info/boltzmann-machine
234•anomancer•18h ago•39 comments

Rolling Highway

https://en.wikipedia.org/wiki/Rolling_highway
35•taubek•2d ago•20 comments

Dr. Dobb's Journal interviews Jef Raskin (1986)

https://computeradsfromthepast.substack.com/p/dr-dobbs-journal-interviews-jef-raskin
74•rbanffy•13h ago•58 comments

Malicious compliance by booking an available meeting room

https://www.clientserver.dev/p/malicious-compliance-by-booking-an
339•jakevoytko•18h ago•321 comments

Show HN: Min.js style compression of tech docs for LLM context

https://github.com/marv1nnnnn/llm-min.txt
168•marv1nnnnn•18h ago•49 comments

Meta Battles an 'Epidemic of Scams' as Criminals Flood Instagram and Facebook

https://www.wsj.com/tech/meta-fraud-facebook-instagram-813363c8
54•erehweb•4h ago•28 comments

“The Mind in the Wheel” lays out a new foundation for the science of mind

https://www.experimental-history.com/p/new-paradigm-for-psychology-just
79•CharlesW•13h ago•60 comments