Apa v0.6.9 ApaNumber View Source
APA : Arbitrary Precision Arithmetic - internal helper functions - ApaNumber.
Link to this section Summary
Functions
Parses a binary (number string) into an ApaNumber tuple.
This is based on Decimal version of pow10 (cool!!! - is much faster then my version). Extended with :error guard for < 0 - in case that ever happen.
Creates a string from an ApaNumber tuple.
Link to this section Functions
Parses a binary (number string) into an ApaNumber tuple.
It works with signs, leading and trailing zeros and additional chars will be ignored.
If successful, returns a tuple in the form of {integer_value, exponent}
:
ApaNumber.parse("+0003.00e+00000 Dollar") {3, 0}
When the binary cannot be parsed, the atom :error
will be returned.
The limit only depends on the internal integers - because of Elixir "unlimited" integers I would say "arbitrary".
Examples
iex> ApaNumber.parse("0003") {3, 0}
iex> ApaNumber.parse("+0003") {3, 0}
iex> ApaNumber.parse("-0003") {-3, 0}
iex> ApaNumber.parse("-0000120.1200") {-12012, -2}
iex> ApaNumber.parse("-0000120.1200") {-12012, -2}
iex> ApaNumber.parse("-03 Euro") {-3, 0}
iex> ApaNumber.parse("-0003e-2") {-3, -2}
iex> ApaNumber.parse("-3e-0002") {-3, -2}
iex> ApaNumber.parse("3e-12") {3, -12}
iex> ApaNumber.parse("+0003e+12") {3, 12}
iex> ApaNumber.parse("+0003e+00000") {3, 0}
iex> ApaNumber.parse("+0003.00e+00000 Dollar") {3, 0}
This is based on Decimal version of pow10 (cool!!! - is much faster then my version). Extended with :error guard for < 0 - in case that ever happen.
Examples
iex> ApaNumber.pow10(3) 1000
iex> ApaNumber.pow10(0) 1
Creates a string from an ApaNumber tuple.
Examples
iex> ApaNumber.to_string({3, 0}, -1, -1) "3"