# Is there a Math Functionality of Outsystems to automatically round up

Is there an equivalent Math.Ceiling from .NET to Outsystems? Outsystems has a Round functionality but it does not have an option to automatically round up the value.
Check the forge if there are already some components.
Out of the box it isn't there.

otherwise create an function yourself :)
Trunc(value) + if (Value = Trunc(Value), 0, 1)

EDIT: Never mind :)

EDIT2: If you have a known number of digits, you can do Trunc(value + 0.99) (where you need the number of 9s as per your number of digits).
Hi Lawrence,

You can easily create an extension for this on Integration Studio. The outsystems' built-in functions contains the most common functions, but everything else you can extend (and that is the purpose of the IS Tool of platform). You could even create an extension that contains all the math functions you need and reuse this in all your future projects.

Trunc(value) + if (Value = Trunc(Value), 0, 1)

Do you have any idea to do a RoundUP but with 1 decimal digit?

Like this: RoundUP(12.22,1) = 12.3

Thank you

Nuno Oliveira wrote:

Trunc(value) + if (Value = Trunc(Value), 0, 1)

Do you have any idea to do a RoundUP but with 1 decimal digit?

Like this: RoundUP(12.22,1) = 12.3

Thank you

The fastest way? Multiply by 10, Roundup, Divide by 10 :)

Hi Nuno,

Great idea…

• First I did a normal round to 2 decimals;

• Then *10;
Trunc(value) + if (Value = Trunc(Value), 0, 1);

• /10;

I’m getting the expected results!

A very simple idea but very useful.

I didn’t spend time to think about it, I guess that appear immediately this solution in your head!

For that, Thank you so much!

Kind regards,

Nuno Oliveira

This is the extension you want:

https://www.outsystems.com/forge/component/516/trigfunctions/

Don't work hard to reinvent the wheel! :)

J.Ja

Hi Justin,

Thank you for the information.

Kind regards,

Nuno Oliveira

A basic alternative to round-up would be like this:

1. Truncate the value using the following expression Trunc(Value);
2. Find the decimal part of the number, like this Value - Trunc(Value);
3. If the decimal part is bigger than 0.5, then you sum 1 to the truncated value.

Best regards,

João Santos

I completely distrust the "Trunc" function, I have found bugs in it (not OutSystems' fault, it's the .NET platform's fault for how it handles some floating point numbers) where in certain cases it doesn't work as-expected. So I convert numbers to strings, and then look for the decimal point to do the operations. Much safer, and guaranteed to be correct.

J.Ja