Re: Greatest Common Divisor
От | Vik Fearing |
---|---|
Тема | Re: Greatest Common Divisor |
Дата | |
Msg-id | 535e8b2f-325b-788a-9dd9-58b170f45f98@2ndquadrant.com обсуждение исходный текст |
Ответ на | Re: Greatest Common Divisor (Dean Rasheed <dean.a.rasheed@gmail.com>) |
Ответы |
Re: Greatest Common Divisor
|
Список | pgsql-hackers |
On 04/01/2020 20:08, Dean Rasheed wrote: > On Sat, 4 Jan 2020 at 17:55, Vik Fearing <vik.fearing@2ndquadrant.com> wrote: >> On 04/01/2020 10:37, Dean Rasheed wrote: >>> BTW, there is actually no need to restrict the inputs to integral >>> values because GCD is something that has a perfectly natural extension >>> to floating point inputs (see for example [1]). Moreover, since we >>> already have a mod(numeric, numeric) that works for arbitrary inputs, >>> Euclid's algorithm just works. >>> [...] >>> If it were more work to support non-integer inputs, I'd say that it's >>> not worth the effort, but since it's actually less work to just allow >>> it, then why not? >> >> Okay, I allow that now, but I've still left it for lcm. I can't find >> anything anywhere that defines lcm for floating point (I do find it for >> fractions) and the result of abs(a*b)/gcd(a,b) certainly doesn't match >> "lowest" in the examples I tried. >> > Here's another article on the subject: > https://www.math-only-math.com/hcf-and-lcm-of-decimals.html Yeah, my eyes weren't aligning the decimal points properly. Attached version frees up lcm to work on non-integrals. Thanks for your input! -- Vik Fearing
Вложения
В списке pgsql-hackers по дате отправления: