Return Type | Function name | Arguments |
---|---|---|
void | WriteSerialSINT64 | (hzChain&,unsigned int&,long,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
void WriteSerialSINT64 (hzChain& Z, unsigned int& nLen, long 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 < 0x0800) { nLen = 2; byte = bNeg ? 0x88:0x80; byte |= ((nValue & 0x0700)>>8); Z.AddByte(byte) ; Z.AddByte(nValue & 0xff); } else if (nValue < 0x080000) { nLen = 3; byte = bNeg ? 0x98:0x90; byte |= ((nValue & 0x070000)>>16); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else if (nValue < 0x08000000) { nLen = 4; byte = bNeg ? 0xA8:0xA0; byte |= ((nValue & 0x07000000)>>24); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else if (nValue < 0x0800000000) { nLen = 4; byte = bNeg ? 0xB8:0xB0; byte |= ((nValue & 0x0700000000)>>32); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff000000)>>24); Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else if (nValue < 0x080000000000) { nLen = 4; byte = bNeg ? 0xC8:0xC0; byte |= ((nValue & 0x0700000000)>>40); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff00000000)>>32); Z.AddByte((nValue & 0xff000000)>>24); Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else if (nValue < 0x08000000000000) { nLen = 4; byte = bNeg ? 0xD8:0xD0; byte |= ((nValue & 0x070000000000)>>48); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff0000000000)>>40); Z.AddByte((nValue & 0xff00000000)>>32); Z.AddByte((nValue & 0xff000000)>>24); Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else if (nValue < 0x08000000000000) { nLen = 4; byte = bNeg ? 0xD8:0xD0; byte |= ((nValue & 0x07000000000000)>>56); Z.AddByte(byte) ; Z.AddByte((nValue & 0xff000000000000)>>48); Z.AddByte((nValue & 0xff0000000000)>>40); Z.AddByte((nValue & 0xff00000000)>>32); Z.AddByte((nValue & 0xff000000)>>24); Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } else { nLen = 5; byte = bNeg ? 0xF8:0xF0; byte |= ((nValue & 0x0f000000)>>24); Z.AddByte(0xC0); Z.AddByte((nValue & 0xff00000000000000)>>56); Z.AddByte((nValue & 0xff000000000000)>>48); Z.AddByte((nValue & 0xff0000000000)>>40); Z.AddByte((nValue & 0xff00000000)>>32); Z.AddByte((nValue & 0xff000000)>>24); Z.AddByte((nValue & 0xff0000)>>16); Z.AddByte((nValue & 0xff00)>>8); Z.AddByte(nValue & 0xff); } }