Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Very big value for CRC32
Message
From
13/08/2011 08:41:35
 
 
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:
01520761
Message ID:
01520912
Views:
37
>>>If you use UInt32 as storage for the calculation then, by definition, it can exceed the maximum value of an Int32. But this is irrelevant. If you need to compare the calculated CRC value to one already stored in SQL server then simply use the matching .NET type for the calculation....
>>>
>>>.
>>> And, even if the property is declared integer, this wouldn't create an overflow. This is why the program didn't generate an error at calculation time. But, it did generate an error at SQL query time as at that location, we have to build our query with the same type as the type in the table.
>>
>>Thanks
>
>You might get a clearer idea of what is happening by looking at the byte representations e.g.:
Dim unsigned As UInt32 = UInt32.MaxValue - 1111  ' 4294966184
>Dim bytes As Byte() = BitConverter.GetBytes(unsigned)     ' 168 251 255 255
>Dim signed As Int32 = BitConverter.ToInt32(bytes, 0)          ' -1112
Also possible to look at the byte values is to use the hex presentation
unsigned.ToString("x8") ;
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform