float addition precision

JavaScript performance comparison

Revision 5 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var ints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    var floats = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.1];
    var floats2 = [1.1234512345, 2.2234512345, 3.3234512345, 4.4234512345, 5.5234512345, 6.6234512345, 7.7234512345, 8.8234512345, 9.9234512345, 10.10234512345];
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
floats one digit
var sum = 0;
for (var i = 0; i < floats.length; i++) {
  sum += floats[i];
}
pending…
floats five digits
var sum = 0;
for (var i = 0; i < floats2.length; i++) {
  sum += floats2[i];
}
pending…
ints
var sum = 0;
for (var i = 0; i < ints.length; i++) {
  sum += ints[i];
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment