Skip to content
Andrea Viganò edited this page Jul 7, 2020 · 2 revisions

Welcome

Operations between numbers aren't new, they are normally performed by the language itself, but in the case of mathematically represented real numbers, sometimes it is not possible to perform the operation required without a loss in precision. Normally, this is not a big deal, but with this project our task is to permit a way to represent real numbers and operate with them with no loss in precision.

This is made possible by checking if the operation required can be performed without a precision loss; if that is not the case, the return value of the operation will be a real number storing the information of the operation that should have been performed and the terms involved in that operations. This form of real number is valid and fully operative, meaning you can use it as a normal and 'simple' real number object, permitting the representation of nested structures we see in algebra.

For example, performing: √3 + √2 = 1.73 + 1.41 = 3.14 involve a certain level of approximation, because √3 and √2 are irrational. So, usually in algebra the sum is not performed in the first place, and the number is represented by and expression, in this case, by two terms connected with '+', indicating a sum. So an object which aims to algebraically represent numbers has to permit this kind of representation. The example provided is a simple case, but the expression could also be more complex: if we were to divide the number from the previous example by 2, we obviously would not be able to perform the operation; the number should then have a form like:

√3 + √2
-------  --> 'TrueDiv( Add( Sqr( 3 ), Sqr( 2 ) ), 2 )'
   2

Which presents another level of complexity that has to be handled. Virtually, there is no limit to the amount of complexity you can get to. To project this reality into a computable model, the RN object should be represented in two main forms, strictly related to each other: the 'simple' RN, representable with a single integer, and the more complex ones, which refer to an operation and its terms.

NOTE: in the example above, the numbers √3 and √2 fall into the second category, because their object should reference the square root operation.

Clone this wiki locally