[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  I get an overflow using the MOD function for the following data.

I get an overflow using the MOD function for the following data.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Bruce   (1 post)  [Biography] bio
Date Thu 25 Jan 2007 01:55 PM (UTC)
Message
I get an overflow for the following VBScript code, and do not know what data type to cast to, so I do not get the "overflow" except. Any idea on this is greatly appreciated.

dim iFileSize
dim Remainder

iFileSize = 2206678860
Remainder= CDbl(iFileSize) Mod (228)

What should I cast my iFileSize to, to avoid an overflow?
If possible, please contact me directly at byang@cmsdirect.com

Thank you.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Thu 25 Jan 2007 02:15 PM (UTC)
Message
You might want to read:
http://blogs.msdn.com/ericlippert/archive/2004/12/01/273222.aspx
(Incidentally, #5 in the result list for google "vbscript mod function")

In particular:
Quote:
And indeed, the writer is correct. 2147483647 mod 2 returns 1, but 2147483648 mod 2 produces a type mismatch error. Since that's 2^31, you should be able to guess at what's going on here -- the mod operator only operates on values that can be fit into a 32 bit signed integer.


The page also suggests a solution, in the form of a custom-written mod function.

(By the way -- normally we strongly encourage public replies so that everybody can see the solution to the problem. Private replies defeat the purpose of a public help forum.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,658 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]