<script> function fn(a) { a = +("" + a).split(",").join("."); return (a | 0) + +(a - (a | 0)).toFixed(2) }; document.write(fn(35.00005) +'<br>') document.write(fn('35,5265485') +'<br>') </script>