# [Solved] Decimal places

Any way to use/show variables limited to one decimal place or two or three? If there is one, I haven’t found one in the expression editor

Anyone know a solution or workaround? Thanks

1 Like

To get 0 decimal points:

``trunc(Value)``

To get 1 decimal point:

``trunc(Value * 10) / 10``

Two decimal points:

``trunc(Value * 100) / 100``

And so on
The value is multiplied by a multiple of 10, so you “save” a number of decimals equal to the number of 0’s this multiple of 10 has, then the other decimals are deleted by the truncate function “trunc()”, finally you divide by the same multiple of 10 to set the “saved” decimals after the floating point again.

2 Likes

Oh I think I get it. Can you store the truncated value in a variable?

For one decimal place:
Ex: accuracy=trunc (((kills/shots)*100)*10)/10)

Yes, but you are multiplying and dividing by 10, so you can simply do:

``accuracy = trunc( (kill/shots) * 100 )``

Instead giving you 85.741623611 %, the saved value will be 85 %. If you use “round()” instead “trunc()” the value will be 86 % (rounded)

1 Like

Yep it works beautifully Thanks guys, thought it might have been some sort of text formatting math function or something