You treat Int.toLargeas a type, but it is a function. The type you are looking for is IntInf.int. The gcd function will look the same no matter what type of number you put into it; but you may need to access arithmetic operators from another module.
Here's the gcd function for type Int.int:
fun gcd (a, 0) = a
| gcd (a, b) = gcd (b, a - b*(a div b))
And since the SML / NJ arithmetic operators are overloaded, here is one for IntInf.int:
fun gcd (a, 0) = a : IntInf.int
| gcd (a, b) = gcd (b, a - b*(a div b))
source
share