675
Views
8
Comments
Decimal with 2 digits without round off
Application Type
Traditional Web
Platform Version
11.20.0 (Build 38549)

I need decimal value with 2 decimal places for the amount and it should not be rounded instead it should be cut off to 2 decimal places

Example: 4816.875 should display as 4816.87 or 3699.095 should display as 3699.09

2025-02-10 17-24-13
Arun Rajput

Hi Asha,

You can use outsystems built in function FormatDecimal()

Ex- FormatDecimal(4816.875,2,"",".")

It will give you exact result which you want


Regards,

Arun

UserImage.jpg
Puja Rani

Hi ,

You can check the below post. It is similar to what you looking for. Hope this helps.

https://www.outsystems.com/forums/discussion/74947/rounded-off/

2023-06-09 10-11-01
Mayuri Pokale

Hi Asha,

You can convert the decimal value into string and then you can format it using the Substr() method and again convert it into decimal with  the help of TextToDecimal() function. 

The required expression would look like:

TextToDecimal(Substr(DecimalToText(In1),0,Index(DecimalToText(In1),".")+3))

In1 will get replaced by the valur you want to pass to the assignment

Example: if we pass 1232.956580 it will return 1232.95


Hope this helps!

Regards

UserImage.jpg
Kiran Shetty

Hi @Asha Burkul 

Check this oml which uses built in function>math>roundoff 

This also will solve your problem

Regards,

Kiran

RoundOff.oml
2021-09-05 13-08-37
Naveen Kumarasamy

Hi @Asha Burkul,

Please check the link provided below:

https://www.outsystems.com/forums/discussion/44508/math-functionality-of-outsystems-to-round/


Thanks&Regards,

Naveen Kumarasamy

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Asha Burkul ,

you can truncate the value multiplied by 100, and then divide by 100

Trunc(Decimal*100)/100

So, 100 is for 2 digits fractional part, 1000 would be for 3 digits fractional part and so forth.

Dorine

2024-03-07 04-57-05
Vox

First: Truncate the decimal variable.

Second: Perform simple arithmetic with multiplication and division my a hundred to get decimal hundredths.

Third: Format decimal to display zeroes when given a whole number value.


Expression--

FormatDecimal(Trunc([LOCALVAR]* 100) / 100, 2, ".", ",")

2021-11-12 04-59-31
Manikandan Sambasivam

To truncate a decimal value to 2 decimal places without rounding in OutSystems, you can create a function to achieve this. 

  1. Multiply the Amount by 100:

    • Create an Assign action and set a local variable (e.g., TruncatedAmount) to Amount * 100.
  2. Use Math.Floor Function:

    • Use the Math.Floor function to remove the decimal part. This function will round down to the nearest integer.
    • TruncatedAmount = Math.Floor(TruncatedAmount)
  3. Divide by 100:

    • Assign the TruncatedAmount divided by 100 to get the truncated value.
    • TruncatedAmount = TruncatedAmount / 100
  4. Return the Truncated Value:

    • Create an Output Parameter to return the TruncatedAmount.

Example:

If you input 4816.875, the function should:

  • Multiply by 100: 4816.875 * 100 = 481687.5
  • Floor the value: Math.Floor(481687.5) = 481687
  • Divide by 100: 481687 / 100 = 4816.87

Similarly, for 3699.095:

  • Multiply by 100: 3699.095 * 100 = 369909.5
  • Floor the value: Math.Floor(369909.5) = 369909
  • Divide by 100: 369909 / 100 = 3699.09
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.