Search code examples
c#serial-portrfid

How to convert 1E00A84ACC to 11029196


  • I have tag of rfid is 0011029196 when i convert it to Hexadecimal it just 0A84ACC and lost 1E0 how i can convert it to
  • 1E00A84ACC.

p/s: tag 1E00A84ACC is read from serial com port

  • i'm using window form with c#

  • how i can code it. thanks


Solution

  • It looks like somewhere the highest 32 bits are getting lost, perhaps by an explicit cast to an int? If so, try using a long types instead of int types.

    Example of the issue:

    long longRFID = 0x1E00A84ACC;
    int intRFID = (int)longRFID;
    Console.WriteLine($"Dec (long): {longRFID}");
    Console.WriteLine($"Hex (long): {longRFID:x}");
    Console.WriteLine($"Dec (int):  {intRFID}");
    Console.WriteLine($"Hex (int):  {intRFID:x}");
    

    Output:

    Dec (long): 128860048076
    Hex (long): 1e00a84acc
    Dec (int):  11029196
    Hex (int):  a84acc