Rounding currency

Hi - I have searched for an answer to this but I haven’t understood what I’ve seen!

I want to be able to round a value in CL and force it to display 2dps - even if the last one is a zero.
So 213.5 would display as 213.50.

If I use the round function that doesn’t happen - please can someone explain how I can get it to display correctly? This is what I am using:

bandtwotax2 = numericValue("\round(${value},2)")

I found this post but I can’t get the code to work as I don’t understand it!

Many thanks for any help!

This is what I use:


r.float will give you any possible number/decimal between 1 and 10, which you can change to be any numbers, and then the 2 that comes after tells it to be rounded off to the hundredths place, which you can also change that to round to whatever

Hi - thanks for that. I have tried to use your format by replacing r.float(1,10) with the calculation I want it to round and it is still only showing 1 dp if the second dp is zero. Am I using it correctly?

(the part after the left bracket is displaying oddly! Sorry!)

bandtwotax=numericValue("\operatorname{round}\left({upperpercenttax2}*{hrp} ,2)\right)")

I’m pretty sure there is no formatting control. I was also asking about support for currency handling back in May (Handling Currency Values) and nothing seemed available then.

Ok - thanks! So is my only work around to use a graphing component to find a way to capture the 2nd dp and then find a way to display it if that value is zero?

Feels a little beyond me but I will have a go!

I have managed to make a workaround that checks if the rounded value to 2dp = 1dp and if it is, I manually add a zero to the content. I also check if rounded value to 0dp = 1dp and display an extra .00 if it is. I did this is all in the CL of the note rather than using an extra graph component,

Seems to work until the currency option becomes available.


I think you have a bit of an issue there with your code - it currently incorrectly rounds things.

Try 5.34 for example.

oh NO! thank you for spotting that - I will attempt to fix it!!

Fixed it! I was getting it to check if the rounded value to 0 dp and 1dp were the same and then use that as a basis for assuming it was a whole number! I have added a check to ensure the rounded value to 2dp is the same as well before assuming it is a whole number. Thank you! If you spot any other mistakes please let me know.