Improve gcd function

Issue #848 new
Pol Welter created an issue

Currently the gcd (greatest common divisor) function does not accept fractional numbers or quantities with a dimension.

Today I found myself in a situation where I wanted to determine the smallest time commensurate with two given frequencies. I.e., I wanted to evaluate

1 / gcd(112.5 mega hertz; 100 mega hertz)

which is not allowed. (By the way, the answer is 80 ns.)

Now, I agree that gcd for fractional numbers is both conceptually weird, and possibly tricky to implement. Just wanted to point out that there are real applications for such a feature.

On a somewhat related note: There is no lcm function. The docs for gcd literally give a complete and ready-to-use implementation for lcm. Maybe it should just be built-in...

Comments (1)

  1. Helder Correia repo owner

    On a somewhat related note: There is no lcm function. The docs for gcd literally give a complete and ready-to-use implementation for lcm. Maybe it should just be built-in...

    Issue #861.

  2. Log in to comment