3DSoftware.com > Programming > Integers
Integers  Page 1
 
Variable Length Integers (Symbolic C++)
 
We begin discussion of integers with review of the “Verylong” class in Symbolic C++ 2/e  which implements variable length integers.
 
In that implementation, each integer is a character string. Each character is a decimal (base 10) digit, '0' through '9'. There are more efficient ways to implement very large integers, but the Symbolic C++ implementation is more portable and more illustrative of how large integers work.
 
“some other representations such as binary representation may need some less straightforward algorithm for implementing the arithmetic operations. Since simplicity is one of our primary goals, we choose the decimal representation.” [ 1 ]
References:
 
1.   Shi, Steeb & Hardy, Symbolic C++ 2nd ed., p. 202.
 
Adding two “Verylong” integers together (p. 458) involves adding together the corresponding digits (ascii characters) of the two “Verylong” integers. Each digit that is greater than 9 has 10 subtracted from it and 1 added to the next higher digit (that 1 is called a carry). When the highest digit generates a carry, a new digit is created (appended to the number) to receive the carry.
 
Subtraction (p. 458-459) does borrowing in the opposite direction than addition carrying. Multiplication (p. 459-460) of two numbers (operands) multiplies an entire operand with a single digit of the other operand at a time until all the single digits of the other operand are multiplied. Division (p. 460-461) uses long division.
 
 
Contents
Page 1:  
2:  
3:  
4:  
5:  
6:  
7:  
Variable Length Integers (This Page)
Decimal Integers
Wide Integers
Simd
Subtraction
Multiplication
Partial Products
 
This is Page 1
 
Next Page:
Page 2
 
 
Copyright © 2008 by 3D Software. All rights reserved.
3D Software, P.O. Box 221190, Sacramento CA 95822 USA
www.3DSoftware.com     Contact us
Thursday, 28-Aug-2008 04:19:08 GMT