++ed by:

1 non-PAUSE user.

Martin Becker
and 1 contributors

# NAME

Math::Logic::Ternary::Word - fixed-size ternary information compound

# VERSION

This documentation refers to version 0.004 of Math::Logic::Ternary::Word.

# SYNOPSIS

``````  use Math::Logic::Ternary::Word;

\$a = Math::Logic::Ternary::Word->from_string(9, 'fnttffnnt');
\$a = Math::Logic::Ternary::Word->from_base27(9, 'sea');
\$a = Math::Logic::Ternary::Word->from_int   (9,  -5696);

\$b = \$a->Neg;                         # word +5696
\$c = \$a->Cmp(\$b);                     # trit -1
(\$d, \$e) = \$a->Add(\$b);               # word 0, carry trit 0
(\$f, \$g) = \$a->Mul(\$b);               # word -6832, word -1648
(\$h, \$i, \$e) = \$f->Div(\$a);           # word +1, word -1136, trit 0
(\$j, \$k, \$l, \$e) = \$f->Ldiv(\$g, \$b);  # word -5696, word 0, word 0, trit 0

@m = \$a->Trits;                       # (true, nil, nil, ..., false)
\$n = \$a->Size;                        # 9

print \$a->as_int;                     # print -5696
print \$b->as_base27;                  # print '%hVZ'
print \$d->as_string;                  # print '@nnnnnnnnn'``````

# DESCRIPTION

## Nomenclature

Method naming conventions for Math::Logic::Ternary::Word are as follows:

Logical operators

Elementary logical operators can be applied in two ways to word objects. Words can be treated as single trits, so that only their truth values (read: signs) are taken into account. Operators with all uppercase names will treat words in this way.

Logical operators spelled all lowercase, on the other hand, will work tritwise on all trits of their operands in parallel. The least significant trit of the result will be the result of the operation on the least significant trits of the operands, and so on up to the most significant trit.

If words of different sizes are mixed in an operation, the leftmost argument determines the word size in which the operation is carried out. Other operands will be padded with nil trits or truncated accordingly, aligned on their least significant end.

Numerical operators

Numerical operators treat their operands as numerical values, which usually means that different trits in multi-trit-words interfere with each other in the course of a computation. Their names are written in mixed case starting with an uppercase letter.

Most numerical and some logical functions have different variants for balanced, unbalanced, and base(-3) arithmetic, where unbalanced also means unsigned. Balanced ternary digits are -1, 0, and 1. Unbalanced base(3) and base(-3) ternary digits are 0, 1, and 2. As balanced ternary numbers are in many cases easier to deal with than unbalanced or negative base numbers, our naming scheme prefers the former, giving balanced arithmetic operators short names, while their unbalanced counterparts get a suffix letter u or U, and base(-3) operators v or V.

Comparison functions

Comparisons are the ultimate challenge of standardizing ternary logic, since there are six ways to assign comparison results to trit values and six ways to order trit values. For three-way comparison results, we continue leaning towards balanced arithmetic and assign -1 (false) to "less than", 0 (nil) to "equal to" and 1 (true) to "greater than". We regard false < nil < true as the "natural" trit order, and nil < true < false as the "unbalanced" order. Again, the latter is flagged with a u or U suffix.

Conversions

Conversions from objects to other data have a name prefix to_ or To_ depending on whether they convert a truth value or a word. The prefix is followed by a name for the data type they yield. If there is an unbalanced or base(-3) variant the final suffix is _u or _v, respectively. Alien type names are always separated by underscores from prefixes and suffixes (if there are any).

Conversions from other data to objects have a name prefix from_ or From_ depending on whether they yield single trits or words, followed by a name for the data type they accept. Again, the unbalanced and base(-3) suffixes are _u and _v, respectively. These constructors are class methods.

Conversions to and from floating point formats are not implemented here. A ternary floating point format with a whole bunch of operations and conversions is defined in the separate module Math::Logic::Ternary::TFP_81.

If an operand size does not match the word size of an operator, it is silently truncated to its least significant trits or padded with leading zeroes as appropriate.

None.

## Complete list of methods

### Logical and tritwise operators

Operators on trits are carried over to word objects in two variants.

Spelled all uppercase they act as pure logical operators, using just the truth values (read: signs) of their arguments and returning a trit.

Spelled all lowercase they act as tritwise operators, performing the logical operation on each trit position of the arguments, and returning a word.

The leftmost argument of a tritwise operator determines the word size of the operation and thus the size of the result. In tritwise operations, all arguments are aligned at the least significant end. Smaller arguments are padded with nil trits and larger arguments are truncated at the other end.

Details about trit operators are documented in Math::Logic::Ternary::Trit.

NIL nil

Nil: Constant nil. No arguments, one result value.

TRUE true

True: Constant true. No arguments, one result value.

FALSE false

False: Constant false. No arguments, one result value.

SN sn

Set to Nil: return nil. One argument, one result value.

ST st

Set to True: return true. One argument, one result value.

SF sf

Set to False: return false. One argument, one result value.

ID id

Identity: return the argument. One argument, one result value.

NOT not

Not. One argument, one result value.

UP up

Up One: increment modulo 3. One argument, one result value.

NUP nup

Not Up: swap nil/false. One argument, one result value.

DN dn

Down One: decrement modulo 3. One argument, one result value.

NDN ndn

Not Down: swap nil/true. One argument, one result value.

EQN eqn

Equal to Nil. One argument, one result value.

EQT eqt

Equal to True. One argument, one result value.

EQF eqf

Equal to False. One argument, one result value.

NEN nen

Not Equal to Nil. One argument, one result value.

NET net

Not Equal to True. One argument, one result value.

NEF nef

Not Equal to False. One argument, one result value.

HM hm

Hamlet: x or not x. One argument, one result value.

UHM uhm

Up & Hamlet. One argument, one result value.

DHM dhm

Down & Hamlet. One argument, one result value.

ORN orn

Or Nil. One argument, one result value.

UORN uorn

Up & Or Nil. One argument, one result value.

DORN dorn

Down & Or Nil. One argument, one result value.

QT qt

Quantum: x and not x. One argument, one result value.

UQT uqt

Up & Quantum. One argument, one result value.

DQT dqt

Down & Quantum. One argument, one result value.

ANN ann

And Nil. One argument, one result value.

UANN uann

Up & And Nil. One argument, one result value.

DANN dann

Down & And Nil. One argument, one result value.

AND and

And. 2 arguments, one result value.

OR or

Or. 2 arguments, one result value.

XOR xor

Exclusive Or. 2 arguments, one result value.

EQV eqv

Equivalent. 2 arguments, one result value.

IMP imp

Implication (x ==> y). 2 arguments, one result value.

REP rep

Replication (x <== y). 2 arguments, one result value.

NAND nand

Not And. 2 arguments, one result value.

NOR nor

Not Or. 2 arguments, one result value.

CMP cmp

Compare (false < nil < true). 2 arguments, one result value.

ASC asc

Ascending (false < nil < true). 2 arguments, one result value.

TLR tlr

The Lesser (false < nil < true). 2 arguments, one result value.

TGR tgr

The Greater (false < nil < true). 2 arguments, one result value.

EQ eq

Equal to. 2 arguments, one result value.

NE ne

Not Equal to. 2 arguments, one result value.

LT lt

Less Than (false < nil < true). 2 arguments, one result value.

GE ge

Greater or Equal (false < nil < true). 2 arguments, one result value.

GT gt

Greater Than (false < nil < true). 2 arguments, one result value.

LE le

Less or Equal (false < nil < true). 2 arguments, one result value.

CMPU cmpu

Compare (unbalanced, nil < true < false). 2 arguments, one result value.

ASCU ascu

Ascending (unbalanced, nil < true < false). 2 arguments, one result value.

TLRU tlru

The Lesser (unbalanced, nil < true < false). 2 arguments, one result value.

TGRU tgru

The Greater (unbalanced, nil < true < false). 2 arguments, one result value.

LTU ltu

Less Than (unbalanced, nil < true < false). 2 arguments, one result value.

GEU geu

Greater or Equal (unbalanced, nil < true < false). 2 arguments, one result value.

GTU gtu

Greater Than (unbalanced, nil < true < false). 2 arguments, one result value.

LEU leu

Less or Equal (unbalanced, nil < true < false). 2 arguments, one result value.

INCR incr

Increment. 2 arguments, one result value.

INCC incc

Increment Carry. 2 arguments, one result value.

INCCU inccu

Increment Carry (unbalanced). 2 arguments, one result value.

INCCV inccv

Increment Carry (negative base). 2 arguments, one result value.

DECR decr

Decrement. 2 arguments, one result value.

DECC decc

Decrement Carry. 2 arguments, one result value.

DECCU deccu

Decrement Carry (unbalanced). 2 arguments, one result value.

DECCV deccv

Decrement Carry (negative base). 2 arguments, one result value.

PTY pty

Parity. 2 arguments, one result value.

DPL dpl

Duplicate. 2 arguments, one result value.

DPLC dplc

Duplication Carry. 2 arguments, one result value.

DPLCU dplcu

Duplication Carry (unbalanced). 2 arguments, one result value.

DPLCV dplcv

Duplication Carry (negative base). 2 arguments, one result value.

NEGCV negcv

Negation Carry (negative base). 2 arguments, one result value.

MULCU mulcu

Multiplication Carry (unbalanced). 2 arguments, one result value.

Addition modulo 3. 3 arguments, one result value.

Addition Carry. 3 arguments, one result value.

Addition Carry (unbalanced). 3 arguments, one result value.

Addition Carry (negative base). 3 arguments, one result value.

Addition Carry (mixed base). 3 arguments, one result value.

SUBT subt

Subtraction. 3 arguments, one result value.

SUBC subc

Subtraction Carry. 3 arguments, one result value.

SUBCU subcu

Subtraction Carry (unbalanced). 3 arguments, one result value.

SUBCV subcv

Subtraction Carry (negative base). 3 arguments, one result value.

CMIN cmin

Ternary Comparison to Minimum. 3 arguments, one result value.

CMED cmed

Ternary Comparison to Median. 3 arguments, one result value.

CMAX cmax

Ternary Comparison to Maximum. 3 arguments, one result value.

CVLD cvld

Ternary Comparison Validation. 3 arguments, one result value.

IPLC iplc

Interpolation Linear Coefficient. 3 arguments, one result value.

IPQC ipqc

Interpolation Quadratic Coefficient. 3 arguments, one result value.

LCO lco

Linear Combination. 3 arguments, one result value.

MIN min

Minimum of Three Values. 3 arguments, one result value.

MED med

Median of Three Values. 3 arguments, one result value.

MAX max

Maximum of Three Values. 3 arguments, one result value.

MINU minu

Minimum of Three Values (unbalanced). 3 arguments, one result value.

MEDU medu

Median of Three Values (unbalanced). 3 arguments, one result value.

MAXU maxu

Maximum of Three Values (unbalanced). 3 arguments, one result value.

SUM sum

Summation. 4 arguments, one result value.

SUMC sumc

Summation Carry. 4 arguments, one result value.

SUMCU sumcu

Summation Carry (unbalanced). 4 arguments, one result value.

MPX mpx

Multiplex: first trit controls which of the other arguments is returned. 4 arguments, one result value.

GENERIC generic

Generic logical and tritwise operators, first argument acts as logical operator name.

### Numerical operators

Addition in balanced, unbalanced, or base(-3) arithmetic. Two operands with optional carry trit, returns value and carry trit.

Asc
Ascu
Ascv

Ascending. Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not nil, result is carry. Otherwise if first operand is less than second operand, result is true. Otherwise if first operand is greater than second operand, result is false. Otherwise result is nil.

Cmp
Cmpu
Cmpv

Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not zero, result is carry. Otherwise if first operand is greater than second operand, result is +1. Otherwise if first operand is less than second operand, result is -1. Otherwise result is zero.

Decr
Decru
Decrv

Decrement operator in balanced, unbalanced or base(-3) arithmetic. One operand with optional carry trit, returns value and carry trit. Carry defaults to one if omitted. The carry is subtracted from the value.

Div
Divu
Divv

Short division operator in balanced, unbalanced or base(-3) arithmetic. Two operands, returns quotient and remainder values and error trit. If the second operand is zero, the error trit is true, otherwise nil.

Dpl
Dplu
Dplv

Duplication operator in balanced, unbalanced or base(-3) arithmetic. One operand with optional carry trit, returns value and carry trit. The operand is multiplied by two.

Ge
Geu
Gev

Greater or equal. Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not nil, result is carry. Otherwise if first operand is not less than second operand, result is true. Otherwise result is false.

Gt
Gtu
Gtv

Greater than. Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not nil, result is carry. Otherwise if first operand is greater than second operand, result is true. Otherwise result is false.

Incr
Incru
Incrv

Increment operator in balanced, unbalanced or base(-3) arithmetic. One operand with optional carry trit, returns value and carry trit. Carry defaults to one if omitted. The carry is added to the value.

Ldiv
Ldivu
Ldivv

Long division operator in balanced, unbalanced or base(-3) arithmetic. Three operands: lower word of first operand, upper word of first operand, second operand. Returns lower and upper word of quotient value, remainder value, and error trit. If the second operand is zero, the error trit is true, otherwise nil.

Le
Leu
Lev

Less or equal. Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not nil, result is carry. Otherwise if first operand is not greater than second operand, result is true. Otherwise result is false.

Lshift

Left shift operator. One operand with optional carry trit, returns value and carry trit. The operand is multiplied by the base and the carry is added. The base is 3 in balanced or unbalanced arithmetic, -3 in base(-3) arithmetic.

Lt
Ltu
Ltv

Less than. Comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands with optional carry trit, returns result trit. If carry is not nil, result is carry. Otherwise if first operand is less than second operand, result is true. Otherwise result is false.

Max
Maxu
Maxv

Maximum. Ternary comparison operator in balanced, unbalanced or base(-3) arithmetic. Three operands, returns the largest of these as result value.

Med
Medu
Medv

Median. Ternary comparison operator in balanced, unbalanced or base(-3) arithmetic. Three operands, returns the second largest of these as result value.

Min
Minu
Minv

Minimum. Ternary comparison operator in balanced, unbalanced or base(-3) arithmetic. Three operands, returns the smallest of these as result value.

Mul
Mulu

Multiplication in balanced or unbalanced arithmetic. Two or three operands, returns lower and upper part of the result value. The optional third operand is added to the multiplication result.

Mulv

Multiplication in base(-3) arithmetic. Two or three operands, returns lower and upper part of the result value and a carry trit. The optional third operand is added to the multiplication result.

Neg

Negation in balanced arithmetic. One operand, one result value. In balanced arithmetic, negation is equivalent to bitwise not.

Negv

Negation in unbalanced arithmetic. One operand with optional carry trit, returns value and carry trit. The operand is multiplied by -1.

Rshift

Right shift operator. One operand with optional carry trit, returns value and carry trit. The operand is divided by the base and the most significant trit is set to the carry. The old least significant trit is returned as new carry. The base is 3 in balanced or unbalanced arithmetic, -3 in base(-3) arithmetic.

Sign
Signu
Signv

Sign operator in balanced, unbalanced or base(-3) arithmetic. One operand, returns sign trit. Note that in unbalanced arithmetic the result can only be nil or true, as all values are representing zero or positive numbers.

Sort2
Sort2u
Sort2v

Binary Sorting operator in balanced, unbalanced or base(-3) arithmetic. Two operands, returns smaller and larger operand.

Sort3
Sort3u
Sort3v

Ternary sorting operator in balanced, unbalanced or base(-3) arithmetic. Three operands, returns smallest, middle and largest operand.

Subt
Subtu
Subtv

Subtraction in balanced, unbalanced, or base(-3) arithmetic. Two operands with optional carry trit, returns value and carry trit.

Sum
Sumu

Three-operand summation in balanced or unbalanced arithmetic. Three operands with optional carry trit, returns value and carry trit. Note that the base(-3) variant is not implemented.

Tgr
Tgru
Tgrv

The greater - binary comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands, returns larger operand.

Tlr
Tlru
Tlrv

The lesser - binary comparison operator in balanced, unbalanced or base(-3) arithmetic. Two operands, returns smaller operand.

### Math::Logic::Ternary::Object Role Methods

Trit

Trit inspection: `\$word->Trit(\$n)` returns trit number `\$n`, 0 indexing the least significant trit.

Trits

Trit inspection: `\$word->Trits` returns a list of precisely n trits for word size n, starting with the least significant trit.

Rtrits

Trit inspection: `\$word->Trits` returns a list of zero up to n trits for word size n, starting with the least significant trit, ending with the most significant non-nil trit.

Sign
Signu
Signv

Numeric sign operator in balanced, unbalanced or base(-3) arithmetic, returns a sign trit. Note that in all variants a return value of true means positive, nil zero and false negative.

as_int

`\$word->as_int` returns the integer number represented by the word in balanced ternary arithmetic. The result will either be a native integer or a Math::BigInt object depending on the word size.

as_int_u

`\$word->as_int_u` returns the integer number represented by the word in unsigned unbalanced ternary arithmetic. The result will either be a native integer or a Math::BigInt object depending on the word size.

as_int_v

`\$word->as_int_v` returns the integer number represented by the word in base(-3) arithmetic. The result will either be a native integer or a Math::BigInt object depending on the word size.

res_mod3

`\$word->res_mod3` returns the least significant trit of the word.

as_string

`\$word->as_string` returns a string of `n` | `t` | `f` characters for all trits in the word including leading zeroes, from most to least significant trit, prepended by an `@` sigil.

is_equal

`\$word->is_equal(\$obj)` returns true if `\$word->Rtrits` and `\$obj->Rtrits` are identical lists, otherwise false. This means that words of different sizes are regarded as equal if they represent equal numeric values.

### Other Object Methods

Mpx

Multiplex. `\$word->Mpx(\$case_n, \$case_t, \$case_f)` with three arbitrary arguments returns `\$case_n` if `\$word` is zero, `\$case_t` if `\$word` is positive, or `\$case_f` if `\$word` is negative. Thus it is equivalent to `\$word->Sign-`Mpx(\$case_n, \$case_t, \$case_f)>.

as_base27

`\$word->as_base27` returns a string of base(27) letters (`_`, lower case `a` up to `m`, upper case `N` up to `Z`) for all groups of three trits in the word including leading zeroes, from most to least significant triplet, prepended by a `%` sigil. The most significant triplet will be taken as zero padded if the word size is not a multiple of three.

Base(27) string representations of words of equal size will sort lexically in the same order as their balanced ternary values sort numerically. Zero values will yield a string of underscore characters, prepended by `%`.

as_modint
as_modint_u
as_modint_v

`\$word->as_modint` converts the numerical value of `\$word` to a Math::ModInt object modulo 3 ** n for words of size n, using balanced arithmetic. The variants as_modint_u and as_modint_v do the same in unbalanced and base(-3) arithmetic.

The Perl extension Math::ModInt (available on CPAN) must be installed for this to work, otherwise as_modint etc. will raise a run-time exception.

### Constructor shortcuts

convert_trits
convert_words
convert_bools
convert_int
convert_int_u
convert_int_v
convert_modint
convert_modint_u
convert_modint_v
convert_base27
convert_string
convert_various

Each of these object methods creates a new word of the same size as its invocant.

`\$word->convert_XXX(@args)` is a shortcut for `Math::Logic::Ternary::Word->from_XXX(\$word->Size, @args)` . See "Constructors", below.

### Splitting

Words

`\$word->Words(\$size)` returns a list of new word objects of the given size, holding all the trits of the invocant, in lowest to highest significance order. This can be used to split a big word into smaller words.

If the desired word size is not a divisor of the original size, some padding nil trits are added at the (most significant) end so that the words returned are all the same size.

### Other object methods

min_int

`\$word->min_int` returns a word representing the smallest integer of the same size as the invocant in balanced ternary arithmetic. This is a word full of false trits.

max_int

`\$word->max_int` returns a word representing the largest integer of the same size as the invocant in balanced ternary arithmetic. This is a word full of true trits.

min_int_u

`\$word->min_int_u` returns a word representing the smallest integer of the same size as the invocant in unbalanced ternary arithmetic. This is a word full of nil trits.

max_int_u

`\$word->max_int_u` returns a word representing the largest integer of the same size as the invocant in unbalanced ternary arithmetic. This is a word full of false trits.

min_int_v

`\$word->min_int_v` returns a word representing the smallest integer of the same size as the invocant in base(-3) ternary arithmetic. This is a word full of alternating nil and false trits, with the least significant trit nil.

max_int_v

`\$word->max_int_v` returns a word representing the largest integer of the same size as the invocant in base(-3) ternary arithmetic. This is a word full of alternating nil and false trits, with the least significant trit false.

## Class methods

### Constructors

Word objects are fixed size containers for trits. All constructors take a size argument and additional information defining those trit values.

The size must be a positive integer. There may be an implementation-specific upper limit for the size. Sizes up to `3 ** 9` should always be valid, though.

from_trits

`Math::Logic::Ternary::Word-`from_trits(\$size, @trits)> creates a new word object of given size from the given trit values.

Trits must be enumerated from lowest to highest significance, without gaps. Trailing (i.e. highly significant) nil trits may be omitted. Trailing superfluous nil trits will be ignored. Non-nil trits beyond the given size will trigger an exception.

from_words

`Math::Logic::Ternary::Word->from_words(\$size, @words)` creates a new word object of given size from trit values taken from the given list of words.

The words may be of any size and must be listed from lowest to highest significance. All of their trits are used.

from_bools

`Math::Logic::Ternary::Word->from_bools(\$size, @bools)` creates a new word object of given size from trit values given as booleans rather than trit objects. Boolean values are taken as nil if undefined, false if defined but false, or true if true.

from_int

`Math::Logic::Ternary::Word->from_int(\$size, \$int)` creates a new word representing the given integer value in balanced arithmetic. If the integer value exceeds the range of the given word size an exception is raised.

from_int_u

`Math::Logic::Ternary::Word->from_int_u(\$size, \$int)` creates a new word representing the given integer value in unbalanced unsigned arithmetic. If the integer value is negative or exceeds the range of the given word size an exception is raised.

from_int_v

`Math::Logic::Ternary::Word->from_int_v(\$size, \$int)` creates a new word representing the given integer value in base(-3) arithmetic. If the integer value exceeds the range of the given word size an exception is raised.

from_base27

`Math::Logic::Ternary::Word->from_base27(\$size, \$string)` creates a new word from a string of base(27) digits (underscore and letters, case not important), given in highest to lowest significance order. If the resulting value exceeds the range of the given word size an exception is raised. See also "as_base27".

from_string

`Math::Logic::Ternary::Word->from_string(\$size, \$string)` creates a new word from a string of ternary digits (`n`, `t`, `f`, case not important), given in highest to lowest significance order. If the resulting value exceeds the range of the given word size an exception is raised.

If the string begins with one of the sigils `%`, `@`, or `\$`, it is interpreted as a base(27) string, ternary digit string, or single ternary digit name, respectively.

If the string is not syntactically correct, an exception is raised.

from_modint

`Math::Logic::Ternary::Word->from_modint(\$size, \$string)` creates a new word from a Math::ModInt object (i.e. a modular integer) representing the same value if interpreted as a balanced ternary number. The modulus must be a power of three. Size can be zero or the base 3 logarithm of the modulus, otherwise an exception will be raised.

from_modint_u

`Math::Logic::Ternary::Word->from_modint_u(\$size, \$string)` creates a new word from a Math::ModInt object (i.e. a modular integer) representing the same value if interpreted as an unsigned ternary number. The modulus must be a power of three. Size can be zero or the base 3 logarithm of the modulus, otherwise an exception will be raised.

from_modint_v

`Math::Logic::Ternary::Word->from_modint_v(\$size, \$string)` creates a new word from a Math::ModInt object (i.e. a modular integer) representing the same value if interpreted as a base(-3) number. The modulus must be a power of three. Size can be zero or the base 3 logarithm of the modulus, otherwise an exception will be raised.

from_various

`Math::Logic::Ternary::Word->from_various(\$size, @args)` creates a new word from its arguments, guided by their type. If the resulting value exceeds the range of the given word size an exception is raised.

If the arguments are word or trit objects, they will be packed into a new word of the given size.

If the argument is a single string of decimal digits, optionally preceded by plus or minus, or it is a single Math::BigInt object, it will be converted as in from_int.

If the argument is a single Math::ModInt object, it will be converted as in from_modint.

If the arguments are plain perl scalars, they will be converted as in from_bools.

If the argument is a single string recognized by as_string, it will be converted accordingly.

### Other class methods

word_operators

`Math::Logic::Ternary::Word->word_operators` returns a list of arrayrefs, each holding an operator signature with five attributes:

`\$name`

Operator method name.

`\$min_args`

Number of mandatory arguments.

`\$var_args`

Number of optional arguments.

`\$ret_vals`

Number of returned values.

`\$is_arith`

Arithmetic type: undef for general operators, 0 for balanced arithmetic, 1 for unbalanced arithmetic, 2 for base(-3) arithmetic.

word_formatters

`Math::Logic::Ternary::Word->word_formatters` returns a list of arrayrefs, each holding a method signature.

These formatters all take no parameters and return a string value. Hence only two attributes are needed to individually describe them:

`\$name`

Formatter method name.

`\$is_arith`

Arithmetic type: undef for general formatters, 0 for balanced arithmetic, 1 for unbalanced arithmetic, 2 for base(-3) arithmetic.

# AGENDA

The range of numeric operators is by no means complete. In particular, conversions supporting input and output for binary architectures will have to be added.

Math::Logic::Ternary - General Information
Math::Logic::Ternary::Trit - Ternary Logical Information Unit
Math::Logic::Ternary::Object - Role providing trit introspection
Math::Logic::Ternary::TFP_81 - 81-Trit Ternary Floating Point
Math::Logic::Ternary::Calculator - Interactive Ternary Calculator

# AUTHOR

Martin Becker <becker-cpan-mp@cozap.com>