1775
Views
7
Comments
Solved
Math Functionality of Outsystems to round
Question

Hai,

I am used round functionality, If I directly assign the expression of value Round(3.7) correct answer is displayed Ans 4. But If I using the local variable(Number) assignment Number=3.7,then I assigned the expression of value Round(Number) answer is not displayed correctly. Ans 3. Anyone can help me pls


Regards,

Jeyasri R

2025-01-09 14-56-57
IQ78
Solution

QUoted from this document: https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Logic/Built-in_Functions/Math#Trunc

In expressions in client-side and server-side logic, applies the method round half to even (rounds to the nearest integer, 0.5 rounds to the nearest even integer).

So, if it is exactly 0.5, it will be rounded to EVEN number. 12.5 will be 12 (12 is even, 13 is odd); 13.5 will be 14 (14 is even, 13 is odd), etc.

to round up, just use expression like this:

Round(If(x-Trunc(x)=0.5, x + 0.1, x)) where x is a variable that is assigned your value, like 12.5.

May this helps.

regards

2024-12-19 12-19-39
Amal
 
MVP

Hi Jeyasri 

Please check the datatype of the variable (Number). I believe you are declaring it as an Integer, so the variable would store the value 3 only, so rounding or no rounding, you will get the answer as 3. 

If you change the data type to Decimal, you will achieve what you are looking for. 

Regards


2020-01-03 05-37-58
JEYASRI R

Amal Raj wrote:

Hi Jeyasri 

Please check the datatype of the variable (Number). I believe you are declaring it as an Integer, so the variable would store the value 3 only, so rounding or no rounding, you will get the answer as 3. 

If you change the data type to Decimal, you will achieve what you are looking for. 

Regards



Thanks Amal

2020-01-03 05-37-58
JEYASRI R

Amal Raj wrote:

Hi Jeyasri 

Please check the datatype of the variable (Number). I believe you are declaring it as an Integer, so the variable would store the value 3 only, so rounding or no rounding, you will get the answer as 3. 

If you change the data type to Decimal, you will achieve what you are looking for. 

Regards


Hai Amal

I need another clarification. I have to set the odd number .5 for example Round(11.5) correct answer is displayed Ans 12. but If I am set the even number .5 for example Round(12.5) I got 12. Actually correct answer is 13 right.Can u pls help me.


Thanks,

Jeyasri R


2020-06-08 02-42-28
Wasabi

I got 4.

mydecimal = round(3.7)

Check what data type is your variable?  In above it is decimal.

2020-01-03 05-37-58
JEYASRI R

Behavioral wrote:

I got 4.

mydecimal = round(3.7)

Check what data type is your variable?  In above it is decimal.

Integer datatype..I changed the decimal datatype.I also got 4.It is work correctly, Thanks for ur reply


2020-01-03 05-37-58
JEYASRI R

Behavioral wrote:

I got 4.

mydecimal = round(3.7)

Check what data type is your variable?  In above it is decimal.

Hai

I need another clarification. I have to set the odd number .5 for example Round(11.5) correct answer is displayed Ans 12. but If I am set the even number .5 for example Round(12.5) I got 12. Actually correct answer is 13 right.Can u pls help me


Thanks,

Jeyasri R

2025-01-09 14-56-57
IQ78
Solution

QUoted from this document: https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Logic/Built-in_Functions/Math#Trunc

In expressions in client-side and server-side logic, applies the method round half to even (rounds to the nearest integer, 0.5 rounds to the nearest even integer).

So, if it is exactly 0.5, it will be rounded to EVEN number. 12.5 will be 12 (12 is even, 13 is odd); 13.5 will be 14 (14 is even, 13 is odd), etc.

to round up, just use expression like this:

Round(If(x-Trunc(x)=0.5, x + 0.1, x)) where x is a variable that is assigned your value, like 12.5.

May this helps.

regards

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