Numeric Variables

L

Lespaul36

I need to check numbers that are sort of extreme such
as -9223372036854775808 and less. I don't see any variables that can do it
without an error..any ideas?
 
R

R. MacDonald

Hello, Lespaul,

Have you considered using the "Decimal" type. I haven't used this
myself, but I think that it will give you 28-29 significant figures.

Cheers,
Randy
 
L

Lespaul36

Yeah I tied that, but still get an overflow error in the code.
Thanks for the thought though.

Would be nice if there was just a number class that could hand it. I have
to deal with some extreme number.. high and low. I am thinking I might have
to write a class for this, but not sure how to do that.
 
R

R. MacDonald

Hello, Lespaul,

The following works for me without an error:

Dim decTest As Decimal = -9223372036854775808D
MsgBox("Value is: " & decTest)

I tried the following loop, and it continues nicely until I = 28 (i.e.
10^28 is OK, 10^29 is not.)

Dim intScale As Integer
Try
Dim decTest As Decimal
intScale = 0
decTest = 10
Do
intScale = intScale + 1
decTest = 10 ^ intScale
MsgBox(intScale & ": Value is: " & decTest)
Loop

Catch ex As Exception
MsgBox(intScale & " is too large.")

End Try

Perhaps you have some other problem. Can you post your code?

Cheers,
Randy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top