Truncate a decimal number
What is the best way to truncate a decimal number? I tried using the Field: Set Value of a Decimal Field to take a decimal such as 0.18756 and just have the first 2 numbers after the decimal point, 0.18, but it automatically rounds it to 0.19. Is there a way to truncate this decimal without rounding it?
Best Answer
-
@Nasir_204951 I think you could also multiply by 100, use the parseInt method, and then divide by 100.
5
Answers
-
The slice field formulas in the link down below may be able to help you around the rounding issue. I recommend trying this out in a field formula:
fields['this-is-my-field'].slice(0,#)
Slice returns characters starting with the first character as 0 and then counting up to character number N.
Field: Field Formulas > Text formula syntax
https://help.catalytic.com/docs/field-field-formulas/#text-formula-syntax0 -
thanks, @Thomas_937381 and @Jozef_783863 . I ended up going with the method Thomas described and achieved the desired result.
0