In the Swift REPL:
$ swift
Welcome to Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42). Type :help for assistance.
1> Double.greatestFiniteMagnitude == (Double.greatestFiniteMagnitude - Double(1))
$R0: Bool = true
2>
The same is true for Float32
(and I would assume the same for other similar types)
I've read this and various other pages about the subject of floating point inaccuracy, but they seem to all be talking about numbers after the decimal point being inaccurate.
My questions are:
- How is it possible that you cannot store a number that is less than your alleged maximum value?
- Does this start happening after a certain number?
- If only some numbers are not representable, can they be predicted? How many individual values can be stored by a
Double
or aFloat32
?