fix: Solve problem with Big Small substraction#1
Open
Conversation
lbergman
reviewed
Jul 28, 2023
src/thx/bigint/Bigs.hx
Outdated
| // 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. |
Member
There was a problem hiding this comment.
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. |
src/thx/bigint/Bigs.hx
Outdated
Comment on lines
+386
to
+388
| lambda = Math.ceil(BASE / (2 * divisorMostSignificantDigit)), | ||
| remainder:Array<Float> | ||
| = multiplySmall(a, lambda).map(function(v):Float return v), |
Member
There was a problem hiding this comment.
Very wonky formatting. Avoid by using vars instead of long expressions on the same line
src/thx/bigint/Bigs.hx
Outdated
Comment on lines
+441
to
+452
| small: arrayToSmall(remainder), | ||
| big: remainder | ||
| }; | ||
| small: arrayToSmall(remainder), | ||
| big: remainder | ||
| }; |
Member
There was a problem hiding this comment.
Avoid formatting changes when working on 3rd party libs
src/thx/bigint/Bigs.hx
Outdated
| 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; |
Member
There was a problem hiding this comment.
Should contain the actual max int value
lbergman
reviewed
Jul 28, 2023
src/thx/bigint/Bigs.hx
Outdated
| // 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. |
Member
There was a problem hiding this comment.
"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. |
lbergman
approved these changes
Jul 31, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.