(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
04-23-23 02:57 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - VB6 - Overflow Error with 32760? New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Sukasa

Birdo
Not quite as active as before.
Xkeeper supporter
Xk > ||bass
I IP Banned myself! Twice!








Since: 11-17-05
From: Somewhere over there

Last post: 5908 days
Last view: 5907 days
Posted on 09-22-06 10:31 PM Link | Quote
So, yeah, I'm working on a piece of code, and a bug gave me a wron goffset for another section of code in a decompression routine. I was using a counter for an array variable bIn(), and got this, where lpA = 8 and bin(9) = 145, and bIn(10) = 0, and lpC and lpB are unimportant (lpC was 0 FYI, and lpB was 18). The error was in the section "( (bIn(lpA+1) * 256) + bIn(lpa + 2) + lpC)":

bOut(lpB) = bOut( (bIn(lpA+1) * 256) + bIn(lpa + 2) + lpC)

lpA, lpB, and lpC were all long variables, and bIn() and bOut() were all byte variables.

So, bIn(lpA+1) = 145, and for 145*256 it gave me an overflow error. Any help as to why it did so? I then executed "Debug.Print 145*256" In the immediate pane, and ALso got an overflow error. Help?
never-obsolete

Paragoomba








Since: 05-14-06
From: AZ

Last post: 5909 days
Last view: 5909 days
Posted on 09-22-06 11:17 PM Link | Quote
Since the two operands are integers, vb assumes that the variable you are assigning the value to is also gonna be an integer. Cast the operands to long first then assign.


Debug.Print 145 * 256&


do that to any integer constants in your algorithm
Sukasa

Birdo
Not quite as active as before.
Xkeeper supporter
Xk > ||bass
I IP Banned myself! Twice!








Since: 11-17-05
From: Somewhere over there

Last post: 5908 days
Last view: 5907 days
Posted on 09-23-06 01:09 AM Link | Quote
Ah, thanks. I was wondering why the heck VB was doing that.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - VB6 - Overflow Error with 32760? |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.010 seconds; used 357.87 kB (max 421.89 kB)