Erlang Central

Category:NumberRecipes

Revision as of 22:59, 3 September 2006 by Bfulgham (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

Numbers are basic to just about any computation. They're used for array indexes, temperatures, salaries, and an infinite variety of things. Yet they're not as simple as they seem. With floating-point numbers, how accurate is accurate? With random numbers, how random is random? With strings that should contain a number, what actually constitutes a number?.

It is important to distinguish between the mathematical numbers, the Erlang numbers that attempt to model them, the machine representations used to implement the Erlang numbers, and notations used to write numbers. We uses the types number, complex, real, rational, and integer to refer to both mathematical numbers and Erlang numbers. Machine representations such as fixed point and floating point are referred to by names such as fixnum and flonum.

Erlang's numerical operations treat numbers as abstract data, as independent of their representation as possible. Although an implementation of Erlang may use fixnum, flonum, and perhaps other representations for numbers, this should not be apparent to a casual programmer writing simple programs.