How to round decimals (Beginner Help)

Hello,

How can I round a calculated value?

I currently have a calculation showing 1.0833333333333

Is there any way I can shorten this to just 1.08 or round u or down?

I have googled math.floor() and math.round() but I cant wrap my head around how this would fit into my code

would appreciate your help!

thanks

1 Like

This is the formula i need rounded

$w(β€œ#age1”).text = β€œβ€ + (Number($w(β€˜#totalmonths1’).value) /12)

from 1.08333333333 to just 1.08

Hi, Shaneice .

Does replacing the following code:

 $w("#age1").text = "" + (Number($w('#totalmonths1').value) /12) 

with the following code:

 $w("#age1").text = (Number($w('#totalmonths1').value) / 12).toFixed(2).toString();

do what you want?

You might have to remove the extraneous β€œ#age1” (two/2 occurrences) and β€˜#totalmonths1’ (two/2 occurrences) that somehow got included/inserted into my response (which I could not then subsequently edit to remove).

Yes! It worked!!!

I’ve been trying to figure this out for WEEKS!! and you helped in minutes!

I appreciate it @abergquist

quick question if you think you can help?

for future purposes I may need to round up to the nearest tenth

EX: 1.08 rounded up to 1.1

is this possible? Thanks!

You’re welcome!