signed_overpunch v0.1.0 SignedOverpunch View Source
Module for converting a string in signed overpunch format into the corresponding integer.
Converstion Table:
Code | Digit | Sign |
---|---|---|
} | 0 | − |
J | 1 | − |
K | 2 | − |
L | 3 | − |
M | 4 | − |
N | 5 | − |
O | 6 | − |
P | 7 | − |
Q | 8 | − |
R | 9 | − |
{ | 0 | + |
A | 1 | + |
B | 2 | + |
C | 3 | + |
D | 4 | + |
E | 5 | + |
F | 6 | + |
G | 7 | + |
H | 8 | + |
I | 9 | + |
Link to this section Summary
Functions
Converts a string in signed overpunch format to an integer
Converts a string in signed overpunch format to an integer
Link to this section Functions
Converts a string in signed overpunch format to an integer.
If successful, returns a tuple in the form of {:ok, integer}
. Otherwise, it
returns :error
.
Examples
iex> SignedOverpunch.convert(“100{“)
iex> SignedOverpunch.convert(“100}”)
iex> SignedOverpunch.convert(“00I”)
iex> SignedOverpunch.convert(“000”) :error
iex> SignedOverpunch.convert(“GOTCHA”) :error
Converts a string in signed overpunch format to an integer.
Similar to SignedOverpunch.convert/1
, but raises an ArgumentError if the
input provided is not valid signed overpunch.
Examples
iex> SignedOverpunch.convert!(“100{“) 1000
iex> SignedOverpunch.convert!(“100}”) -1000
iex> SignedOverpunch.convert!(“00I”) 9
iex> SignedOverpunch.convert!(“000”) ** (ArgumentError) invalid signed overpunch
iex> SignedOverpunch.convert!(“GOTCHA”) ** (ArgumentError) invalid signed overpunch