
Johan Råde skrev:
Thorsten Ottosen wrote:
Johan Råde skrev:
Robert Kawulak wrote:
From: Johan Rade The statement is "x <= y before truncation implies x <= y after truncation".
Or more specifically: "x < y before truncation implies x <= y after truncation" Is this right?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thought about it again. None if these statements are true, unfortunately, if you consider the case when one number is truncated to 64 bits and the other is kept at 80 bits. Then you can even have x < y before and x > y after.
Hm. This sucks.
Do we know if that 80-bit floating point values are guaranteed to be a superset of 64-bit and 32-bit floats (or if 64-bit is a superset of 32-bit floats).
I suspect the answer might be yes. If so, I don't think
x < y before ==> x > y after
can be true. If x is rounded upwards, y would be an upper bound.
Imagine the following case,
1) x and y are stored in 80-bit registers 2) x < y 3) both x and y are just below 1.0, so close that they would be rounded to 1.0 if truncated to 64 bits
If now x is truncated to 64 bits, and then moved back to an 80-bit register, while y is unchanged, then x > y.
We need to make either x or y one of the bounds of our interval. Let us assume it is y. Furthermore, we know y has been specified such that it is representable exactly in float or double. Since the 80-bit floating point values are a superset, we know y can also be represented exactly in this format, and we know that truncation on y will have no effect. Basically, y will have the same value no matter if it is stored in a register or at some memory location. The question is know, can x < y pass, and then x is assigned to the a bounded_float (where it will be stored in x'), only to discover that x' < y ? We know y will always have the same value, so only x may switch location. Case 1: x is in memory, x' is in register. Then x == x' by the superset property. Case 2: x is in register, x' is register. Then x == x'. Case 3: x is in register, x' is in memory. Then we might have x' == y, but not x' > y, since that would violate the fact that y is exactly representable in both formats. Have I overlooked something? -Thorsten