Number type comparisons

Benchmark created on


Setup

function t(n) {
	if ((n << 24 >> 24) === n) {
		return 'int8'
	}
	
	if ((n & 0xffff00) === 0) {
		return 'uint8';
	}
}

function t2(n) {
	if (n >= -128 && n <= 127) {
	    return 'int8';	
	}
	
	if (n >= 0 && n <= 255) {
		return 'uint8';
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
t1
t(-128)
t(127)
t(255)
t(0)
ready
t2
t2(-128)
t2(127)
t2(255)
t2(0)

ready

Revisions

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