This page is in progress and is the artifact forĀ http://dev.clojure.org/jira/browse/CLJ-718.

Numbers and Math

As of version 1.3, Clojure provides full support for JVM primitive values, making it possible to write high performance, idiomatic Clojure code for numeric applications.

Numeric Types

Literals

It is possible to create most types of numbers as literals directly within Clojure code:

Type

Literal Syntax

Examples

primitive long (decimal)

a number, with no leading zeroes

42

primitive long (octal)

a number with a leading zero

052

primitive long (hexadecimal)

a number prefixed by 0x

0x2A

primitive long (arbitrary base)

base + r + the number

2r101010, 12r36

primitive double (standard notation)

a number containing a decimal point

98.8, 3.3

primitive double (scientific notation)

coefficient + E + sign (optional) + exponent

6.0221479E+23, 6.67428E-11

rational number

number including a slash, with no spaces

1/3, 33/16

fixed point decimal (java.lang.BigDecimal)

number with M suffix

9.99M

big integer (clojure.lang.BigInt)

number with N suffix, or a number too large to fit in a long

42N, 42000000000000000000

Math Operations

TODO: Documentation of math operations, contagion & overflow

Hinting, casting and coercions

TODO: Documentation of autoboxing, type hints on functions, coercion/casting functions

Usage notes

TODO: