decimal rounding toFixed vs Math.round (v23)

Revision 23 of this benchmark created by TJKoury on


Setup

var number = 25.5981956;

Test runner

Ready to run.

Testing in
TestOps/sec
toFixed
Number((number).toFixed(1));
ready
Mozilla Test
var precision = 1;
var y = +number + (precision === undefined ? 0.5 : precision/2);
var prx = y - (y % (precision === undefined ? 1 : +precision));
ready
Math.round
Math.round(number * 10) / 10
ready
toFixed string
number.toFixed(1)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published on
  • Revision 2: published on
  • Revision 3: published on
  • Revision 4: published on
  • Revision 5: published on
  • Revision 6: published on
  • Revision 7: published on
  • Revision 8: published on
  • Revision 9: published by Julian Diaz on
  • Revision 10: published on
  • Revision 16: published on
  • Revision 23: published by TJKoury on
  • Revision 27: published by Yanislav Igonin on
  • Revision 31: published by Stephen Irving on
  • Revision 32: published by Stephen Irving on
  • Revision 34: published by Stephen Irving on
  • Revision 45: published by Stephen Irving on
  • Revision 46: published by Stephen Irving on
  • Revision 50: published by Gust van de Wal on
  • Revision 51: published by Kesavamoorthi Subramanian on
  • Revision 52: published by Kesavamoorthi Subramanian on
  • Revision 53: published by Kesavamoorthi Subramanian on
  • Revision 54: published by Kesavamoorthi Subramanian on
  • Revision 55: published by Kesavamoorthi Subramanian on