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.

GPTZero finds 100 new hallucinations in NeurIPS 2025 accepted papers

https://gptzero.me/news/neurips/
627•segmenta•7h ago•333 comments

Show HN: isometric.nyc – giant isometric pixel art map of NYC

https://cannoneyed.com/isometric-nyc/
502•cannoneyed•6h ago•137 comments

Qwen3-TTS family is now open sourced: Voice design, clone, and generation

https://qwen.ai/blog?id=qwen3tts-0115
415•Palmik•9h ago•123 comments

Anthropic Economic Index economic primitives

https://www.anthropic.com/research/anthropic-economic-index-january-2026-report
16•malshe•1h ago•12 comments

Viking Ship Museum in Denmark announces the discovery of the largest cog

https://www.medievalists.net/2025/12/medieval-ship-discovered-copenhagen/
16•PaulHoule•1h ago•4 comments

Compiling Scheme to WebAssembly

https://eli.thegreenplace.net/2026/compiling-scheme-to-webassembly/
50•chmaynard•4d ago•8 comments

My first year in sales as technical founder

https://www.fabiandietrich.com/blog/first-year-in-sales.html
41•f3b5•5d ago•8 comments

CSS Optical Illusions

https://alvaromontoro.com/blog/68091/css-optical-illusions
113•ulrischa•5h ago•11 comments

Recent discoveries on the acquisition of the highest levels of human performance

https://www.science.org/doi/abs/10.1126/science.adt7790
83•colincooke•5h ago•41 comments

'Active' sitting is better for brain health: review of studies

https://www.sciencealert.com/not-all-sitting-is-equal-one-type-was-just-linked-to-better-brain-he...
47•mikhael•4h ago•22 comments

Capital One Strikes $5.15B Deal for Fintech Brex (YC W17)

https://www.wsj.com/finance/banking/capital-one-to-buy-fintech-brex-e2dacc67
19•cj•1h ago•10 comments

Why does SSH send 100 packets per keystroke?

https://eieio.games/blog/ssh-sends-100-packets-per-keystroke/
199•eieio•3h ago•143 comments

Your app subscription is now my weekend project

https://rselbach.com/your-sub-is-now-my-weekend-project
147•robteix•4d ago•118 comments

Extracting a UART Password via SPI Flash Instruction Tracing

https://zuernerd.github.io/blog/2026/01/07/switch-password.html
13•Eduard•1h ago•0 comments

Tree-sitter vs. Language Servers

https://lambdaland.org/posts/2026-01-21_tree-sitter_vs_lsp/
193•ashton314•8h ago•53 comments

Show HN: First Claude Code client for Ollama local models

https://github.com/21st-dev/1code
28•SerafimKorablev•5h ago•10 comments

Composing APIs and CLIs in the LLM era

https://walters.app/blog/composing-apis-clis
5•zerf•5h ago•0 comments

AnswerThis (YC F25) Is Hiring

https://www.ycombinator.com/companies/answerthis/jobs/r5VHmSC-ai-agent-orchestration
1•ayush4921•6h ago

Show HN: CLI for working with Apple Core ML models

https://github.com/schappim/coreml-cli
30•schappim•2h ago•0 comments

Launch HN: Constellation Space (YC W26) – AI for satellite mission assurance

28•kmajid•6h ago•10 comments

A Year of 3D Printing

https://brookehatton.com/blog/making/a-year-of-3d-printing/
71•nindalf•5d ago•74 comments

Reverse engineering Lyft Bikes for fun (and profit?)

https://ilanbigio.com/blog/lyft-bikes.html
42•ibigio•6h ago•12 comments

Keeping 20k GPUs healthy

https://modal.com/blog/gpu-health
68•jxmorris12•4d ago•25 comments

Design Thinking Books (2024)

https://www.designorate.com/design-thinking-books/
261•rrm1977•11h ago•120 comments

Preserved Fish, Boss of New York City

https://signoregalilei.com/2025/12/21/preserved-fish-boss-of-new-york-city/
15•surprisetalk•3d ago•2 comments

Mote: An Interactive Ecosystem Simulation [video]

https://www.youtube.com/watch?v=Hju0H3NHxVI
50•evakhoury•1d ago•8 comments

It looks like the status/need-triage label was removed

https://github.com/google-gemini/gemini-cli/issues/16728
262•nickswalker•6h ago•67 comments

Show HN: Text-to-video model from scratch (2 brothers, 2 years, 2B params)

https://huggingface.co/collections/Linum-AI/linum-v2-2b-text-to-video
28•schopra909•6h ago•7 comments

Show HN: Synesthesia, make noise music with a colorpicker

https://visualnoise.ca
27•tevans3•17h ago•11 comments

TTY and Buffering

https://mattrighetti.com/2026/01/12/tty-and-buffering
38•mattrighetti•5d ago•10 comments