Round _up_ math.divided_by?
See original GitHub issueTeam,
Is it possible to do a math.divided_by and round UP the result?
Now:
{{ 25 | math.divided_by 2 }} = 12.5 so it will return 12
The goal is to “round up” the 12.5 to 13 instead of down to 12.
IF you could check if the start number is_odd or is_even, then you could
- if_odd: add 1 to 25 --> 26 --> /2 = 13
- if_even: --> /2
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to round up the result of integer division? - java
For C# the solution is to cast the values to a double (as Math.Ceiling takes a double): int nPages = (int)Math.Ceiling((double)nItems ...
Read more >How to round up the answer of an integer division?
If you want to round up instead, a quick way is, as the top comment says, just to add denominator - 1 to...
Read more >Decimal Rounding and Division | CK-12 Foundation
If the number is equal to or greater than 5, round the number up. Round 2.1046891425 to the nearest hundredths place. The number...
Read more >Rounding Numbers - Kids Math
When the number you are rounding is between 0-4, you round down to the next lowest number. When the number is 5-9, you...
Read more >Round up when Dividing numbers - Power Platform Community
Hello Teams, I'm using 'Div' function to divide a number by 30 and I want to round up the result. For example, 139/30...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hm, in some cases, number will not round correctly with floating point numbers. You can try to use a custom function that wraps double.Round(Double, MidpointRounding) using
MidpointRounding.AwayFromZero
I can add maybe later a function
math.round_away_from_zero
but it won’t solve all issues as explained in the doc linked.You can probably use something like
{{ (25 / 2) + 0.5 | math.round }}