1
$\begingroup$

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

$\endgroup$

1 Answer 1

0
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ By fractional I mean non-integer. $\endgroup$ Commented Mar 29, 2011 at 12:30
  • $\begingroup$ 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. $\endgroup$ Commented Mar 29, 2011 at 12:35
  • $\begingroup$ You must understand a representation of the "non-integer" before encoding this chosen representation in the lambda calculus. $\endgroup$ Commented Mar 29, 2011 at 12:50
  • $\begingroup$ 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? $\endgroup$ Commented Mar 29, 2011 at 17:07
  • $\begingroup$ 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... $\endgroup$ Commented Mar 29, 2011 at 17:09

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.