Change decimal point after convert using to string

1
Hi guys, Anyone know how to change the decimal point if we change the data to string? toString($MasterData/CSPHmin)+'-'+toString($MasterData/CSPHMax) Based on the image above, I want to make the number in 2 decimal places, but when I used  function, it show 8 decimal places.  
asked
2 answers
3

You can use the Round Function to reduce the decimal precision before parsing your data to a string.

So, to use your example:

toString(  round($MasterData/CSPHmin), 2) +'-'+toString(   round($MasterData/CSPHMax), 2)

(You'll have to decide if you want to round before or after adding as they may lead to different values)

answered
1

There is the formatDecimal function that you can use to do this.

https://docs.mendix.com/refguide/parse-and-format-decimal-function-calls/#3-formatdecimal
 

formatDecimal($MasterData/CSPHmin, '0.0#') + '-' + formatDecimal($MasterData/CSPHMax, '0.0#')


The format of the decimal point will be related to your locale. You can override this by passing in an optional locale string, or use the Decimal Tools module in the marketplace to manually set it.

https://marketplace.mendix.com/link/component/119981

Hope this helps.

answered