Notes on Prime Numbers
  • Introduction
  • Revision History
  • What Do You Mean Large
  • Enter bc
  • Pi with bc
  • C++
  • Ramanujan's constant
  • The Largest Known Prime
  • The Golden Ratio
  • Random Numbers
Powered by GitBook
On this page
  • Native Numbers
  • Traps

Was this helpful?

What Do You Mean Large

PreviousRevision HistoryNextEnter bc

Last updated 5 years ago

Was this helpful?

Large numbers generally means number with a great many digits. These are not native machine datatypes and depend on [arbitrary precision arithmetic] () packages.

Native Numbers

Modern CPUs support integers, unsigned integers, and IEEE-475 [floating point]( numbers that provide:

  • half precision (3 sig figs)

  • single precision (7 sig figs)

  • double precision (16 sig figs)

  • extended precision (19 sig figs)

  • quadruplel precision (34 sig figs)

For computational speed, if native numbers are suitable, one would use them.

Note that the normal add, subtract, multiply and divide arithmetic operators are natively available, depending on the CPU, OS, and the language. In practice one needs a library of functions with the corresponding precision.

Traps

In the course of doing floating point arithmetic, it is possible that calculations will overflow or underflow. Assigning a high precision format variable to a lower precision variable will cause a loss of significance. Assigning a low precision number variable to a high precision variable number will generate gargage digits.

Also, a double precision number may be too large to be represented by a lower precision variable, resulting in an error condition.

IEEE 754 specifies five arithmetic exceptions that are to be recorded in the status flags ("sticky bits"):

  • inexact, set if the rounded (and returned) value is different from the mathematically exact result of the operation.

  • underflow, set if the rounded value is tiny (as specified in IEEE 754) and inexact (or maybe limited to if it has denormalization loss, as per the 1984 version of IEEE 754), returning a subnormal value including the zeros.

  • overflow, set if the absolute value of the rounded value is too large to be represented. An infinity or maximal finite value is returned, depending on which rounding is used.

  • divide-by-zero, set if the result is infinite given finite operands, returning an infinity, either +∞ or −∞.

  • invalid, set if a real-valued result cannot be returned e.g. sqrt(−1) or 0/0, returning a quiet NaN.

Unhandled trap exceptions in non-IEEE-754 are not supposed to happen. Other numerical systems might. Threfore in embedded systems or in space systems, one must pay close attentions to the numerics involved.

https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic
https://en.wikipedia.org/wiki/Floating_point
How Java’s Floating-Point Hurts Everyone Everywhere