Rational number
A rational number is a number expressible as the quotient of two integers, with a nonzero denominator.
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.
Also covered in
What to know first
- integerAn integer is a whole-number value with no fractional part, including negative numbers, zero, and positive numbers.
Related concepts
- real numberkind of · A real number is a value corresponding to a point on the continuous number line, including rational and irrational numbers.
- Numimplements · Num is a type class or interface for types that support basic numeric operations, such as addition and multiplication, and conversion from integer literals.
- normalizationconfigured by · Normalization is the process of transforming or organizing data or representations according to rules to achieve a consistent form, scale, or structure.
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.


