Page 1 of 1

Comparison error

Posted: Thu Jun 05, 2025 6:26 pm
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

Re: Comparison error

Posted: Thu Jun 05, 2025 7:10 pm
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.

Re: Comparison error

Posted: Thu Jun 05, 2025 7:20 pm
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

Re: Comparison error

Posted: Thu Jun 05, 2025 8:18 pm
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