Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
By fractional I mean non-integer. –  Anonymous Mar 29 '11 at 12:30
    
Then you could search for how people do "exact real arithmetic", e.g haskell.org/haskellwiki/Exact_real_arithmetic , or search for 'interval "exact real"', etc. –  Chris Kuklewicz Mar 29 '11 at 12:35
    
You must understand a representation of the "non-integer" before encoding this chosen representation in the lambda calculus. –  Chris Kuklewicz Mar 29 '11 at 12:50
    
I do, but it should be coded so it's as practical as possible. For example, church numerals are encoded as iteration. That's a generic and practical way of encoding them. What would be a generic and practical way of encoding non-integer numbers? –  Anonymous Mar 29 '11 at 17:07
    
Perhaps you have a way to encode pairs, this leads to a way to encode a lazy list, which leads to a lazy list of decimal digits... –  Chris Kuklewicz Mar 29 '11 at 17:09
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.