THIS is How to Store Money and Currency using Swift

This can go wrong!

Steven Curtis
3 min readApr 28, 2021
Photo by Josh Appel on Unsplash

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:

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)

--

--

Responses (3)