Change Endian
Posted: Thu Aug 11, 2011 5:14 pm
Working with hashing algorithms is one place you can run into the need for changing the byte order in a variable. I didn't really see any examples and I can't remember any so I came up with this, which does do the job:
Question: Is there a better way? Or a "standard" way that everybody but me knows about?
Code: Select all
Procedure.q ChangeEndian(value.q)
Structure bquad
byte.a[8]
EndStructure
Protected result.q = 0
*thismem.bquad = @result
*thatmem.bquad = @value
For i=0 To 7
*thismem\byte[i] = *thatmem\byte[7-i]
Next
ProcedureReturn result
EndProcedure