Brandon Rohrer on Nostr: It is surprisingly hard to get computers to do addition with decimals the way a ...
Published at
2025-12-31 03:00:30 UTCEvent JSON
{
"id": "7bb3117e6cc55f7aa37e3dbc35bb33b81ba8b14a82a998f67cf84235ee861316",
"pubkey": "338db7cb8d3882b90195100eaeaf6094d197494045fbd2a15bd55a7d892565df",
"created_at": 1767150030,
"kind": 1,
"tags": [
[
"imeta",
"url https://cdn.masto.host/recsyssocial/media_attachments/files/115/811/941/266/725/311/original/e341c7ad07b83a88.png",
"m image/png",
"dim 1346x970",
"blurhash U05h0,oJ-:9Z~q01%2xt-:E1WBxa-o~V9aE1"
],
[
"proxy",
"https://recsys.social/users/brohrer/statuses/115811944390833123",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub/"
]
],
"content": "It is surprisingly hard to get computers to do addition with decimals the way a third-grader can.\n\nadding floats gives things like \n\n0.1 + 0.2 = 0.30000000000000004\n\nhttps://graffitiwall.nexus/graffiti_adder.html\n\nThe mpmath library in Python is capable of arbitrary precision, but still gives things like \n\n-1.2 + 1.21 = 0.009999999999...\n\nhttps://mpmath.org\n\nThe answer I was looking for was Python's decimal library. It gives\n\n0.1 + 0.2 = 0.3\nand\n-1.2 + 1.21 = 0.01\n\nhttps://docs.python.org/3/library/decimal.html\n\nhttps://cdn.masto.host/recsyssocial/media_attachments/files/115/811/941/266/725/311/original/e341c7ad07b83a88.png",
"sig": "80d4b57439bb48e9caaa3653cd112d60b61120578a004ac06f9b824ba2209711db2f48a233a6065263e1adfd0b9ef87b115321d0928882726df1d857d51242f0"
}