Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CRC32 returns negative on big files
Message
From
01/08/2011 08:28:36
 
 
To
01/08/2011 08:14:34
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01519635
Message ID:
01519798
Views:
26
>>That seems odd (although I agree it is true).
>>The equivalent in C# is fine ( UInt32 lcCRC33Result = 0xFFFFFFFF) and you can achieve the requred result in VB using ' Dim lnCRC32Result = UInt32.MaxValue'
>>
>>But VB.NET isn't my first language so there may be some VB related quirk I'm not aware of. IAC, AFAICS, we've established that an unsigned int isn't a good choice since it offers no benefits and may, in some circumstances, be less useful in that (a) it's not CLS compliant and (b) it may not be storable in some databases.
>
>Thanks, so basically, the current formula is OK and can return negative values, which would then be normal.
>
>So, this whole thread that you exchanged with Gregory was about the possibility to always return a positive value, which would then be not polynomal PKZip CRC32 compliant. Is that it?


Michel,

Both are 'polynomal PKZip CRC32 compliant'

Whether you return an Integer (which can be < 0) or a UInteger (always >= 0) , does not matter. It's the bit pattern that matters, ie
0xFFFFFFFF

is -1 if it is an Integer
is  4,294,967,295 if it is a UInteger
So,
 dim xx as Integer = &HFFFFFFFF  ' -1

or
dim xx as UInteger = &HFFFFFFFFUI ' 4,294,967,295 
Both bit structures are equal
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform