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": "5d1d792c769099f59a0ee79ba5028c42c8d581840a6ff68fc5abd6108eceb684",
"pubkey": "95ea081a627cee44e532825986ecc662139d068c4bdacbe820a8f445b9c6c06b",
"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"
],
[
"proxy",
"https://recsys.social/@brohrer/115811944390833123",
"web"
],
[
"proxy",
"https://recsys.social/users/brohrer/statuses/115811944390833123",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://recsys.social/users/brohrer/statuses/115811944390833123",
"pink.momostr"
],
[
"-"
]
],
"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\nhttps://cdn.masto.host/recsyssocial/media_attachments/files/115/811/941/266/725/311/original/e341c7ad07b83a88.png\n",
"sig": "a96250a33942923589eaa06e998b480f8b2a76bc9496f83b1d3688409198e33f6f14a2f636b3b38af5c4930ea5aff6a2c383e82afc9c29ab9883091958f0f709"
}