Skip to content

fix: Solve problem with Big Small substraction#1

Open
tkwiatek wants to merge 5 commits intomasterfrom
substract-fix
Open

fix: Solve problem with Big Small substraction#1
tkwiatek wants to merge 5 commits intomasterfrom
substract-fix

Conversation

@tkwiatek
Copy link
Copy Markdown

No description provided.

// Chrome resolves -1 % 1 to -0 and -0 < 0 == true, Std.int fixes this with -0 | 0 = 0
remainder = Std.int(difference % BASE);
r[i] = difference < -BASE ? (remainder < 0 ? remainder + BASE : remainder) : difference;
// Code below normalize result. Returns always integer in range [0, BASE) even for negative input.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Code below normalize result. Returns always integer in range [0, BASE) even for negative input.
// Code below normalize result. Returns always integer in range [0, BASE] even for negative input.

Comment on lines +386 to +388
lambda = Math.ceil(BASE / (2 * divisorMostSignificantDigit)),
remainder:Array<Float>
= multiplySmall(a, lambda).map(function(v):Float return v),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very wonky formatting. Avoid by using vars instead of long expressions on the same line

Comment on lines +441 to +452
small: arrayToSmall(remainder),
big: remainder
};
small: arrayToSmall(remainder),
big: remainder
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid formatting changes when working on 3rd party libs

inline public static var DOUBLE_BASE = 100000000000000.0; // 1e14
inline public static var LOG_BASE:Int = 7;
public static var MAX_INT(default, null):Int = #if js js.Syntax.code("9007199254740992") #else 2147483647 #end;
public static var MAX_INT(default, null):Int = 10000000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should contain the actual max int value

// Chrome resolves -1 % 1 to -0 and -0 < 0 == true, Std.int fixes this with -0 | 0 = 0
remainder = Std.int(difference % BASE);
r[i] = difference < -BASE ? (remainder < 0 ? remainder + BASE : remainder) : difference;
// Code below normalize result. Returns always integer in range [0, BASE] even for negative input.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Code below" is noise, it is expected that comments refer to the following line. Also "Always returns" not "returns always", and it is not actually a return, but an assignment

Suggested change
// Code below normalize result. Returns always integer in range [0, BASE] even for negative input.
// Normalize to integer in range [0, BASE], even for negative input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants