13,457,673 members
Tip/Trick
alternative version

#### Stats

7.2K views
3 bookmarked
Posted 10 Jun 2010

# HugeInt - N Digit Arithmetic Class

, 10 Jun 2010
A class for N-Digit Arithmetic

## Introduction

HugeInt Class is like any Integer Class(only +,-,*,^ are supported) but can hold any number of digits.

## Using the Code

HugeInt can be used like this:

```Dim int1 as New HugeInt.HugeInt("2")
Dim int2 as New HugeInt.HugeInt("4096")
MsgBox(int1^int2)
MsgBox(CStr(int1*int2).Length)```

Keep in mind that this class is not designed for high-speed arithmetic. My aim was to develop logic in basic n-digit arithmetic.

A Factorial function or Permute or Combine function can also be included. But I thought the basic functions would be enough for logic.

This class will be very useful for computations of Combinations or Permutations or 1000!(factorials) or big exponents(10^10000). Every digit of the given integer is accurate.

Internally, it uses a string array for the digits. So the precision is upto the nth digit.

## Points of Interest

First, I tried to convert an N-Digit number to Binary format. But I couldn't develop a good method other than dividing and getting the remainder(if there is a good method, please let me know.)

A Case-By-Case Analysis of what our human brain does for various types of subtraction(borrows, first digit etc.) was interesting and I learnt how complex the brain is!

## Share

 Student India
No Biography provided