I
I
impressive172020-09-30 16:05:14
go
impressive17, 2020-09-30 16:05:14

How to round up a number in golang?

I need to always round a number up, for example, 11.3 -> 12. As far as I know, math.Round() rounds up to the nearest, not up. Can you tell me how can I achieve the desired result?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2020-09-30
@impressive17

math.Ceil()- rounding up
math.Floor()- rounding down

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question