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

#1 Beach_Coder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • 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
Imports System.Numerics (I had to add the Reference)


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  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • 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.

Was This Post Helpful? 0
  • +
  • -

#3 Beach_Coder  Icon User is offline

  • D.I.C Head
  • member icon

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

Re: Really Big Integers

Posted 12 December 2011 - 07:40 AM

View Postmodi123_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).
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: Really Big Integers

Posted 12 December 2011 - 07:48 AM

Ah.. gotcha..
Was This Post Helpful? 0
  • +
  • -

#5 Beach_Coder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,012
  • 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.
Was This Post Helpful? 0
  • +
  • -

#7 Beach_Coder  Icon User is offline

  • D.I.C Head
  • member icon

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

Re: Really Big Integers

Posted 12 December 2011 - 10:06 AM

View Post_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.
Was This Post Helpful? 0
  • +
  • -

#8 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1