$float32
Jump to navigation
Jump to search
Converts four bytes to a 32-bit float
$float32(byte1, byte2, byte3, byte4)
All credits go to Saturn
Common Uses
Scenarios in which would be dealing with four bytes instead of the float itself are when you would be reading low level data. Typically, this is done when reading from database structured files or TCP/UDP packets. The most common scenario is the time_played field of the query packets for source servers (Such as Counter-Strike source).
Script
alias float32 { var %d = $calc($1 + $2 * 256 + $3 * 256^2 + $4 * 256^3) var %e = $calc($and(%d,$calc(2^31-2^23))/(2^23)) var %m = $base(1. $+ $right($base(%d,10,2,23),23),2,10) return $calc(-1^$isbit(%d,32) * %m * 2^(%e - 127)) }