Updated Internals (markdown)

Danila Fedorin 2017-07-26 21:48:59 -07:00
parent cffbf63564
commit 2ac73e3ac8
1 changed files with 1 additions and 1 deletions

@ -1,5 +1,5 @@
# Number Implementation
Abacus, being design with future extensions in mind, does not simply operate on doubles. As other approaches to storing numbers are possible, and it is also possible for the "number" to carry more or less information depending on context, abacus attempts to stay away from a hard-coded implementation. As such, it provides an interface, `NumberInterface`, which is then implemented by an implementation of a number. This interface provides several primitive methods, such as add, subtract, multiply, divide, take to an integer power, etc. The rest of the functions are built on top of these methods, thus being completely implementation-agnostic. This sacrifices speed and prevents abacus from using standard Java library functions like Math.sin, but in exchange allows for the ability to implement the number in many different ways.
Abacus, being designed with future extensions in mind, does not simply operate on doubles. As other approaches to storing numbers are possible, and it is also possible for the "number" to carry more or less information depending on context, abacus attempts to stay away from a hard-coded implementation. As such, it provides an interface, `NumberInterface`, which is then implemented by an implementation of a number. This interface provides several primitive methods, such as add, subtract, multiply, divide, take to an integer power, etc. The rest of the functions are built on top of these methods, thus being completely implementation-agnostic. This sacrifices speed and prevents abacus from using standard Java library functions like Math.sin, but in exchange allows for the ability to implement the number in many different ways.
## Immutability
All the `NumberInterface` implementations are immutable - any operation, such as addition, creates a new copy of the output. This prevents accidental side effects in functions, and removes the need for duplication when returning instances of `NumberInterface` from functions, or storing them as variables.