M
M
MFilonen22021-11-27 13:05:11
Programming
MFilonen2, 2021-11-27 13:05:11

What are alternative ways to represent numbers in memory?

Any programmer is familiar with integer data types and floating point numbers.
In some cases, such as bookkeeping, decimal numbers are required, and there are also rational numbers in the form of a pair of two integers, numbers of arbitrary size.

But have there been attempts to more accurately convey mathematically exact values, albeit at the cost of losing the speed of calculations? Well, for example, the exact representation of pi as an infinite fraction or something like that? That is, represent numbers as functions, and then operate with such “functions” already according to the rules of ordinary mathematics, with the ability to perform actions on them without the need to immediately calculate the final value ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2021-11-27
@MFilonen2

Yes, a lot of such attempts. GMP and analogues represent numbers in the form of fractions, the number of characters in the numerator and denominator of which is limited only by the amount of RAM
. Symbolic mathematics programs like Maple, Maxima, Octave can store an expression in the form of an analytical notation, that is, they can represent any irrationality exactly (like sqrt (2 ) it is stored as sqrt(2))
For practical engineering calculations, such accuracy is obviously not needed - both float and double are usually enough there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question