How are fractional numbers most effectively encoded in lambda calculus?

649 Views Asked by At

I haven't been able to find any information on this, but I think that if someone knows it, it's someone here. I need it for some theoretical knowledge about lambda calculus and compiler optimizations. I'm sorry if this is the wrong stackexchange site, I have been told to go here by some people at stackoverflow.com

1

There are 1 best solutions below

6
On BEST ANSWER

If you want to encode arbitrary fractions then a common choice is as a ratio of two arbitrary integers: numerator and denominator. In this case one would keep always cancel the gcd of the two integers to keep it in a simple form. One can keep denominator positive and the sign with the numerator or one can split the sign out and have a triple of (sign,numerator,denominator), in which case the numerator and denominator are natural numbers (though try not to divide by zero...)

If by fractional you mean "non-integer" real number then other choices might be a continued fraction representation, or some successive interval approximation, or even a lazy stream of digits.