What numeric types should be provided in a pedagogical programming language? Obviously avoid machine-precision types because those are confusing to a beginner programmer. (Though we might want to provide integers with programmer-configurable arbitrary bounds with automatic bounds checking.)
Arbitrary precision integers.
Arbitrary precision rationals. This makes division closed.
Fixed-precision decimal real types (programmer-specifiable amount of precision) with unbounded range. 3 display (printing) options: full precision, show a given number of digits (error to ask for more than full precision), show all but a given number of digits. Showing all but the last two digits is common. Incidentally, because we specify decimal, converting to rational is straightforward without surprises.
Decimal floating point with programmer-specifiable fixed mantissa precision and unbounded exponent. This is a slightly more advanced feature.
Complex numbers formed of two real numbers. This makes square roots (and all RootOf) closed.
No comments :
Post a Comment