// There is NO WARRANTY.
function assert_eq(a: string, b: string) {
- if (a != b) throw('unequal ' + a + ' ' + b);
+ if (a == b) return;
+ console.log(['unequal', a, b]);
+ throw('unequal');
}
-let x = "!0000 ffff_ffff_fff0" as any;
-let y = "!0000 0000_0000_0040" as any;
-let i = Bigfloats.iter_upto(x, y, 4);
+let x : any;
+let y : any
+let i : any
+
+x = "!0000 ffff_ffff_fff0" as any;
+y = "!0000 0000_0000_0040" as any;
+i = Bigfloats.iter_upto(x, y, 4);
assert_eq(i(), "+0000 0000_0000_0000");
assert_eq(i(), "+0000 0000_0000_0010");
assert_eq(i(), "+0000 0000_0000_0020");
assert_eq(i(), "+0000 0000_0000_0030");
+
+x = "!0000 ffff_ffff_fffe" as any;
+y = "!0000 0000_0000_0001" as any;
+i = Bigfloats.iter_upto(x, y, 4);
+
+assert_eq(i(), "!0000 ffff_ffff_ffff 3333_3333_3333");
+assert_eq(i(), "!0000 ffff_ffff_ffff 6666_6666_6666");
+assert_eq(i(), "!0000 ffff_ffff_ffff 9999_9999_9999");
+assert_eq(i(), "!0000 ffff_ffff_ffff cccc_cccc_cccc");
export function pack(v: Unpacked): Packed {
function hex16(x: number) { return ('000' + x.toString(16)).slice(-4); }
function hex48(x: Limb) {
- return (hex16(Math.floor(x / 0x100000000) ) + '_' +
- hex16( (x & 0xffff0000) >> 16 ) + '_' +
- hex16( x & 0x0000ffff ) );
+ return (hex16(Math.floor(x / 0x100000000 ) ) + '_' +
+ hex16( (x >> 16) & 0x0000ffff ) + '_' +
+ hex16( x & 0x0000ffff ) );
}
+//# console.log('pack', v);
return (
(v.sign < 0 ? '!' : '+') +
hex16(v.exponent) + ' ' +
current.limbs.length = i;
current.limbs[i] = 0;
}
+//# console.log('will iter',current,step,avail);
return function() {
i += add_to_limb(current, i, step);
return pack(current);