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/
288•segmenta•2h ago•169 comments

Qwen3-TTS Family Is Now Open Sourced: Voice Design, Clone, and Generation

https://qwen.ai/blog?id=qwen3tts-0115
168•Palmik•3h ago•37 comments

In Europe, Wind and Solar Overtake Fossil Fuels

https://e360.yale.edu/digest/europe-wind-solar-fossil-fuels
251•speckx•3h ago•218 comments

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

https://cannoneyed.com/isometric-nyc/
44•cannoneyed•44m ago•11 comments

Tree-sitter vs. Language Servers

https://lambdaland.org/posts/2026-01-21_tree-sitter_vs_lsp/
103•ashton314•2h ago•30 comments

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

https://github.com/google-gemini/gemini-cli/issues/16728
47•nickswalker•1h ago•12 comments

AnswerThis (YC F25) Is Hiring

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

Miami, Your Waymo Ride Is Ready

https://waymo.com/blog/2026/01/miami-your-waymo-ride-is-ready
26•ChrisArchitect•1h ago•25 comments

Design Thinking Books You Must Read

https://www.designorate.com/design-thinking-books/
190•rrm1977•5h ago•92 comments

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

https://constellation-io.com/
6•kmajid•33m ago•0 comments

ISO PDF spec is getting Brotli – ~20 % smaller documents with no quality loss

https://pdfa.org/want-to-make-your-pdfs-20-smaller-for-free/
91•whizzx•6h ago•40 comments

30 Years of ReactOS

https://reactos.org/blogs/30yrs-of-ros/
160•Mark_Jansen•9h ago•80 comments

Joe Armstrong and Jeremy Ruston – Intertwingling the Tiddlywiki with Erlang [video]

https://www.youtube.com/watch?v=Uv1UfLPK7_Q
24•kerim-ca•2d ago•2 comments

Show HN: Sweep, Open-weights 1.5B model for next-edit autocomplete

https://huggingface.co/sweepai/sweep-next-edit-1.5B
470•williamzeng0•18h ago•95 comments

Doctors in Brazil using tilapia fish skin to treat burn victims

https://www.pbs.org/newshour/health/brazilian-city-uses-tilapia-fish-skin-treat-burn-victims
223•kaycebasques•12h ago•71 comments

Your brain on ChatGPT: Accumulation of cognitive debt when using an AI assistant

https://www.media.mit.edu/publications/your-brain-on-chatgpt/
480•misswaterfairy•18h ago•347 comments

We will ban you and ridicule you in public if you waste our time on crap reports

https://curl.se/.well-known/security.txt
758•latexr•6h ago•467 comments

Show HN: Interactive physics simulations I built while teaching my daughter

https://www.projectlumen.app/
41•anticlickwise•3d ago•5 comments

In Praise of APL (1977)

https://www.jsoftware.com/papers/perlis77.htm
76•tosh•8h ago•43 comments

Downtown Denver's office vacancy rate grows to 38.2%

https://coloradosun.com/2026/01/22/denver-downtown-office-vacancy-rate-tenants-workplace/
14•mooreds•24m ago•9 comments

Threat actors expand abuse of Microsoft Visual Studio Code

https://www.jamf.com/blog/threat-actors-expand-abuse-of-visual-studio-code/
246•vinnyglennon•17h ago•250 comments

eBay explicitly bans AI "buy for me" agents in user agreement update

https://www.valueaddedresource.net/ebay-bans-ai-agents-updates-arbitration-user-agreement-feb-2026/
262•bdcravens•20h ago•278 comments

Douglas Adams on the English–American cultural divide over "heroes"

https://shreevatsa.net/post/douglas-adams-cultural-divide/
249•speckx•3h ago•250 comments

Pragmatic Bitmap Filters in Microsoft SQL Server

https://www.vldb.org/cidrdb/2026/i-cant-believe-its-not-yannakakis-pragmatic-bitmap-filters-in-mi...
5•tanelpoder•5d ago•1 comments

Meet the Alaska Student Arrested for Eating an AI Art Exhibit

https://www.thenation.com/article/society/alaska-student-arrested-eating-ai-art-exhibit/
77•petethomas•3h ago•41 comments

The Science of Life and Death in Mary Shelley's Frankenstein

https://publicdomainreview.org/essay/the-science-of-life-and-death-in-mary-shelleys-frankenstein/
16•Anon84•5d ago•1 comments

Claude's new constitution

https://www.anthropic.com/news/claude-new-constitution
535•meetpateltech•1d ago•626 comments

Waiting for dawn in search: Search index, Google rulings and impact on Kagi

https://blog.kagi.com/waiting-dawn-search
413•josephwegner•1d ago•230 comments

Gathering Linux Syscall Numbers in a C Table

https://t-cadet.github.io/programming-wisdom/#2026-01-17-gathering-linux-syscall-numbers
82•phi-system•5d ago•35 comments

Skip is now free and open source

https://skip.dev/blog/skip-is-free/
476•dayanruben•1d ago•216 comments