9.1. Using Platform-Specific Datatypes

Integers are typically supported by providing types with various ranges. For instance, the programming language Java supports two different integer types (int and long), while the MySQL DBMS supports five different integer types (TINYINT, SMALLINT, MEDIUMINT, INT and BIGINT).

The mathematical concept of decimal numbers is often supported in the form of two different kinds of computational number types:

  1. floating point numbers, represented with base 2, typically called FLOAT or DOUBLE, which are appropriate for calculations where approximate results are acceptable, and
  2. arbitrary-precision numbers, represented with base 10, typically called DECIMAL, which are appropriate for currency amounts and financial calculations in business apps.

Certain decimal numbers can't be exactly represented as machine numbers with base-2. For instance, the decimal number 0.1 can't, and so we get results like 1.0 - 0.1 = 0.8999999. FLOAT often denotes a floating point number type with a smaller range (typically represented with 4 Bytes), while DOUBLE allows floating point numbers with a double size (typically represented with 8 Bytes).