liveBook · Manning

Decimal

A decimal is a base-ten numeric representation or type with defined precision and rounding semantics for decimal-valued arithmetic.

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
Preserves ACH debit and credit totals while moving them through parsing, database storage, APIs, and dashboard calculations.
How deep it goes
Demonstrates string construction, schema fields, API typing, client conversion, and method-based addition; defers Decimal internals.
Examples
Uses ACH file-control debit and credit totals, Decimal('0.1') versus Decimal(0.1), and grouped company batch totals.
What you can do after
Apply it by constructing financial values from strings and adding converted debit and credit totals with Decimal methods.

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 →

Related concepts

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.