
Fernando Cacciola wrote:
Johan Råde wrote:
John Maddock wrote:
Johan Råde wrote:
> floatdistance(lhs, rhs)? Would adding an underscore be nicer:
FPT float_distance(FPT lhs, FPT rhs); How about discrete_distance? That's not bad at all actually,
Thanks, John. To me the word distance suggests an unsigned quantity.
Same here, but...
Maybe discrete_difference?
The word difference in the context of a numerical operation suggests a numerical difference, so I feel that distance suits better here.
I like "representation_distance". To me it says exactly what it is. And I would even call it "rep_distance" since 'rep' is a fairly common abbreviation.
Anyway, don't we want to also have the 'cousin' function: "representation_advance", such that:
representation_advance(x,representation_distance(x,y)) == y
always holds for any x,y?
That identity makes it clear that the distance is signed.
Best
Hmm, the concept we are discussing is related to the set of possible values of a floating point number type, but not necessarily to the representation of these values. Also, if we calculate the xxx_distance between a positive and a negative number, do we count positive and negative zero separately? I suppose not. The name representation_distance suggests that we might. --Johan