Comparison error

Just starting out? Need help? Post your questions and find answers here.
User_Russian
Addict
Addict
Posts: 1525
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Comparison error

Post by User_Russian »

Code: Select all

UseCRC32Fingerprint()

x = $09E2A088
s.s = Fingerprint(@x, SizeOf(x), #PB_Cipher_CRC32)
CRC32.l = Val("$"+s)
If CRC32 = Val("$"+s)
  Debug "OK"
Else
  Debug "Bug"
EndIf
User avatar
Kiffi
Addict
Addict
Posts: 1497
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Comparison error

Post by Kiffi »

Code: Select all

CRC32 = Val("$"+s) ; --> OK
CRC32.q = Val("$"+s) ; --> OK
PB-Help wrote:Val() converts a string into a quad numeric value.
Hygge
User_Russian
Addict
Addict
Posts: 1525
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Comparison error

Post by User_Russian »

CRC32 it's 4 bytes (32 bits), not 8 bytes.
Why doesn't the compiler convert types for correct comparison? PB does not have manual type conversion, which I have long proposed viewtopic.php?t=58347
User avatar
mk-soft
Always Here
Always Here
Posts: 6242
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Comparison error

Post by mk-soft »

Code: Select all

UseCRC32Fingerprint()

Macro ULongToSInt(x)
  ($FFFFFFFF & x)
EndMacro

x = $09E2A088
s.s = Fingerprint(@x, SizeOf(x), #PB_Cipher_CRC32)
CRC32.l = Val("$"+s)
If ULongToSInt(CRC32) = Val("$"+s)
  Debug "OK"
Else
  Debug "Bug"
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply