Skip to content

Commit 20958a0

Browse files
committed
Minor cleanup.
1 parent ee0bba3 commit 20958a0

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/bigfloat.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ export class BigFloat {
137137
/** Multiply by an integer and write output limbs to another list. */
138138

139139
private mulInt(factor: number, dstLimbList: number[], srcPos: number, dstPos: number, overwriteMask: number) {
140+
if(!factor) return(0);
141+
140142
let limbList = this.limbList;
141143
let limbCount = limbList.length;
142144
var limb: number;
143145
var lo: number;
144146
let carry = 0;
145147

146-
if(!factor) return(0);
147-
148148
// limbList is an array of 32-bit ints but split here into 16-bit low
149149
// and high words for multiplying by a 32-bit term, so the intermediate
150150
// 48-bit multiplication results fit into 53 bits of IEEE 754 mantissa.
@@ -183,15 +183,11 @@ export class BigFloat {
183183
const limbCount = limbList.length;
184184
let out = new BigFloat();
185185

186-
out.isNegative = this.isNegative ^ factor.isNegative;
187-
188-
let carry: number;
189-
let carryPos = this.limbList.length;
190-
191186
for(let limbNum = 0; limbNum < limbCount; ++limbNum) {
192187
this.mulInt(limbList[limbNum], out.limbList, 0, limbNum, 0xffffffff);
193188
}
194189

190+
out.isNegative = this.isNegative ^ factor.isNegative;
195191
out.fractionLen = this.fractionLen + factor.fractionLen;
196192

197193
return(out);
@@ -323,6 +319,8 @@ export class BigFloat {
323319
return(BigFloat.trim(digitList.join('')));
324320
}
325321

322+
/** Remove leading and trailing insignificant zero digits. */
323+
326324
static trim(str: string) {
327325
return(str
328326
.replace(/^(-?)0+([1-9a-z]|0(\.|$))/, '$1$2')

test/test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const charView = new Uint8Array(buf);
77
const shortView = new Uint16Array(buf);
88
const doubleView = new Float64Array(buf);
99

10-
// var A = new BigFloat(0x27bc04b9253a9);
11-
1210
function randDouble() {
1311
for(let i = 0; i < 4; ++i) {
1412
shortView[i] = ~~(Math.random() * 65536);

0 commit comments

Comments
 (0)