UNPKG

float-exponent

Version:

Extracts the previous power of 2 floating point number

16 lines (14 loc) 321 B
'use strict' var tape = require('tape') var fltexp = require('../fltexp') tape('fltexp', function(t) { for(var i=-1023; i<=1024; ++i) { var x = Math.pow(2, i) t.equals(fltexp(x), x) for(var j=0; j<10; ++j) { var y = x * (1.0 + 0.5 * Math.random()) t.equals(fltexp(y), x) } } t.end() })