frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

A misalignment of AI in mathematics

https://mathandai.org/
549•meredydd•6h ago•612 comments

I spent $220 on Google app ads and 60% of the installs were robots

https://dayzlegame.com/blog/google-ads-bot-farm/
230•nickabe•5h ago•121 comments

OpenAI agents carried out an undisclosed attack on RubyGems

https://www.rubyhack.ai/
27•chao-•33m ago•5 comments

GrapheneOS' rewritten Messages app is released

https://github.com/GrapheneOS/Messaging/releases/tag/13
170•microtonal•5h ago•98 comments

A Design Space Exploration of Async/Await

https://cel.cs.brown.edu/blog/design-space-async-await/
97•wcrichton•2d ago•21 comments

DeCloudflare

https://0xacab.org/dCF/deCloudflare/-/blob/master/README.md
25•DeepLogin•51m ago•38 comments

Project Blinkenlights

https://blinkenlights.de/en/
27•doener•1h ago•12 comments

Show HN: ResolveHQ – A Helpdesk Built on Cloudflare Workers, D1, R2 and Queues

https://github.com/mirza-rizvi/ResolveHQ
18•mirza_rizvi•2h ago•7 comments

Litelm: LiteLLM Without the Bloat

https://github.com/kennethwolters/litelm
83•kennethwolters•5h ago•34 comments

Λ Snap – An inviting programming language for kids and adults for CS study

https://snap.berkeley.edu/
99•dr_kiszonka•6h ago•53 comments

AlphaGenome maps 9B DNA variants

https://spectrum.ieee.org/alphagenome-atlas
59•ltononro•2d ago•6 comments

Hepburn Romanization: How to Read Japanese in the Latin Alphabet

https://www.fink-translate.com/blog/hepburn-romanization.html
11•miuraboy•1d ago•2 comments

QueryBrew: System-Agnostic SQL-to-SQL Query Optimization [pdf]

https://www.vldb.org/pvldb/vol19/p4494-schmidt.pdf
9•matt_d•1h ago•0 comments

Rune is now open source

https://rune.build/blog/rune-is-now-open-source
128•ernestrc•8h ago•52 comments

The EPA is planning to scrap public review rules for data center pollution

https://capitalbnews.org/data-centers-permit-rules-epa/
311•doener•5h ago•211 comments

I've operated petabyte-scale ClickHouse clusters for 5 years

https://www.tinybird.co/blog/what-i-learned-operating-clickhouse
169•adastral•4d ago•62 comments

So you want to use OpenRouter?

https://mmoustafa.com/blog/so-you-want-to-use-openrouter/
688•player85•2d ago•189 comments

Logo Programming Language

https://el.media.mit.edu/logo-foundation/what_is_logo/logo_programming.html
232•azhenley•2d ago•94 comments

Mind-altering drugs played key role in rise of Andean civilization

https://www.science.org/content/article/mind-altering-drugs-played-key-role-rise-andean-civilization
85•geneticdrifts•6h ago•64 comments

Zep AI (YC W24) Is Hiring a Head of Forward Deployed Engineering

https://www.getzep.com/careers/
1•roseway4•6h ago

Show HN: Godot and Rust based multiplexer (terminal panes and more)

https://github.com/godot-pty/gpty
75•1nv1n•7h ago•41 comments

There is no 10x RBAC

https://infisical.com/blog/folder-based-rbac
12•FinnLobsien•2d ago•3 comments

CIA Releases President's Daily Briefs in Commemoration of 9/11

https://www.cia.gov/stories/story/cia-releases-presidents-daily-briefs-in-commemoration-of-the-25...
92•stmw•5h ago•54 comments

Claude is only available to people over 18 years

https://support.claude.com/en/articles/15171100-age-assurance-on-claude
554•Muhammad523•13h ago•584 comments

RTK reports token savings, but our cost benchmarks disagree

https://quesma.com/blog/does-rtk-make-ai-coding-cheaper/
142•michalwarda•12h ago•71 comments

Show HN: Bodily Oddities

https://vester.si/bodily-oddities/
153•vesterde•1d ago•121 comments

How the Chorleywood Bread Process transformed British bread

https://edconway.substack.com/p/the-little-holes-in-your-bread-are
95•baud147258•3d ago•101 comments

Global Glacier Extinction Explorer

https://glacierextinction.com
148•guillego•7h ago•49 comments

Copper lined vest to help penguins with recovery

https://apnews.com/article/chile-el-nino-humboldt-penguins-vulnerable-injuries-rehabilitation-6e9...
54•ninju•3d ago•16 comments

Measuring the sloppiness of code

https://earendil.com/posts/measuring-code-sloppiness/
238•doppp•10h ago•222 comments
Open in hackernews

Comparing floating-point numbers (2012)

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
26•sph•1y ago

Comments

LegionMammal978•1y 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•1y 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•1y 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.