17
Views
4
Solved
Decimal round up (always!)
Question

Hi all,

I would like to make a function that has the input of a datatype 'decimal'  for example '4.1356'. The output of this action should than be 5. (The decimal value need to be rounded up, no matter what).

So if the decimal is 4.01 it should become 5, if it's already exactly a whole number it should be just displayed normally  (4 needs to stay 4). If its 0.5 it should become 1. Etc.

Does anyone have an idea on how to do this? (Reactive app)

Kind regards,

Bash nie

Champion
Solution

Hi bash,

Use Trunc() math bult in function to get to truncate it's decimal part.

For example Trunc(10.45) will give you 10.

So You can write logic like that- if  your decimal input parameter is greater than Trunc(decimal value) them add 1

= Trunc(decimal value) +1

and if it is equal to Trunc(decimal value) then it sould be same Trunc(decimal value)

Other ways, You can use math utils componet and use Math_ ceil function. You can also use Math.ceil() javascript function.

Hope this help

Thanks the first solution is exactly what i need!

Hi Bash Nie,

Test with this image function:

Hope this helps you.

Regards

Hi !

I tried the default round() function. However this doesn't always round up and therefore it's unfortnatly not suited for my use case.

Regards,

Bash nie

Champion
Solution

Hi bash,

Use Trunc() math bult in function to get to truncate it's decimal part.

For example Trunc(10.45) will give you 10.

So You can write logic like that- if  your decimal input parameter is greater than Trunc(decimal value) them add 1

= Trunc(decimal value) +1

and if it is equal to Trunc(decimal value) then it sould be same Trunc(decimal value)

Other ways, You can use math utils componet and use Math_ ceil function. You can also use Math.ceil() javascript function.

Hope this help

Thanks the first solution is exactly what i need!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.