liveBook · Manning

Decimal

Decimal refers to base-ten numeric representation or arithmetic, with precision, scale, and rounding behavior determined by the particular type or system.

How 5 Manning books explain it

Build Financial Software with Generative AI (From Scratch)

Decimal is Python's arbitrary-precision decimal arithmetic type for representing base-ten numbers without the usual binary floating-point approximation.

How it is used
Uses Decimal to handle ACH debit and credit amounts across parsing, API responses, and dashboard calculations.
How deep it goes
Explains construction from strings versus floats and shows financial-field parsing and addition, without detailing Decimal arithmetic internals.
Examples
Uses 0.1 construction comparisons and ACH debit and credit totals extracted from file records.
What you can do after
Apply it via Python's decimal module to construct financial amounts from strings and avoid an intermediate float conversion.

Read how Build Financial Software with Generative AI (From Scratch) explains Decimal →

Grokking Relational Database Design

A DECIMAL data type is an SQL fixed-point numeric type whose precision and scale control the represented number of digits.

How it is used
Stores precise values such as product prices and money amounts in SQL table definitions.
How deep it goes
Explains precision, scale, fixed-point accuracy, and floating-point rounding risks through database and currency examples.
Examples
Uses DECIMAL(5,2) for product prices and contrasts floating-point currency conversion with fixed-point accuracy.
What you can do after
Apply it via CREATE TABLE by specifying total and fractional digit limits for accurate numeric columns.

Read how Grokking Relational Database Design explains Decimal →

PostgreSQL Mistakes and How to Avoid Them

NUMERIC is an exact SQL numeric data type for storing values with specified precision and scale.

How it is used
Uses exact numeric storage for monetary values and other calculations where floating-point approximation is unacceptable.
How deep it goes
Defines NUMERIC and DECIMAL equivalence, explains monetary trade-offs, and warns against cross-database type-name assumptions.
Examples
Contrasts NUMERIC with MONEY and floating-point types, then uses Oracle NUMBER migration as a compatibility example.
What you can do after
Evaluate numeric choices, select NUMERIC for exact amounts, separate currency, and diagnose migration mappings that risk precision loss.

Read how PostgreSQL Mistakes and How to Avoid Them explains Decimal →

ScyllaDB in Action

DECIMAL is a ScyllaDB arbitrary-width decimal data type that represents values precisely.

How it is used
Stores precise decimal or very large numeric values when fixed-width or floating-point types are unsuitable.
How deep it goes
Defines arbitrary width and precision, contrasts rounding risks, and stops short of detailed storage or arithmetic internals.
Examples
Uses monetary values, base-unit integer storage such as cents, and numeric values beyond BIGINT’s range.
What you can do after
Evaluate/understand numeric type choices for accuracy, monetary storage, and unusually large values.

Read how ScyllaDB in Action explains Decimal →

Python Workout: 50 ten-minute exercises

Decimal is a Python numeric class that provides decimal floating-point arithmetic with explicitly represented base-ten values.

How it is used
Uses Decimal for accurate decimal arithmetic, particularly in financial calculations where float inaccuracies matter.
How deep it goes
Demonstrates construction from strings, arithmetic, and conversion to float at the final boundary.
Examples
Uses 0.1 plus 0.2, user-entered decimal strings, and a progressively timed taxation calculation.
What you can do after
Apply it via Python's Decimal class to perform accurate arithmetic and delay conversion to float.

Read how Python Workout: 50 ten-minute exercises explains Decimal →

Also covered in

What to know first

Related concepts

Questions about Decimal

What is Decimal?

Decimal refers to base-ten numeric representation or arithmetic, with precision, scale, and rounding behavior determined by the particular type or system.

Which Manning books explain Decimal?

Build Financial Software with Generative AI (From Scratch), Grokking Relational Database Design, PostgreSQL Mistakes and How to Avoid Them, ScyllaDB in Action and Python Workout: 50 ten-minute exercises.

What should I know before learning Decimal?

Manning books that teach Decimal usually introduce floating-point arithmetic, float64, integer and SQL first.

What is the difference between Decimal and floating-point arithmetic?

Decimal refers to base-ten numeric representation or arithmetic, with precision, scale, and rounding behavior determined by the particular type or system. Floating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.

What is Decimal a kind of?

Decimal is a kind of number type. A numeric type is a type whose values represent numbers with a defined representation and support numerical operations.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.