liveBook · Manning

Rational number

A rational number is a number expressible as the quotient of two integers, with a nonzero denominator.

How 3 Manning books explain it

100 C++ Mistakes and How to Avoid Them

A rational number is a number expressible as a ratio of two integers with a nonzero denominator.

How it is used
Uses rational numbers to demonstrate designing classes as intuitive, reliable data types.
How deep it goes
Examines representation, invariants, invalid states, mutability, arithmetic, and interface design through contrasting implementations.
Examples
Contrasts naïve and corrected C++ Rational class listings, including reduction, addition, multiplication, and output.
What you can do after
Apply integer representation, invariant validation, reduction, and intuitive operators when maintaining a Rational class.

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

Learn Haskell by Example

Rational is a Haskell numeric type representing ratios of integers.

How it is used
Represents exact musical durations and other ratios where floating-point approximation would be less explicit.
How deep it goes
Defines Ratio, its Integral parameter, arithmetic support, and Natural pitfalls, but stops short of broader implementation internals.
Examples
Uses whole, half, quarter, dotted, triplet, and GHCi arithmetic examples for musical note lengths.
What you can do after
Build exact duration values and calculate dotted notes or tuplets with typed ratios.

Read how Learn Haskell by Example explains rational number →

Modern C, Third Edition

A rational number is a number that can be expressed as the quotient of two integers with a nonzero denominator.

How it is used
Uses rational numbers to demonstrate pure functions and value-oriented arithmetic in C.
How deep it goes
Explains representation, equivalent forms, normalization, extension, multiplication, and addition, but does not detail a complete library.
Examples
Uses 6/15 and 2/5, plus C functions for construction, normalization, extension, multiplication, and addition.
What you can do after
Apply rational arithmetic through C functions that construct, normalize, multiply, and add values.

Read how Modern C, Third Edition explains rational number →

Also covered in

What to know first

Related concepts

Questions about rational number

What is rational number?

A rational number is a number expressible as the quotient of two integers, with a nonzero denominator.

Which Manning books explain rational number?

100 C++ Mistakes and How to Avoid Them, Learn Haskell by Example and Modern C, Third Edition.

What should I know before learning rational number?

Manning books that teach rational number usually introduce integer first.

What kinds of rational number are there?

Kinds of rational number include binary fraction.

What is rational number a kind of?

Rational number is a kind of real number. A real number is a value corresponding to a point on the continuous number line, including rational and irrational 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.