THIS is How to Store Money and Currency using Swift
This can go wrong!
3 min readApr 28, 2021
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.5, and Swift 5.4
This will cover how we might store “money,” and make sure everything works as well as you might expect.
Take a look at the accompanying video: HERE
Prerequisites:
- You will be expected to be aware how to make a Single View Application in Swift, or be able to code in Swift Playgrounds.
Terminology:
Denary: The name of the base 10 numbering system
Double: A double-precision, floating-point value type
How can we store “money” and make sure everything works as well as you might expect.
The Solutions
Just use a double
Just is quite a disempowering word, especially when (in terms of currency) it can be a complete mistake.
What do I mean by this? Take a look at this example of adding two numbers:
let result: Double = 0.1 + 0.2print (result)