﻿Base-X Notation and Tri-Value Logic

American Journal of Computational Mathematics
Vol.2 No.3(2012), Article ID:23221,4 pages DOI:10.4236/ajcm.2012.23033

Base-X Notation and Tri-Value Logic

Xiaolin Li

Department of Mathematics and Computer Science, Alabama State University, Montgomery, USA

Email: xli@alasu.edu

Received April 29, 2012; revised July 3, 2012; accepted July 13, 2012

Keywords: Index Terms—Base-X Notation; Tri-Value Logic

ABSTRACT

This paper introduces the base-X notation and discusses the conversion between numbers of different bases. It also introduces the tri-value logic that is associated with the base-3 system.

1. Introduction

People use decimal numbers in their daily life. However, our computers use the binary system and the binary logic [1-3]. A computer also involves other number systems such as octal numbers and hexadecimal numbers. There is an easy way to convert a number in one system to another using the base-X notation.

2. Base-X Notation

Let X be an integer, X > 1. Using X as the base, we can form a number system. A base-X system uses the digit set {0, 1, ···, X − 1} to constitute a number. Any number Y in the system can be written as: (1)

where m and n are integers, 0 ≤ m <∞, 1 ≤ n < ∞. In the above notation, Yi is the digit at position i and Yi is in {0, 1, ···, X − 1}, −n ≤ i ≤ m. When X = 2, we have the binary system; when X = 8, we have the octal system; when X = 10, we have the decimal system; when X = 16, we have the hexadecimal system.

Let us consider how to convert Y into a decimal number when X ≠ 10. Notice that for each position i, there is an associated weight Xi, and Yi represents a term YiXi. Thus, adding all terms together, we get the corresponding decimal number: (2)

The following examples illustrate the above conversion, where the subscript indicates the base:

1) Binary to Decimal The binary system has the advantage that it uses only two digits: 0 and 1. Within a binary number, digit 0 always represents a zero term while digit 1 always represents a term identical to the weight associated with the digit position. Notice that we have dropped all zero terms in the above summation.

2) Octal to Decimal  The digit set used in the hexadecimal system is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}, where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

3. Decimal to Base-X Conversion

The conversion of a decimal number to a base-X number is also indicated by Equation (2). Given a decimal number Y, we can treat Y as the summation of a sequence of terms where each term is a power of X, then we can write down the corresponding base-X number. For example, given the decimal number 25.625, we have therefore, . In general, one can use the following procedure for the conversion.

Let , where Yi and Yf are the integer portion and fraction portion of Y, respectively. We can convert Yi and Yf separately:

1) Regarding Yi as the initial quotient and dividing the remained quotient by X repeatedly until it becomes zero, we get a sequence of remainder digits, the integer portion of the base-X number then can be obtained by reversing the order of the remainder digits in the sequence;

2) Regarding Yf as the initial fraction and multiplying the remained fraction by X repeatedly, we get a sequence of digits from the integer portion of the products, the fraction portion of the base-X number then can be obtained from this digit sequence.

Consider the decimal number 123.65625 for example, we can convert it into binary, octal and hexadecimal number:

1) Decimal to Binary Integer portion conversion: Fraction portion conversion:  2) Decimal to Octal Integer portion conversion: Fraction portion conversion:  3) Decimal to Hexadecimal Integer portion conversion: Fraction portion conversion:  Notice that in the above conversion, we always get a finite digit sequence for the integer portion because the remained quotient always becomes zero by repeated division. On the other hand, we may get an infinite digit sequence for the fraction portion if the remained fraction never becomes zero through the repeated multiplication. In such a case, it may produce an endless circulate fraction.

For example, .

4. Base-3 System and Tri-Value Logic

Let us consider the base-3 number system that uses the digit set {0, 1, 2} to constitute a number.

Denote T = {0, 1, 2} and let A, B in T, the results of A + B are shown in Table 1.

Consider a tri-value logic associated with the digit set T. Let 0, 1, 2 represent false, true, and neutral (neither false nor true) state, respectively. We can generalize the basic logic operators (logic and), (logic or) and ′(logic not) in Boolean algebra to this tri-value case such that , , and . Let A and B be two variable, A, B in T, then the definition of these generalized logic operators is given in Table 2.

Notice that if we delete all rows that contain state 2 from Table 2, then we get the truth table in Boolean algebra as Table 3.

From Table 2, it is easy to see that the following equalities hold:      It is obvious that the De Morgan’s law and the binary implication can be extended into this tri-value case:   In addition to the above, we can also define other compound logic operators from the basic logic operators , , ', such as the exclusive or operator : 5. Conclusion

In this paper, we have introduced the base-X notation and have discussed the conversion between numbers of different bases. We have also introduced a tri-value logic that is associated with the base-3 system. We have shown that the tri-value logic is compatible with the binary logic, and the De Morgan’s law and the implication rule can be extended into this tri-value case. Here we point out that all base-X systems are equivalent to each other because any number in one system can be uniquely mapped into  Table 2. Tri-value logic. Table 3. Binary logic.

another system as implied by Equation (2). Furthermore, any rational number in one system remains rational in another system because its integer numerator and denominator can be converted into integers in another system as indicated by the integer conversion process.

REFERENCES

1. J. Sanchez and M. P. Canton, “Microcontroller Programming: The Microchip PIC,” CRC Press, Boca Raton, 2006.
2. J. E. Whitesitt, “Boolean Algebra and Its Applications,” Dover Publications, New York, 2010.
3. S. Givant and P. Halmos, “Introduction to Boolean Algebras (Undergraduate Texts in Mathematics),” Springer, New York, 2008.