Test integerness: Difference between revisions

m
→‎Tricky: Dancing with the optimisations.
m (→‎Tricky: Dancing with the optimisations.)
Line 161:
Or alternatively, compare 1 + ''eps'' to 1, successively dividing ''eps'' by BASE.
 
The difficulties include the risk that a compiler might wrongly apply the axia of mathematics to floating-point arithmetic and deduce that D was always one. Similarly, after assigning the result of X + 1 to Y, it may notice that the register could retain that value and so there would be no need to load Y's value to calculate Y - X: if the register was of greater precision than the variable, the probe will err. Producing output can help. As well as being interesting, otherwise a compiler might deduce that there is no need to calculate something because it is not used to produce output nor affects something that does lead to output.
 
Conveniently, F90 standardised the functions FRACTION(x) and EXPONENT(x) that reveal the parts of a floating point number and with the assistance of the RADIX(x) function that reports the base of the number system and DIGITS(x) the number of digits represented, a suitable boundary value can be constructed. For the decimal example above, 1E7 is the first value that has no space for fractional digits.
1,220

edits