Skip to content

Instantly share code, notes, and snippets.

@bsneed
Created November 7, 2015 22:03
Show Gist options
  • Save bsneed/6589a0273f0f8b996af9 to your computer and use it in GitHub Desktop.
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)
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)
}
@steveriggins
Copy link

test increments of .1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment