absolute-int

Benchmark created by Gary Chisholm on


Description

What's the fastest way of getting the absolute value of a negative integer

Setup

var i = -5;

Test runner

Ready to run.

Testing in
TestOps/sec
tilde
~i+1;
ready
Math
Math.abs(i);
ready
timesequals
i*=-1;
ready

Revisions

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