PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 11, 2022

[FIXED] How to get top and bottom number of a number in iOS Swift?

 August 11, 2022     decimal, ios, numbers, swift     No comments   

Issue

I have a number like 73
how get max and min like 70 and 80.
or 173 I want to get 170 and 180 etc.


Solution

ceil(73/10) * 10 // round up 80
round(73/10) * 10 // round down 70

Playground: enter image description here

EDIT: Here just provide an idea.

let value: Int = 75

func min(_ value: Int) {
    value - value % 10
}

func max(_ value: Int) {
    value + 10 - value % 10
}

min(value)

max(value)


Answered By - William Hu
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,206,943

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing