Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: How to use numbers larger than 2147483647?


Message #1 by "euan green" <euan_green@h...> on Thu, 23 May 2002 17:15:29
I am using vbscript with asp on IIS4.0 (i am not sys admin)

My questions I desperately need answered are:

How do you perform a cos/sin calculation on a value larger than Cos
(2147483647)?
Try it on  Cos(2147483648) and you'll see what I mean

This saga  is all part of a serial number generation script.  Don't want 
to bore you
with the details but it goes along the lines of this....

A key number is generated client side using a Macromedia Director app.  
The key number
is generated using an algorithm that is replicated Server side on our
website (this is what I am working on)

The key number may contain 8 - (unlimited) figures, but will normally be
between 8-20 figures.

The user comes to our website, and inputs the keynumber.  The keynumber is
split into two seperate strings, one containing the first 5 digits of the
key number, the other containing the rest.

The sine of the first number is taken
The cos of the second number is taken

However, the value of the second number can be very large, it is ok if it 
is below 2147483647, but anyhting larger produces an error,and the number 
used is actually a radian value (Director uses radians
in cos/sin calculations)

If  I put the large number into a Cos calculation ( Cos(2147483648)
for example)  an error message is generated (don't know why...)

The largest integer value Cos can handle apparantley is 2147483647,
It can handle scientific notation, but again, only up to 2.147483647E+9

I just cannot seem to get it to handle a value bigger than this!

Have started converting the key number from radians to degrees using:

dblDegrees = radInitial/(3.14159265358979323846264338327950288/180)

Then dividing this by 360 to get the number of complete 360's in the 
number. 

degValue = dblDegrees/360

The code I am using to get the remainder, which is what I need for the Cos 
calculation goes along the lines of this:

PointPosition = Instr(degValue,".")

If PointPosition <> 0 Then
strWholeNumbers = Left(degValue,(PointPosition-1))
Else
strWholeNumbers = degValue
End If

This actually calculates what the remainder is:

degRemainder = dblDegrees - (360*strWholeNumbers)

and this produces the new Radian value, which is limited to something like 
4,

radNewRadians = degRemainder * (3.14159265358979323846264338327950288/180)
I can then take the cos of it and Robert's your father's brother.

strCos = Cos(radNewRadians)

BUT
This actually works fine, on values bigger than 2147483647 until the 
server automatically switches the result of degValue to scientific 
notation (it does this at around powers of 15), then when the remainder 
gets calculated using:

PointPosition = Instr(degValue,".")
End If
If PointPosition <> 0 Then
strWholeNumbers = Left(degValue,(PointPosition-1))
Else
strWholeNumbers = degValue
End If

It comes across something like 3.545555E+12 and takes the value 3 as the 
number of whole numbers and everything goes arse over tit again.

So I thought I had a work around the initial 2147483647, but now the 
scientific notation issue is buggering things up.

If I can now figure out some way of getting the value of the remainder, 
when a number such as 3.417826377723E+15 is divided by 360 then I will be 
OK.

I'll be amazed if you actually read to the bottom of this email, but 
thanks if you do.

I'm not looking for someone to solve my problem completely, I just need 
some advice on how to get around this, or even if it's just me having 
problems with it, then if it's just me I will feel a lot better (a bit 
thick, but nonetheless better)

Here's Hoping

Euan

  Return to Index