definitely too long :D
This commit is contained in:
parent
fe23193ce9
commit
badc730f2b
1 changed files with 9 additions and 4 deletions
13
silly.js
13
silly.js
|
@ -55,10 +55,14 @@ function log2(val) {
|
||||||
// returns rounded integer
|
// returns rounded integer
|
||||||
function pow2(fixed) {
|
function pow2(fixed) {
|
||||||
let n = fixed >> reduction;
|
let n = fixed >> reduction;
|
||||||
if (empower[n] == undefined) {
|
if (n >= empower.length) {
|
||||||
console.log(`float ${toFloat(fixed)} fixed ${fixed} n ${n} max ${empower.length}`);
|
/*
|
||||||
|
console.log(`ERROR float ${toFloat(fixed)} fixed ${fixed} n ${n} max ${empower.length}`);
|
||||||
|
|
||||||
//throw new Error('whoops');
|
throw new Error('whoops');
|
||||||
|
*/
|
||||||
|
// Overflow? Round down.
|
||||||
|
return empower[empower.length - 1];
|
||||||
}
|
}
|
||||||
return empower[n];
|
return empower[n];
|
||||||
}
|
}
|
||||||
|
@ -76,6 +80,7 @@ function mul(a, b) {
|
||||||
return pow2(la + lb);
|
return pow2(la + lb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (let i = 0; i < logEntries; i++) {
|
for (let i = 0; i < logEntries; i++) {
|
||||||
let l = log2(i);
|
let l = log2(i);
|
||||||
let p = pow2(l);
|
let p = pow2(l);
|
||||||
|
@ -92,7 +97,7 @@ for (let i = 0; i < powEntries; i++) {
|
||||||
let val = pow2(fixed);
|
let val = pow2(fixed);
|
||||||
console.log(`${i} ${fixed} ${float} ${val}`)
|
console.log(`${i} ${fixed} ${float} ${val}`)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// now just try multipling numbers
|
// now just try multipling numbers
|
||||||
let deltas = 0;
|
let deltas = 0;
|
||||||
|
|
Loading…
Reference in a new issue