Round up / decimals

Is there any way of rounding up a value or chosing position after the decimal?

Let’s say i got

3.141592653589793238 and all i want to display is 2 digits after decimal ,how could I do that ? Thanks in advance!

You can do the following on a function node. Let me know if you have any questions.

Number.parseFloat(3.141592653589793238).toFixed(2)

not sure i got it, could you tell me how to add it to :

${{$json[“BTC/USD”]/100000000}} for example?

Hey @marcondy!

You can use either of the following expressions:

  1. {{Math.round($json["BTC/USD"]/10000)}} Output will be similar to 3
  2. {{Number.parseFloat($json["BTC/USD"]/10000).toFixed(2)}} Output will be similar to 2.70

Hope this helps! :slightly_smiling_face:

4 Likes

thank you ! worked like a charm

1 Like

Happy that I could help! Have fun! :slightly_smiling_face:

1 Like

Hey @RicardoE105,

I have tried with string number (343.29842488).toFixed(2) but I got an undefined error. Don’t know where I am doing something wrong. :person_shrugging:

If the number is a string, just parse to number and then do the toFixed as shown below:

Number('343.29842488').toFixed(2)