File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Zero } from "../fixedPoint/index.js";
33import { type Hex , type HexLike } from "../hex/index.js" ;
44import { mol } from "../molecule/index.js" ;
55import { numFrom , NumLike , type Num } from "../num/index.js" ;
6+ import { gcd } from "../utils/index.js" ;
67
78/**
89 * @deprecated use `Epoch.from` instead
@@ -293,19 +294,3 @@ export class Epoch extends mol.Entity.Base<EpochLike, Epoch>() {
293294 * 4 hours * 60 minutes per hour * 60 seconds per minute * 1000 milliseconds per second.
294295 */
295296const epochInMilliseconds = numFrom ( 14400000 ) ; // (Number.isSafeInteger(14400000) === true)
296-
297- /**
298- * Calculate the greatest common divisor (GCD) of two Num values using the Euclidean algorithm.
299- *
300- * @param a - First operand.
301- * @param b - Second operand.
302- * @returns GCD(a, b) as a Num.
303- */
304- function gcd ( a : Num , b : Num ) : Num {
305- a = a < Zero ? - a : a ;
306- b = b < Zero ? - b : b ;
307- while ( b !== Zero ) {
308- [ a , b ] = [ b , a % b ] ;
309- }
310- return a ;
311- }
Original file line number Diff line number Diff line change 1- import { NumLike , numFrom , numToHex } from "../num/index.js" ;
1+ import { Zero } from "../fixedPoint/index.js" ;
2+ import { NumLike , numFrom , numToHex , type Num } from "../num/index.js" ;
23
34/**
45 * A type safe way to apply a transformer on a value if it's not empty.
@@ -264,3 +265,19 @@ export function stringify(val: unknown) {
264265 return value ;
265266 } ) ;
266267}
268+
269+ /**
270+ * Calculate the greatest common divisor (GCD) of two Num values using the Euclidean algorithm.
271+ *
272+ * @param a - First operand.
273+ * @param b - Second operand.
274+ * @returns GCD(a, b) as a Num.
275+ */
276+ export function gcd ( a : Num , b : Num ) : Num {
277+ a = a < Zero ? - a : a ;
278+ b = b < Zero ? - b : b ;
279+ while ( b !== Zero ) {
280+ [ a , b ] = [ b , a % b ] ;
281+ }
282+ return a ;
283+ }
You can’t perform that action at this time.
0 commit comments