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.
Asked
Active
Viewed 99 times
-2

reza_khalafi
- 6,230
- 7
- 56
- 82
1 Answers
1
ceil(73/10) * 10 // round up 80
round(73/10) * 10 // round down 70
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)

William Hu
- 15,423
- 11
- 100
- 121
-
Sorry both of these code return 80. – reza_khalafi Jun 23 '19 at 17:35
-
@reza_khalafi are you sure? Check the edited image. – William Hu Jun 24 '19 at 02:26
-
Please check 75 or 76 . – reza_khalafi Jun 25 '19 at 06:59
-
See my edit, might not proper, shouldn't be a hard thing. – William Hu Jun 25 '19 at 08:24