On Sat Feb 22, 2025 at 12:21 AM CET, G. Branden Robinson wrote: > At 2025-02-22T00:11:13+0100, onf wrote: > > By the way, Heirloom troff has floating point registers. > > Just converting the type backing groff's registers from `int` to `long` > is a significant refactor, because it implicates other things like the > formatting of diagnostic messages. I found this out when taking a stab > at it a few years ago, assuming it would be easy. > > Floats aren't always better. They have variable instead of fixed > relative error, for example. So I wouldn't just assume that replacing > `int` with `double`--I assume no one would advocate `float`--would be an > unambiguous win.
I wouldn't think so, either. I just thought it might be relevant to the topic. I likewise think that troff's integer arithmetic is usually sufficient, and the combination of base-2 floating point tradeoffs and rise in internal complexity might not be worth it. With that said, while problems with floating point roundoff errors are well known, I've been wondering for a while whether the errors resulting from repeated truncation are any better, or if they could in fact be worse. > Then one wonders, "why not both?" > [...] Well, that's what Heirloom troff does... it has both integer and floating point registers, and it's in fact using the float data type for the floating point ones :) /* troff/tdef.h */ extern struct numtab { int r; /* name */ short fmt; int inc; int val; struct numtab *link; int aln; int nlink; float fval; float finc; enum flags flags; } *numtab; ~ onf