OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Rational Numbers

What Is a Rational Number?

A rational number in our representation consists of the numerator and the denominator. ICE provides price information using numerators only. To get a real price, get the denominator from a product definition and divide the numerator by the denominator. To simplify this, we decided to use our own representation and always keep the denominator together with the numerator.

For more details, please see Rational.

Operations On Rational Numbers

We support only limited operations for rational numbers. There are no arithmetic operations for this class at all. You can only use the following:

  • Create a number.
  • Copy a number.
  • Convert a number to another type (for example, float or double).
  • Compare numbers (==, !=, <, >, <=, >=).
  • Print a number with I/O streams.

Rational Numbers Arithmetic

If you want to perform basic arithmetic on rational numbers, use numerators only and make sure the denominators match. For example, to add two prices represented as rational numbers, create a rational number whose numerator equals the sum of numerators while keeping the denominator the same:

\[ \frac{1}{100} + \frac{2}{100} = \frac{1 + 2}{100} = \frac{3}{100} \]