Euphoria
Ticket #765:
The gcd() function returns the wrong value when any argument is zero.
-
Reported by
DerekParnell
May 07, 2012
Currently, the function returns zero when either of the two argument values is zero. It should be returning 0 if both arguments are zero, and if one argument is zero, the other argument (floor(abs(X))) should be returned.
Details
1. Comment by jimcbrown
May 07, 2012
See: hg:euphoria/rev/22be357f99ac
changeset: 5557:22be357f99ac branch: 4.0 tag: tip user: Jim C. Brown date: Mon May 07 10:12:45 2012 -0400 files: include/std/math.e description:
- gcd() return the other number if one of the integers is equal to zero, and only returns zerow hen both are zero.
- fixes ticket:765
2. Comment by jimcbrown
May 07, 2012
See: hg:euphoria/rev/703bfe9a2635
changeset: 5558:703bfe9a2635 tag: tip parent: 5551:a224598996c1 user: Jim C. Brown date: Mon May 07 10:15:59 2012 -0400 files: include/std/math.e description:
- merge 4.0 fix in
- fixes ticket:765
3. Comment by DerekParnell
May 07, 2012
Sorry Jim, but that doesn't fix it. Now gcd(1,X) always returns X instead of 1. Also the comments need fixing and we need to add some test cases. My changes will follow shortly.
4. Comment by DerekParnell
May 07, 2012
See: hg:euphoria/rev/4abc18d01dc3
changeset: 5559:4abc18d01dc3 branch: 4.0 tag: tip parent: 5557:22be357f99ac user: Derek Parnell <owner@derekparnell.id.au> date: Tue May 08 01:05:07 2012 +1000 files: include/std/math.e tests/t_math.e description: fixes ticket:765. gcd() now returns correct values.
5. Comment by jimcbrown
May 07, 2012
Oops. Thanks, Derek.
I was surprised at how easy the fix was. Now I know why.