StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
StackGenVis/frontend/node_modules/big-rat/test/num-to-bn.js

33 lines
973 B

4 years ago
var test = require('tape')
var bn = require('bn.js')
var toBN = require('../lib/num-to-bn')
test('simple cases', function(t) {
t.equals(toBN(0).toString(), '0', 'zero')
t.equals(toBN(-1234567).toString(), (new bn(-1234567)).toString(), 'negative')
t.equals(toBN(1234567).toString(), (new bn(1234567)).toString(), 'positive')
t.end()
})
test('powers of 2', function(t) {
for(var i=0; i<1024; ++i) {
var x = Math.pow(2, i)
var y = (new bn(1)).ushln(i)
t.equals(toBN(x).toString(), y.toString())
t.equals(toBN(-x).toString(), y.neg().toString())
}
t.end()
})
test('powers of 2 with 2 bits set', function(t) {
for(var i=52; i<1024; ++i) {
for(var j=1; j<53; ++j) {
var x = Math.pow(2, i) + Math.pow(2, i-j)
var y = (new bn(1)).ushln(i).add((new bn(1)).ushln(i-j))
t.equals(toBN(x).toString(), y.toString(), y.toString())
t.equals(toBN(-x).toString(), y.neg().toString(), y.neg().toString())
}
}
t.end()
})