aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/backend
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-25 03:01:17 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-18 13:54:54 +0100
commit1c182507c3981aa20193c68d7cfd32d750b571cf (patch)
treeb0ec94c9cad3d457ffb7db679a070db729327450 /validation/backend
parent1fb139520881e9339589048c9c31dd1956a33ffb (diff)
downloadsparse-dev-1c182507c3981aa20193c68d7cfd32d750b571cf.tar.gz
fix support of floating-point compare
Comparision of floating-point values can't be done like for integral values because of the possibility to have NaNs which can't be ordered with normal values or even between themselves. The real difference appears once there is any "reasoning" done with the result of the comparison. For example, once NaNs are taken in account: "!(a < b)" and "(a >= b)" are not the same. In fact the usual comparison operators must be reinterpreted as implicitely first testing if any of the operand is a Nan and return 'false' if it is the case. Thus "a < b" becomes "!isnan(a) && !isnan(b) && (a < b)". If we need to negate the comparison we get "!(a < b)" which naturally becomes "isnan(a) || isnan(b) || (a >= b)". We thus need two sets of operators for comparison of floats: one for the "ordered" values (only true if neither operand is a Nan) and one for the "values" (also true if either operand is a NaN). A negation of the comparison switch from one of the set to the other. So, introduce another set of instructions for the comparison of floats. Note: the C standard requires that: *) "x == x" is false if x is a NaN, *) "x != x" is true if x is a NaN, and this is coherent with "x != x" <-> "!(x == x)". Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/backend')
0 files changed, 0 insertions, 0 deletions