Search code examples
language-agnosticguidlong-integer

How to Convert Long to Guid and Vice Versa?


Is this even possible? I don't even think it is, but I saw some code that was trying to do it. However, my unit tests showed that it was not working. I did see some similar thoughts:

Just for clarification. The Guid creation is outside of my control; therefore, I can't just store the value in one of the Guid sets.


Solution

  • A GUID is 16 bytes long. A "long" is often understood as being 64 bits (i.e. 8 bytes) long. You cannot convert between those without losing or providing extra data.