Return TypeFunction nameArguments
voidWriteSerialSINT64(hzChain&,unsigned int&,long,)

Declared in file: hzCodec.h
Defined in file : hzCodec.cpp

Function Logic:

0:START 1:nValue<0 2:bNeg nValue 3:nValue<0x40 4:nLen byte byte hzChain::AddByte 5:nValue<0x0800 6:nLen byte byte hzChain::AddByte hzChain::AddByte 7:nValue<0x080000 8:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte 9:nValue<0x08000000 10:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 11:nValue<0x0800000000 12:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 13:nValue<0x080000000000 14:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 15:nValue<0x08000000000000 16:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 17:nValue<0x08000000000000 18:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 19:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 20: No text

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);
   }
}