Floating-point arithmetic
Floating-point arithmetic is computation using finite-precision representations of real numbers, which can introduce rounding and range errors.
Modern C, Third Edition
A floating-point value is a finite-precision numerical value represented by a sign, an exponent, and a sequence of significand bits.
- How it is used
- Explains why C arithmetic on floating-point types approximates values rather than behaving like exact integer arithmetic.
- How deep it goes
- Derives a simplified binary value from sign, exponent, and precision bits, then identifies type limits and rounding-state constraints.
- Examples
- Uses `0.2F`, `0.2`, and `0.2L` value comparisons plus a sign-and-bits calculation.
- What you can do after
- Evaluate/understand floating-point approximations, inspect type-dependent limits, and choose suitable literals and output formats.
Read how Modern C, Third Edition explains floating-point arithmetic →
Get Programming: Learn to code with Python
A floating-point number is a Python object representing a decimal value using floating-point numeric representation.
- How it is used
- Uses floats to explain numeric types, arithmetic results, and a minutes-to-hours conversion.
- How deep it goes
- Works through conversions and arithmetic, then explains decimal approximation through its effect on a calculation without detailing storage internals.
- Examples
- Shows mixed-type arithmetic, conversion checks, and a 123-minute calculation whose decimal result needs rounding.
- What you can do after
- Practice/perform numeric conversions, predict arithmetic result types, and round a float-based minute calculation when needed.
Read how Get Programming: Learn to code with Python explains floating-point arithmetic →
Rust in Action: Systems programming concepts and techniques
A floating-point type represents real-number values using a finite-precision binary format with sign, exponent, and significand components.
- How it is used
- Uses floating-point values for decimal-looking calculations and as a starting point for a compact numeric format.
- How deep it goes
- Works from literals and comparison hazards down to bit-field extraction, decoding, and reconstruction of an f32 value.
- Examples
- Shows f32 and f64 comparisons of 0.1 + 0.2 with 0.3 and a bit-level round trip of 42.42.
- What you can do after
- Build it from scratch by extracting floating-point fields and using them to design a limited-range, one-byte numeric type.
Modern C
A floating-point value is a value represented approximately by a sign, a significand, and a power-of-two exponent.
- How it is used
- Explains why C arithmetic on real-valued data has limited range and approximate results.
- How deep it goes
- Works through sign, significand bits, exponent, and range macros while leaving exact operational precision platform-dependent.
- Examples
- Calculates -0.15625 from binary significand bits and identifies float.h macros and %g output.
- What you can do after
- Evaluate/understand approximate C results and use %g to print floating-point values when no special format is needed.
Python How-To
A floating-point number is a numeric representation for values that may contain a fractional component and use finite precision.
- How it is used
- Supports numeric comparisons after string input is cast and readable presentation of decimal values.
- How deep it goes
- Works through casting and display formats, but stops short of floating-point representation or arithmetic internals.
- Examples
- Uses a Celsius-temperature exercise, decimal-place output, invalid numeric strings, and JSON numbers.
- What you can do after
- Apply it via Python's float() and f-strings to compare numeric input and display chosen decimal places.
Pandas Workout: 200 exercises to make you a stronger data analyst
Floating-point arithmetic performs numerical calculations using finite-precision representations that can produce small rounding discrepancies.
- How it is used
- Diagnoses tiny discrepancies in pandas averages and guides decisions about rounding or greater numeric precision.
- How deep it goes
- Compares default 64-bit and 128-bit representations, including precision, memory, method compatibility, and portability trade-offs.
- Examples
- Uses taxi-fare averages, sorting-derived subsets, visible decimal discrepancies, and a 128-bit dtype experiment.
- What you can do after
- Diagnose small numerical differences, round readable results, and evaluate whether higher precision justifies its costs.
The Quick Python Book, Fourth Edition
A floating-point number is a numeric value represented using a finite-precision floating-point format.
- How it is used
- Uses floats for fractional arithmetic, division results, scientific-notation values, and numbers converted from strings.
- How deep it goes
- Explains literals, operator results, conversions, and typical machine precision without detailing floating-point representation internals.
- Examples
- Compares 5 / 2 with 5 // 2, converts 200.2 and numeric strings, and calculates an average.
- What you can do after
- Apply float() to convert numeric strings, use / for fractional division, and handle invalid conversions with ValueError.
Read how The Quick Python Book, Fourth Edition explains floating-point arithmetic →
Deep Learning with PyTorch, Second Edition
Numeric values represented approximately in binary floating-point form, used here as the tensor element type for loaded data.
- How it is used
- Represents real-world inputs, learned intermediate features, and neural-network outputs as numeric tensor values.
- How deep it goes
- Defines floating-point representations and compares common precisions, but does not develop floating-point arithmetic internals.
- Examples
- Uses image pixels, learned edges and textures, image structures, and numerical table columns as concrete representations.
- What you can do after
- Understand how PyTorch encodes data and selects float32, float16, or float64 for neural-network computation.
Read how Deep Learning with PyTorch, Second Edition explains floating-point arithmetic →
The Well-Grounded Rubyist, Fourth Edition
Float is Ruby's built-in class for representing finite-precision floating-point numeric values.
- How it is used
- Uses Float values to obtain fractional arithmetic results and represent individual numeric measurements.
- How deep it goes
- Explains Float as an object, demonstrates arithmetic and rounding, and covers permissive versus strict conversion without detailing representation internals.
- Examples
- Demonstrates fractional arithmetic, rounding 99.6, string conversion, and Celsius-to-Fahrenheit temperature conversion.
- What you can do after
- Apply it via Ruby expressions that preserve fractional results, convert input, round values, and calculate temperatures.
Read how The Well-Grounded Rubyist, Fourth Edition explains floating-point arithmetic →
100 C++ Mistakes and How to Avoid Them
A floating-point value is a numeric representation that approximates a real number using a finite-precision significand and exponent.
- How it is used
- Prevents incorrect equality tests and makes numeric conversions explicit in C++ code.
- How deep it goes
- Explains approximation, limited representation, IEEE 754 behavior, and epsilon comparison, without deriving floating-point internals.
- Examples
- Uses 100.0 divided by 3 and Rational values such as 1/3 to expose precision and conversion problems.
- What you can do after
- Diagnose precision-related comparison failures and replace direct equality with an epsilon-based comparison.
Read how 100 C++ Mistakes and How to Avoid Them explains floating-point arithmetic →
Python Workout, Second Edition
float is Python's built-in constructor and conversion function for creating floating-point number objects.
- How it is used
- Deploys floats for fractional measurements, averages, rates, user input, and calculations integrated with other data types.
- How deep it goes
- Explains types, conversions, accumulation, and inexact representation, then defers exact decimal behavior to Decimal.
- Examples
- Uses running-time averages, fractional slicing, Decimal sums, and rainfall values entered through input.
- What you can do after
- Apply it via Python's float constructor to convert numeric input, accumulate fractional values, and calculate averages.
Read how Python Workout, Second Edition explains floating-point arithmetic →
Julia as a Second Language
A floating-point number is a finite-precision numerical representation that stores a sign, significant digits, and an exponent to approximate real values.
- How it is used
- Uses floating-point arithmetic for calculator-style calculations where numerical type, division result, and precision matter.
- How deep it goes
- Works through Julia literals, bit lengths, conversions, division, and rounding, but defers unfamiliar number-type concepts to an appendix.
- Examples
- Shows REPL checks with `typeof`, Float32’s `f0` suffix, mixed-type addition, division, and rounding functions.
- What you can do after
- Practice/perform Julia calculations while choosing floating-point types and selecting division or rounding operations for the desired result.
Read how Julia as a Second Language explains floating-point arithmetic →
Python Workout: 50 ten-minute exercises
A floating-point value is a numeric value represented using a finite-precision significand and exponent, allowing fractional values and a wide magnitude range.
- How it is used
- Supports fractional measurements, averages, reports, indexes, counts, and financial-rate calculations in Python programs.
- How deep it goes
- Explains conversion, accumulation, formatting, and representation error, but stops short of floating-point internals.
- Examples
- Uses run-time averages, invalid-input handling, 0.1 plus 0.7, formatted output, integer cents, and Decimal sums.
- What you can do after
- Apply it via Python's float conversion, averaging, validation, and f-string formatting while recognizing when precision alternatives are needed.
Read how Python Workout: 50 ten-minute exercises explains floating-point arithmetic →
100 Java Mistakes and How to Avoid Them
A floating-point number is a numerical value represented with a significand and an exponent, allowing fractional values and a wide range of magnitudes with finite precision.
- How it is used
- Uses floating-point arithmetic to discuss Java numeric mistakes involving precision, signed zero, widening, and division.
- How deep it goes
- Explains concrete failure modes and prevention rules, but stops short of a general floating-point representation treatment.
- Examples
- Uses signed-zero multiplication, boxed equality, set contents, integer widening, and integer division snippets.
- What you can do after
- Diagnose precision loss and signed-zero surprises, then select explicit conversions, normalization, or higher-precision types.
Read how 100 Java Mistakes and How to Avoid Them explains floating-point arithmetic →
Clojure: The Essential Reference
Floating-point arithmetic is numerical computation using finite-precision representations with a significand and exponent.
- How it is used
- Supports mixed-type numeric comparison and warns when approximate arithmetic is unsuitable for currency.
- How deep it goes
- Explains binary precision, visible rounding propagation, and representation choices, but does not derive floating-point internals.
- Examples
- Uses 0.1, repeated addition, mixed numeric equality, and cross-market order prices.
- What you can do after
- Apply it via Clojure’s == and choose BigDecimal when computations require explicit precision.
Read how Clojure: The Essential Reference explains floating-point arithmetic →
Learn Go with Pocket-Sized Projects
A floating-point number is a numeric value represented using a finite significand and an exponent, allowing a wide range of magnitudes with limited precision.
- How it is used
- Uses floating-point arithmetic for numeric computations while warning against treating results as exact values.
- How deep it goes
- Explains IEEE-754 representation, decimal precision, rounding examples, magnitude loss, tolerance comparisons, and bounded-value validation.
- Examples
- Demonstrates float32 rounding, lost currency subtraction, sin(π), tolerance checking, and bounded currency amounts.
- What you can do after
- Diagnose precision loss in Go and compare computed values with tolerances instead of exact equality.
Read how Learn Go with Pocket-Sized Projects explains floating-point arithmetic →
Math for Web Design
A floating-point number is a finite-precision numerical value represented with a significand and an exponent, allowing fractional quantities and a wide range of magnitudes.
- How it is used
- Explains numerical behavior behind JavaScript calculations used for layout, animation, alignment, snapping, and pricing interfaces.
- How deep it goes
- Explains IEEE 754 storage, repeating binary fractions, rounding, safe integer limits, and tolerance checks without pursuing floating-point internals further.
- Examples
- Uses 0.1 + 0.2, unsafe integer increments, EPSILON comparisons, UI alignment, animation timing, and visual snapping.
- What you can do after
- Diagnose precision-sensitive UI calculations and apply rounding, formatting, safe-integer checks, or EPSILON-based comparisons.
Read how Math for Web Design explains floating-point arithmetic →
100 Go Mistakes and How to Avoid Them
A floating-point number is a finite-precision representation of a real value that uses a significand and exponent and may approximate real arithmetic.
- How it is used
- Diagnoses surprising results when Go programs perform fractional calculations with finite-precision numeric types.
- How deep it goes
- Explains approximation, IEEE-754 fields, and accumulation effects, but stops short of fully explaining decimal conversion.
- Examples
- Uses 1.0001 multiplication, float32 representation, and differently ordered accumulation loops.
- What you can do after
- Evaluate floating-point results while accounting for approximation, representation limits, and operation order.
Read how 100 Go Mistakes and How to Avoid Them explains floating-point arithmetic →
Functional Design and Architecture: Examples in Haskell
A floating-point data type represents approximate real-number values using a finite-precision fractional representation.
- How it is used
- Uses floating-point values for measured domain fields while warning against equality-sensitive database identification.
- How deep it goes
- Explains rounding-related equality failures and database key risks, but does not develop numerical error analysis or alternative comparison algorithms.
- Examples
- Uses meteor coordinates and GHCi comparisons showing different outcomes for decimal additions.
- What you can do after
- Evaluate floating-point fields for persistence and reject them as primary-key components when exact identity is required.
PostgreSQL Mistakes and How to Avoid Them
A floating-point data type stores approximate real-number values using finite binary or decimal precision.
- How it is used
- Warns against using approximate numeric types for currency and against careless data-type mappings during migrations.
- How deep it goes
- Explains approximation and rounding consequences with SQL results, but stops short of floating-point representation internals.
- Examples
- Uses percentage multiplication, a money-column calculation, and cross-database type mappings to expose precision problems.
- What you can do after
- Evaluate monetary schemas and migration mappings, then choose NUMERIC or DECIMAL when exact amounts are required.
Read how PostgreSQL Mistakes and How to Avoid Them explains floating-point arithmetic →
Related concepts
- number typekind of · A number type is a programming-language or data-system type whose values represent numeric quantities and support defined numerical operations.
- integercontrasts with · An integer is a whole-number value with no fractional part, including negative numbers, zero, and positive numbers.
- float64includes · Float64 is a 64-bit floating-point numeric type, commonly represented using the IEEE 754 binary64 format.
- FP32includes · FP32 is the IEEE 754 binary32 single-precision floating-point format, which represents approximate real numbers using 32 bits.
- Decimalalternative to · A decimal is a base-ten numeric representation or type with defined precision and rounding semantics for decimal-valued arithmetic.
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.



















