BlitzMax Request: Signed Short

BlitzMax Forums/BlitzMax Programming/BlitzMax Request: Signed Short

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.

Here are two ways to convert a signed short to an Int.
' Human-readable version:

Function SignedShortToInt( s:Short )
	
	If s < 32768 Then Return Int(s)
	Return Int(s) - 65536
	
End Function


' CPU-friendly version:

Function SignedShortToInt( s:Short )
	
	Return (s Shl 16) Sar 16
		
End Function