function number_good_view(user_num, after_point){ if ((user_num-Math.floor(user_num))>0){ //если есть дробная часть user_num=user_num.toFixed(after_point).replace(/0+$/,""); } return user_num; } alert( number_good_view(0.000000006000, 10));