by The Zombie Killer » Sun Dec 03, 2017 11:34 pm
Currently, there is no way to convert a series of bytes to a float or a double in ZScript (you can get around it by marshalling data using ScriptCall and C via GDCC, but this limits you to play scope, and requires you to be ingame, ruling out StaticEventHandler::OnRegister).
Perhaps a class like the following could be implemented?
Code: Select all
class BitConverter
{
static int BytesToInt16(int a, int b);
static int BytesToInt32(int a, int b, int c, int d);
static float BytesToFloat32(int a, int b, int c, int d);
static double BytesToFloat64(int a, int b, int c, int d, int e, int f, int g, int h);
static int, int Int16ToBytes(int n);
static int, int, int, int Int32ToBytes(int n);
static int, int, int, int Float32ToBytes(float f);
static int, int, int, int, int, int, int, int Float64ToBytes(double d);
}
Currently, there is no way to convert a series of bytes to a float or a double in ZScript (you can get around it by marshalling data using ScriptCall and C via GDCC, but this limits you to play scope, and requires you to be ingame, ruling out StaticEventHandler::OnRegister).
Perhaps a class like the following could be implemented?
[code=php]class BitConverter
{
static int BytesToInt16(int a, int b);
static int BytesToInt32(int a, int b, int c, int d);
static float BytesToFloat32(int a, int b, int c, int d);
static double BytesToFloat64(int a, int b, int c, int d, int e, int f, int g, int h);
static int, int Int16ToBytes(int n);
static int, int, int, int Int32ToBytes(int n);
static int, int, int, int Float32ToBytes(float f);
static int, int, int, int, int, int, int, int Float64ToBytes(double d);
}[/code]