liveBook · Manning

Number rounding

Also called round

Number rounding replaces a numerical value with a nearby value at a specified precision according to a rounding rule.

How 7 Manning books explain it

JavaScript in Depth

The process of approximating a numeric value to a nearby representable value.

How it is used
Explains surprising arithmetic results and distinguishes representational rounding from integer-rounding operations.
How deep it goes
Works through exponent alignment, binary addition, normalization, and fitting the result into 52 significand bits.
Examples
Uses `0.1 + 0.2`, stored binary patterns, `Number.EPSILON`, and `Math.round`, `Math.floor`, and `Math.ceil`.
What you can do after
Diagnose/debug with it when decimal-looking arithmetic yields a nearby, unexpected value.

Read how JavaScript in Depth explains number rounding →

Quantization and Fast Inference

Rounding maps a numerical value to a nearby representable value according to a specified tie-breaking or directional rule.

How it is used
Uses rounding to map values onto quantization grids and return fixed-point products to their target format.
How deep it goes
Works through grid error and shift-based rounding, while identifying framework tie-breaking differences without specifying a universal rule.
Examples
Walks through uint8 ReLU quantization and Q3.4 multiplication, including reconstruction and rounding bias.
What you can do after
Diagnose/debug rounding error and distinguish it from clipping when comparing quantized results.

Read how Quantization and Fast Inference explains number rounding →

Math for Web Design

A rounding strategy specifies how a numerical value is selected when rounding it to an interval.

How it is used
Selects practical values for pixel layouts, responsive typography, currency displays, and progress indicators.
How deep it goes
Defines four JavaScript whole-number behaviors and four CSS strategies, including negative values and CSS intervals, then demonstrates display formatting.
Examples
Uses three-column widths, two-decimal prices, whole-number progress percentages, and CSS widths rounded to 10px intervals.
What you can do after
Apply it via JavaScript Math methods and CSS round() to choose whole-number or interval-based results for frontend calculations.

Read how Math for Web Design explains number rounding →

Get Programming: Learn to code with Python

A Python built-in function that returns a number rounded to a specified precision or to the nearest whole-number value by default.

How it is used
Uses round() to turn decimal calculation results into practical whole-minute values.
How deep it goes
Explains the call through a worked conversion and floating-point rationale, but does not develop broader rounding rules.
Examples
Demonstrates round() while converting 123 minutes into 2 hours and 3 minutes.
What you can do after
Apply round() to correct small floating-point discrepancies when a calculation should produce a whole-number result.

Read how Get Programming: Learn to code with Python explains number rounding →

100 C++ Mistakes and How to Avoid Them

How it is used
Uses integer-conversion choices to avoid incorrect results when a calculation requires a particular direction.
How deep it goes
Compares four conversion results with examples but does not detail their implementation.
Examples
Compares conversions for positive and negative decimals and relates them to packing boxes and debt.
What you can do after
Evaluate which conversion function fits a desired integer result.

Read how 100 C++ Mistakes and How to Avoid Them explains number rounding →

Learn Haskell by Example

round is a Haskell function that converts a fractional value to the nearest integral value according to its rounding rules.

How it is used
Converts fractional audio calculations into integer sample counts required by signal-processing code.
How deep it goes
Defines the RealFrac-to-Integral type relationship and demonstrates round in sample-count helpers and GHCi.
Examples
Uses audio sample-rate helpers and round (3.1415 :: Double) :: Integer as concrete examples.
What you can do after
Apply round to convert floating-point calculations into values with an Integral result type.

Read how Learn Haskell by Example explains number rounding →

Clojure: The Essential Reference

Numeric rounding is the approximation of a value to the finite precision available in its numerical representation.

How it is used
Controls numerical precision explicitly in BigDecimal calculations and floating-point-sensitive code.
How deep it goes
Defines precision, rounding modes, numeric contagion, exceptions, and financial examples without developing rounding internals.
Examples
Demonstrates 22/7, floating-point subtraction error, and share-price calculations with explicit rounding.
What you can do after
Apply it via with-precision to choose precision and rounding behavior for BigDecimal expressions.

Read how Clojure: The Essential Reference explains number rounding →

Also covered in

What to know first

Related concepts

Questions about number rounding

What is number rounding?

Number rounding replaces a numerical value with a nearby value at a specified precision according to a rounding rule.

Which Manning books explain number rounding?

JavaScript in Depth, Quantization and Fast Inference, Math for Web Design, Get Programming: Learn to code with Python, 100 C++ Mistakes and How to Avoid Them, Learn Haskell by Example and Clojure: The Essential Reference.

What should I know before learning number rounding?

Manning books that teach number rounding usually introduce integer, floating-point arithmetic, sum and float64 first.

What kinds of number rounding are there?

Kinds of number rounding include banker's rounding.

What is number rounding a kind of?

Number rounding is a kind of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.

What is number rounding part of?

Number rounding is part of card game. A card game is a game played with cards according to rules governing their distribution, use, values, and outcomes.

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.