It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Partner Sites
Board index Programming Visual Basic Forum

VB Calcuation Returns "Infinity" as Value

Moderator: dafunkymunky

VB Calcuation Returns "Infinity" as Value

Postby andrewbecks on Thu Oct 22, 2009 4:17 am

Let me start by thanking you all in advance for your assistance and patience with me. I've spent the past several hours combing through many forum posts trying to find an answer to this question but have, so far, been unsuccessful.

I am writing an app using Visual Basic 2008 Express Edition and stumbling into a problem. I need to able to define two different variable (see the example below) and then calculate setting the second variable as the exponent of the first variable.

A few examples of what I've tried...
Code: Select all
Dim value1 as Integer = 445
Dim value2 as Integer = 1980
Dim value3 as Integer = Math.Pow(445, 1980)

and
Code: Select all
Dim value1 as Integer = 445
Dim value2 as Integer = 1980
Dim value3 as Integer = value1 ^ value2

etc.

However, no matter what I seem to do, I keep getting infinity returned as the value. I've tried using Integer, int64, double, etc. for the various dims, but still no luck.

I'm new to VB and could really use/would really appreciate any assistance that could be provided.

Cheers!
Andrew
andrewbecks
 
Posts: 1
Joined: Thu Oct 22, 2009 4:10 am

Re: VB Calcuation Returns "Infinity" as Value

Postby bytelogik on Thu Oct 22, 2009 6:21 am

Dim value1 as Integer = 445
Dim value2 as Integer = 1980
Dim value3 as Integer = value1 ^ value2

The result is too big to store in a variable. Use the Variant data type for result if available. Surprisingly the same values are valid in the Windows Calculator using the x ^ y function.

Let me know the requirement of such big values.
bytelogik
 
Posts: 7
Joined: Tue Oct 06, 2009 8:24 pm


Return to Visual Basic Forum

Who is online

Users browsing this forum: No registered users and 0 guests