; 32-bit float snippet by David "Saturn" van Moolenbroek ; Version 0.01, released 16-10-2011 -- support on #help.script/QuakeNet ; ; Usage: $float32(byte1,byte2,byte3,byte4) ; ; This snippet implements a subset of the IEEE 754 32-bit floating point ; standard. It takes four numeric ASCII byte values, and returns a floating ; point number. Originally written for someone whose nick I cannot remember, ; for interpreting player connect times on Half Life servers or so. 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)) }