How to roung a float number

i have doing a cash register program and i came up with a problems of Penny 0.01
lets say i have given a penny 0.03999779 when i try

let a=0.03999779
Math.round(a)

returns 0 but i want to return

0.04

Hello @kumenger;

Use this

parseFloat(a).toFixed(2);

It will return 0.04

1 Like

A good link about this topic here:


Use Math.round(num * 100) / 100 or Math.round((num + 0.00001) * 100) / 100

1 Like