Last active
December 7, 2016 11:06
-
-
Save svetlanama/f4abf2528c0026b5e4732bc7e8a45f0b to your computer and use it in GitHub Desktop.
Float Point Values Computation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let a = 1e+30 | |
let b = -1e+30 | |
let c = 1.0 | |
let sum1 = (a + b) + c | |
let sum2 = a + (b + c) | |
//Representation of floating point value according to IEEE 754 | |
let lbits = Double(-0.06) | |
lbits.sign //sign | |
lbits.exponent //exponent | |
lbits.significand //mantissa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We all know the Math rule by permutation sum is not changed so
(a + b) + c = a + (b + c), and it seems to be that it is not TRUE in programming.