# Really Big Integers

Page 1 of 1

## 7 Replies - 8570 Views - Last Post: 12 December 2011 - 10:33 AM

### #1 Beach_Coder

Reputation: 17
• Posts: 123
• Joined: 10-November 11

# Really Big Integers

Posted 12 December 2011 - 06:43 AM

Playing around with numbers soon led to frustration with the limits of the given numerical data types. However, I found .Net 4.0 to provide some relief with BigInteger:

Option Strict On
Option Explicit On

Imports System.Console

```
Dim F1 As BigInteger = 0
Dim F2 As BigInteger = 1
Dim F As BigInteger
Dim FString As String

Do
F = F1 + F2
FString = F.ToString
If Len(FString) > 49 Then
FString = F.ToString("E49")
Else
FString = F.ToString("N0")
End If
WriteLine(FString)
F1 = F2
F2 = F
Loop

```

I'm up to 6.3898851458558178284455348202642608899252891622315 E10043 And counting ...
Now over 12,800 digits long. Way too much fun. And it's not even 9AM...
Wait, is it okay to post something like this in here or is there a better spot?

This post has been edited by Beach_Coder: 12 December 2011 - 06:58 AM

Is This A Good Question/Topic? 0

## Replies To: Really Big Integers

### #2 modi123_1

• Suitor #2

Reputation: 10483
• Posts: 40,478
• Joined: 12-June 08

## Re: Really Big Integers

Posted 12 December 2011 - 07:35 AM

What's the question? I moved this up to general vb help, but I am not sure the direction this thread is going.

http://msdn.microsof...biginteger.aspx

Quote

The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds. The members of the BigInteger type closely parallel those of other integral types (the Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, and UInt64 types). This type differs from the other integral types in the .NET Framework, which have a range indicated by their MinValue and MaxValue properties.

### #3 Beach_Coder

Reputation: 17
• Posts: 123
• Joined: 10-November 11

## Re: Really Big Integers

Posted 12 December 2011 - 07:40 AM

modi123_1, on 12 December 2011 - 09:35 AM, said:

What's the question? I moved this up to general vb help, but I am not sure the direction this thread is going.

There isn't a question; it's just me sharing an example of something really cool (BigInteger) that I hadn't used before and I don't recall seeing any mention of here before.

From what I understand, the only limit placed on the value assigned to a BigInteger is that of what one's individual machine is capable of handling. Perhaps it allows for folks using only vb.net on their desktop to join in the GIMPS project (I think I have those letters right).

### #4 modi123_1

• Suitor #2

Reputation: 10483
• Posts: 40,478
• Joined: 12-June 08

## Re: Really Big Integers

Posted 12 December 2011 - 07:48 AM

Ah.. gotcha..

### #5 Beach_Coder

Reputation: 17
• Posts: 123
• Joined: 10-November 11

## Re: Really Big Integers

Posted 12 December 2011 - 07:58 AM

The loop (from the code above) doesn't seem to show any sign of slowing down. It's only a simple calculation with four variables, but it's still a calculation with four variables. Perhaps I'll put the BigInteger to use with something a little more engaging and see where I get the OutOfMemory Exception. I imagine I could calculate where given the amount of memory I have and the operating system and how bits and bytes are stored, accessed and processed, but I'll leave that for someone who was a computer science major.

### #6 _HAWK_

• Master(Of Foo)

Reputation: 1151
• Posts: 4,418
• Joined: 02-July 08

## Re: Really Big Integers

Posted 12 December 2011 - 08:08 AM

Someone shoot me if I ever need a value that big! Would be curious to know where you end up though.

### #7 Beach_Coder

Reputation: 17
• Posts: 123
• Joined: 10-November 11

## Re: Really Big Integers

Posted 12 December 2011 - 10:06 AM

_HAWK_, on 12 December 2011 - 10:08 AM, said:

Someone shoot me if I ever need a value that big! Would be curious to know where you end up though.

It reached 25,000 digits (in just a little more than 3 hours I think) and then I stopped it. I needed my machine back.

### #8 raziel_

• Like a lollipop

Reputation: 466
• Posts: 4,262
• Joined: 25-March 09

## Re: Really Big Integers

Posted 12 December 2011 - 10:33 AM

Quote

in theory has no upper or lower bounds

which means its much much more i guess

This post has been edited by raziel_: 12 December 2011 - 10:33 AM