wayfarer wrote:
NZQRC
Integer, Signed, Rational, High-Precision 'point' numbers (or Scientific Notation (OR|| Symbolic Real Numbers)), Complex Numbers
It may help to look at the
number system classifications on Wikipedia. You can, of course, use terms however you like, but using the standard terms in the standard ways will reduce confusion all around.
In math, integers are signed as they go on infinitely in both directions along the number line (except when using modular arithmetic).
ℕ is the "natural" numbers, which have a starting point and go infinitely in one direction. . These may start at 0 or 1, if you're counting them using numerals, or might be counted without numerals at all, as in
Peano numerals (Z, S(Z), S(S(Z)), ...) or
Church encoding.
Typical computer encodings of numbers use modular arithmetic, and it's because of that that you distinguish between signed and unsigned representations: you're trying to save space and time by reducing the range of your numbers to something covering the range you need. (Adding even one bit to your range can, depending on how many bits you already have, double the storage space and more than double the cycles needed to do your arithmetic. This is not necessarily just on byte or word boundaries, either; a system I'm working on uses 14-bit "small" ints because adding a 15th bit would blow up my space and time as above.)
ℝ are the "real" numbers. These do not have inherent precision; the precision, and whether or not you use "scientific notation" (more on this below) are artifacts of your implementation.
Quote:
...the 'Q' numbers are rational and the numerator and denominator should ideally be any other type of number however for simplicity I would say use either an Integer or Signed Int for both...
Actually, it's simpler to use a signed integer for
just one of the numerator or denominator (typically the numerator). If both are signed you then have to deal with calculating the sign based on the two signs in your representation: +/+ and -/- are positive, and +/- and -/+ are negative.
Quote:
...and then you have scientific notation, which while basically a 'float', it is a fixed point number, with an exponent, and these can then be operated on in ways that might be faster than traditional floating point math...
What you've described
is traditional floating point math: a
significand scaled by an integer
exponent of a fixed base. This is not, however, "scientific notation"; whether you choose to represent (i=.123,e=2) as 12.3 or 1.23 × 10² (the latter being scientific notation) is irrelevant to the floating point format. (I understand that this distinction may seem subtle.)
Quote:
...however I think as you move into more symbolic maths, the limitations of storing this number is more obvious; moving to a system where representation is not 'fixed until needed' and 'always exactly predictable to a given place or level of precision' so if you want Pi, you calculate it out from a Unit circle or some other convenient meter...
Or you just do symbolic math and π is π everywhere, including in your output.
You may also find it useful to look at how numeric towers and number systems are dealt with in functional programming languages, which tend to be a little more rigorous about how they set these things up. The
Spire package for Scala is a simpler example, and if you want to get really serious you can look at the various numeric towers available for Haskell, which usually work up to the various sets of operations from basic algebraic structures such as monoids, semigroups, and so on and are very careful (due to the nature of the language) about things like partial functions (such as division). The
Numbers section of the Prelude is what most people use, but
NumHask looks like a good alternative, though I've not investigated it.