liveBook · Manning

Integer division

Integer division is division that produces an integer quotient by discarding the fractional part according to the applicable arithmetic convention.

How 2 Manning books explain it

The Quick Python Book, Fourth Edition

Integer division is division whose result is truncated to an integer value.

How it is used
Uses // in arithmetic expressions when calculations require integer results instead of floating-point division.
How deep it goes
Defines // and demonstrates its output beside / and %, without developing implementation internals.
Examples
Demonstrates 5 / 2, 5 // 2, and 5 % 2 with outputs 2.5, 2, and 1.
What you can do after
Apply integer division via Python's // operator when a calculation must return an integer.

Read how The Quick Python Book, Fourth Edition explains integer division →

Grokking GPU Programming

Integer division is division whose result is an integer obtained by truncating the fractional part of the quotient.

How it is used
Calculates enough CUDA blocks to cover a one-dimensional array, including leftover elements.
How deep it goes
Explains truncation and derives the ceiling-division adjustment with divisible and nondivisible array sizes.
Examples
Uses seven friends sharing four-seat taxis and arrays of 1,000 or 1,024 elements with 256 threads per block.
What you can do after
Apply it via C/C++ arithmetic to calculate a block count that covers every array element.

Read how Grokking GPU Programming explains integer division →

Also covered in

What to know first

Related concepts

Questions about integer division

What is integer division?

Integer division is division that produces an integer quotient by discarding the fractional part according to the applicable arithmetic convention.

Which Manning books explain integer division?

The Quick Python Book, Fourth Edition and Grokking GPU Programming.

What should I know before learning integer division?

Manning books that teach integer division usually introduce operator and size_t first.

What is the difference between integer division and ceiling division?

Integer division is division that produces an integer quotient by discarding the fractional part according to the applicable arithmetic convention. Ceiling division returns the least integer greater than or equal to the exact quotient of two numbers.

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.