Synchsafe Integer

BlitzMax Forums/BlitzMax Programming/Synchsafe Integer

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

this is the c to bmx conversion(UNTESTED):
Function unsynchsafe:Int(in:Int) 
	Local out:Int=0, i:Int;
	Local mask:Int= $7F000000;
 
	For i = 0 Until 4
		out = out Shr 1
		out :| in & mask
		mask = mask Shr 8
	Next
 
	Return out
End Function 

this is what I understand from the wikipedia you posted:
it seems to me that you need to grab each byte, the hight byte's firts bit needs to be extracted and moved to the first byte last bit
example 16 bit integer:
local highbyte:int = readbyte(f) ' or something like that
local lowbyte:int = readbyte(f) '        "                   "
lowbyte :| ( highbyte & 1) shl 7 ' extract the first bit of the high byte add it to the end of the low byte
highbyte = highbyte shr 1
int16 =   (highbyte shl 8) | lowbyte


or something similar. that should give you an idea for the 24 bit one. I am not shure the high byte is read first for big endian. if not then read the low byte first.