Number rounding
Number rounding replaces a numerical value with a nearby value at a specified precision according to a rounding rule.
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.
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.
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
- Pandas Workout: 200 exercises to make you a stronger data analyst
- Build Python Web Apps with Streamlit
- Learn SQL in a Month of Lunches
- Statistics Slam Dunk
- Learn Go with Pocket-Sized Projects
- Delivering Machine Learning Projects: From design to deployment
- 100 Java Mistakes and How to Avoid Them
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Learn Rust in a Month of Lunches
- Julia as a Second Language
What to know first
- integerAn integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- floating-point arithmeticFloating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
- float64Float64 is a 64-bit floating-point numeric type, commonly represented by the IEEE 754 binary64 format.
Related concepts
- quantizationused by · Model quantization represents model parameters or computations with reduced-precision numerical values, often to lower storage or computational requirements.
- integerproduces · An integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- card gamepart of · A card game is a game played with cards according to rules governing their distribution, use, values, and outcomes.
- floating-point arithmeticaddresses · Floating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
- functionkind of · 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.
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.






