Created
November 7, 2015 22:03
-
-
Save bsneed/6589a0273f0f8b996af9 to your computer and use it in GitHub Desktop.
Decimal is a struct that wraps NSDecimalNumber so you can use it like other types (Float, Int, Double, Int64, etc)
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
func testSomeStuff() { | |
// trying to come up with shit to test. | |
var d: Decimal = 1234 | |
print(d) | |
d += 2 | |
print(d) | |
d++ | |
print(d) | |
var b = ++d | |
print(b, d) | |
b *= 3.14 | |
print(b) | |
b /= 2 | |
print(b) | |
// make sure the behavior is the same as the normal int/float types. | |
let neg = Decimal(-200.4) | |
let fneg = -200.4 | |
print(+neg, +fneg) | |
print(-neg, -fneg) | |
let pos = Decimal(200.4) | |
let fpos = 200.4 | |
print(-pos, -fpos) | |
print(+pos, +fpos) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test increments of .1