| Return Type | Function name | Arguments |
|---|---|---|
| void | WriteSerialSINT32 | (hzChain&,unsigned int&,int,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
void WriteSerialSINT32 (hzChain& Z, unsigned int& nLen, int nValue)
{
bool bNeg ;
char byte ;
if (nValue < 0)
{ bNeg = true ; nValue *= -1; }
if (nValue < 0x40)
{
nLen = 1;
byte = bNeg ? 0x40:0;
byte |= nValue ;
Z.AddByte(byte) ;
}
else if (nValue < 0x1000)
{
nLen = 2;
byte = bNeg ? 0x90:0x80;
byte |= ((nValue & 0x0f00)>>8);
Z.AddByte(byte) ;
Z.AddByte(nValue & 0xff);
}
else if (nValue < 0x400000)
{
nLen = 3;
byte = bNeg ? 0xB0:0xA0;
byte |= ((nValue & 0x0f0000)>>16);
Z.AddByte(byte) ;
Z.AddByte((nValue & 0xff00)>>8);
Z.AddByte(nValue & 0xff);
}
else if (nValue < 0x40000000)
{
nLen = 4;
byte = bNeg ? 0xD0:0xC0;
byte |= ((nValue & 0x0f000000)>>24);
Z.AddByte(byte) ;
Z.AddByte((nValue & 0xff0000)>>16);
Z.AddByte((nValue & 0xff00)>>8);
Z.AddByte(nValue & 0xff);
}
else
{
nLen = 5;
byte = bNeg ? 0xF0:0xE0;
byte |= ((nValue & 0x0f000000)>>24);
Z.AddByte(0xC0);
Z.AddByte((nValue & 0xff000000)>>24);
Z.AddByte((nValue & 0xff0000)>>16);
Z.AddByte((nValue & 0xff00)>>8);
Z.AddByte(nValue & 0xff);
}
}