Search code examples
language-design

Programming language without integer type


What would be shortcomings of a language without integer type (only float)? Which of them will be very serious or unsolvable? Suppose compiler is sufficiently smart to print rounded number when it knows, that this number is really integer. Was such idea discussed in scientific papers or implemented in some language (I cannot find neither).


Solution

  • Javascript is such a language: all numbers are double-precision (64-bit) floating point. There are a number of unfortunate consequences of this design choice, but clearly the result can be made to work...

    Note that double-precision floating point can precisely represent integers of up to 53 bits. So, it can be more practical than you might think to use it as an integer-substitute.