Rounding is pretty simple in Swift. But as usual there are a few gotchas:

1. Rounding is performed by the rounded() function:

2. If you want to round to a certain number of decimals, try a little arithmetic:

I think that’s all you need!

How to Round a Number in Swift Programming
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Get your FREEapp monetisation flowchart!

Use our epic flowchart to help you find the money in your idea! If you're thinking of making an app then this is vital information!


You have subscribed! Please check your email to confirm this subscription and to receive your item!