Table of Contents

Numeric Types

Numeric types represent Real numbers in a computer. Because computers have limited space, most numeric values are approximations of a real value.

Math in a computer is a combination of a storage of data, and a collection of operators. Interpretation of the bits is up to the operators. When we talk about a type of a number, we are usually referring to the operations we can do on them, rather than the storage.

Here are some Numeric Types that programming languages usually support.

There are many less common types, or types that libraries implement.

As a consequence of their representation, most operations on numeric types are not true to their eponymous mathematical function. For example, adding two Int32 numbers can overflow, resulting in a wrong answer. Also, most floating point operations are not associative: (a + b) + c != a + (b + c). This is usually uncommon enough that it isn't a problem, but care should be taken to programming defensively.

Support in Languages

Java

Main: Java Numeric.