wip
This commit is contained in:
parent
c3c5968749
commit
c5a62cfa1d
3 changed files with 95 additions and 5 deletions
13
fixed.js
13
fixed.js
|
|
@ -17,11 +17,11 @@ let bytes = Math.ceil(bits / 8) * entries;
|
|||
let epsilonBits = 1 ;
|
||||
let epsilon = 2 ** epsilonBits;
|
||||
|
||||
function toFixed(float) {
|
||||
export function toFixed(float) {
|
||||
return Math.round(float * base);
|
||||
}
|
||||
|
||||
function toFloat(fixed) {
|
||||
export function toFloat(fixed) {
|
||||
return fixed / base;
|
||||
}
|
||||
|
||||
|
|
@ -48,12 +48,12 @@ for (let i = 0; i < entries * 2; i++) {
|
|||
|
||||
|
||||
// returns fixed point
|
||||
function log2(fixed) {
|
||||
export function log2(fixed) {
|
||||
return enloggen[toIndex(fixed)];
|
||||
}
|
||||
|
||||
// returns rounded integer
|
||||
function pow2(fixed) {
|
||||
export function pow2(fixed) {
|
||||
let n = toIndex(fixed);
|
||||
if (n > empower.length) {
|
||||
n = empower.length - 1;
|
||||
|
|
@ -61,7 +61,7 @@ function pow2(fixed) {
|
|||
return empower[entries + n];
|
||||
}
|
||||
|
||||
function mul(a, b) {
|
||||
export function mul(a, b) {
|
||||
if (a == 0) return 0;
|
||||
if (b == 0) return 0;
|
||||
let la = log2(a)|0;
|
||||
|
|
@ -93,6 +93,7 @@ for (let i = 0; i < powEntries; i++) {
|
|||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// now just try multipling numbers
|
||||
let deltas = 0;
|
||||
let deltaAvg = 0;
|
||||
|
|
@ -153,3 +154,5 @@ for (let i = 0; i < enloggen.length; i++) {
|
|||
m = Math.max(m, enloggen[i]);
|
||||
}
|
||||
console.log(`max enloggen entry is ${m}`);
|
||||
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue