Considering switching the mathable fields in Typica away from using the ECMA-262 host environment and instead letting SQLite do the arithmetic for me because that's less work than implementing a proper solution myself, is less work and doesn't come with license issues compared with some of the libraries I looked at, and Typica 2 already has an SQLite dependency anyway and has better behavior for this use case.

Most of the time the existing solution works just fine, but then you end up with things like 1+1.03=2.0300000000000002 (generally with slightly larger numbers since it's used for things like the roasted coffee not fitting in one bucket and adding the two bucket weights together) instead of the expected 2.03. Other options are heuristic hacks or exposing a setting for decimal places, but SQL already specifies the behavior I want so as much as I hate this "solution" I'll go with it for now.

Follow

There's work on getting decimal floats into C and I wouldn't be surprised if C++ just absorbed that once it's ready, and I would expect this to also behave better for this use case so I can revisit that decision some time next decade.

· · Web · 0 · 0 · 0
Sign in to participate in the conversation
Typica Social

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!