Skip to content

Commit e474db8

Browse files
feat(Epoch): extend gcd for negatives
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent f77be5f commit e474db8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/core/src/ckb/epoch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ const epochInMilliseconds = numFrom(14400000); // (Number.isSafeInteger(14400000
302302
* @returns GCD(a, b) as a Num.
303303
*/
304304
function gcd(a: Num, b: Num): Num {
305+
a = a < Zero ? -a : a;
306+
b = b < Zero ? -b : b;
305307
while (b !== Zero) {
306308
[a, b] = [b, a % b];
307309
}

0 commit comments

Comments
 (0)