1

Some programing languages, notably Pascal, have a type of numbers called "real".

However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to represent any real number. Real numbers like 1/3 and irrationals, however, can't be represented in floating point. So why do some programing languages call these types "real"?

  • 1
    Real numbers were introduced as distinct from integer numbers. Both Algol and Fortran pre-date Pascal and use "real" to mean non-integers. – BobDalgleish Jul 18 '14 at 14:35
  • 2
    The int type doesn't really denote integers in most languages either. The use of unsigned int instead of nat or natural is a bit perplexing though. – Doval Jul 18 '14 at 14:39
  • 3
    Many languages also habe a type called "integer" which cannot represent all integers. – Jörg W Mittag Jul 18 '14 at 14:47
  • Calling them rational would lead to the expectation that exact rational arithmetic could be performed. – AakashM Jul 18 '14 at 15:04
  • 1
    I think you have the question backwards. At a time when most of the existing languages were using "real" to mean floating-point (as opposed to integer), C chose to use "float" instead of "real". Your question could just as easily, and more correctly IMHO, be stated as "Why does C (and its derivatives) use "float" instead of "real" to denote (machine-approximate, i.e., floating-point) real numbers?". – John R. Strohm Jul 18 '14 at 16:18
5

Short answer: because it is the default approximation of a real number the language in question provides.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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