3. Defining a Pure Numeric Data Type

3.1. What does “pure numeric” mean?

A pure numeric data item doesn’t represent an object in the real world. It’s an abstract, mathematical entity.

Some pure numeric data types are built into our programming languages. Java calls them “primitive types.” C supports integers (short, int, long) and real number approximations (float, double). C++ and Java inherit those built-in types from C with minor variations.

However, none of these languages supports such mathematical quantities as complex numbers, rational numbers, fixed-point numbers, transfinite numbers, or numbers of arbitrary precision.1 If we need to use such numbers, we must construct them ourselves using OOP’s class definition mechanism (or find a ...

Get Object-Oriented Computation in C++ and Java: A Practical Guide to Design Patterns for Object-Oriented Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.