2003-10-24 21:43:32 +00:00
|
|
|
#include "math.qh"
|
2003-10-27 22:27:29 +00:00
|
|
|
#include "builtins.qh"
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
/* Ugh. QuakeC doesn't include these ops. */
|
2004-02-08 07:34:17 +00:00
|
|
|
float (float num, float bits)
|
|
|
|
shl =
|
|
|
|
{
|
|
|
|
if (bits >= 16) {
|
|
|
|
num *= 65536;
|
|
|
|
bits -= 16;
|
|
|
|
}
|
|
|
|
if (bits >= 8) {
|
|
|
|
num *= 256;
|
|
|
|
bits -= 8;
|
|
|
|
}
|
|
|
|
if (bits >= 4) {
|
|
|
|
num *= 16;
|
|
|
|
bits -= 4;
|
|
|
|
}
|
|
|
|
if (bits >= 2) {
|
|
|
|
num *= 4;
|
|
|
|
bits -= 2;
|
|
|
|
}
|
|
|
|
if (bits >= 1) {
|
|
|
|
num *= 2;
|
|
|
|
}
|
2003-10-24 21:43:32 +00:00
|
|
|
return num;
|
|
|
|
};
|
|
|
|
|
2004-02-08 07:34:17 +00:00
|
|
|
float (float num, float bits)
|
|
|
|
shr =
|
|
|
|
{
|
|
|
|
if (bits >= 16) {
|
|
|
|
num /= 65536;
|
|
|
|
bits -= 16;
|
|
|
|
}
|
|
|
|
if (bits >= 8) {
|
|
|
|
num /= 256;
|
|
|
|
bits -= 8;
|
|
|
|
}
|
|
|
|
if (bits >= 4) {
|
|
|
|
num /= 16;
|
|
|
|
bits -= 4;
|
|
|
|
}
|
|
|
|
if (bits >= 2) {
|
|
|
|
num /= 4;
|
|
|
|
bits -= 2;
|
|
|
|
}
|
|
|
|
if (bits >= 1) {
|
|
|
|
num /= 2;
|
|
|
|
}
|
|
|
|
return floor (num);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|