liveBook · Manning

Number type

As explained in Clojure: The Essential Reference

A numeric type is a type whose values represent numbers with defined precision, range, and arithmetic behavior.

A number type defines the precision and range of numeric values, along with the arithmetic behavior applied to them. Mixed-type operations roughly promote results toward the most precise operand, but exceptions exist. section 5.13

Precision is not merely a size limit: floating-point arithmetic rounds values when finite machine precision cannot represent the exact result. Code that depends on precision should choose its numeric behavior explicitly. section 5.13

Overflowing integer arithmetic

Unchecked operations wrap at the limits of a long. Incrementing 9223372036854775807 produces -9223372036854775808, while decrementing the smallest long produces 9223372036854775807. This behavior can support fixed-width hashing.

How Clojure: The Essential Reference covers it

How deep it goes
Defines precision and contagion, then works through floating-point rounding and fixed-width overflow without detailing every numeric type.
Examples
Demonstrates unchecked operators, long boundary values, floating-point conversion, and a string hash using overflowing arithmetic.
What you can do after
Evaluate numeric behavior and choose explicit precision handling instead of relying on contagion rules.
How it connects
Connects numeric types with arithmetic operators, floating-point arithmetic, type promotion, overflow, and hashing.

Also explained in

Compare how 6 books explain number type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.