From: Steffen Nurpmeso Subject: Re: exact floating point calculations in roff(7) To: Ingo Schwarze Cc: j@bitminer.ca, tech@openbsd.org Date: Sat, 05 Apr 2025 22:22:35 +0200 Ingo Schwarze wrote in : ... |Before i wrote the double arithmetic code, that code did use integer |arithmetic. I had written that integer arithmetic code several years |earlier. | |> decided, instead, to adopt doubles. | |I deemed the change necessary because the roff(7) input syntax |supports decimal fractions. | |Admittedly, it might be possible to parse 23.999 as *two* integers |(23 and 999), scale both parts separately, do some kind of carry, |and finally add both results, all using integer arithmetics. |I admit i did not consider that possibility when switching this |code to floating point, but it does not feel like a simple solution. I mean, you *could* also ask "which is the largest output size i want to support" on the one hand, and on the other count fraction digits. Ie, always work with "super-scaled" 64-bit integer arithmetic. Just wanted to add that. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)