Ejemplo n.º 1
0
    /* Unpack a split unsigned double */
 double PackedNavBits::asUnsignedDouble(const unsigned startBits[],
                                        const unsigned numBits[],
                                        const unsigned len,
                                        const int power2) const
 {
    
    unsigned long ulong = (unsigned long) asUint64_t(startBits[0], numBits[0]);
    int64_t temp;
    for(unsigned int i = 1; i < len; i++){
       temp = asUint64_t(startBits[i], numBits[i]);
       ulong <<= numBits[i];
       ulong |= temp;
    }
    
    
    //uint64_t temp1 = asUint64_t( startBit1, numBits1 );
    //uint64_t temp2 = asUint64_t( startBit2, numBits2 );
    //unsigned long ulong = (unsigned long) temp1;
    //ulong <<= numBits2;
    //ulong |= temp2;
    
       // Convert to double and scale
    double dval = (double) ulong;
    dval *= pow(static_cast<double>(2), power2);
    return( dval );
 }
Ejemplo n.º 2
0
 unsigned long PackedNavBits::asUnsignedLong(const int startBit, 
                                             const int numBits, 
                                             const int scale ) const
 {
    uint64_t temp = asUint64_t( startBit, numBits );
    unsigned long ulong = (unsigned long) temp;
    ulong *= scale; 
    return( ulong ); 
 }
Ejemplo n.º 3
0
 double PackedNavBits::asUnsignedDouble(const int startBit, const int numBits, 
                                        const int power2) const
 {
    uint64_t uint = asUint64_t( startBit, numBits );
    
       // Convert to double and scale
    double dval = (double) uint;
    dval *= pow(static_cast<double>(2), power2);
    return( dval );
 }
Ejemplo n.º 4
0
 int64_t PackedNavBits::SignExtend( const int startBit, const int numBits) const
 {
    union
    {
       uint64_t u;
       int64_t s;
    };
    u = asUint64_t( startBit, numBits);
    s <<= 64 - numBits; // Move sign bit to msb.
    s >>= 64- numBits;  // Shift result back to correct location sign bit extended.
    return (s);
 }
Ejemplo n.º 5
0
 std::string PackedNavBits::asString(const int startBit, const int numChars) const 
 {
    int CHAR_SIZE = 8;
    string out = " ";
    int currentStart = startBit;
    for (int i = 0; i < numChars; ++i)
    {
       uint64_t temp = asUint64_t(currentStart, CHAR_SIZE);
       char ch = (char) temp;
       out += ch;
       currentStart += CHAR_SIZE;
    }
    return(out);
 }
Ejemplo n.º 6
0
    /* Unpack a split unsigned long integer */ 
 unsigned long PackedNavBits::asUnsignedLong(const unsigned startBits[],
                                             const unsigned numBits[],
                                             const unsigned len,
                                             const int scale ) const
 {
    
    unsigned long ulong = (unsigned long) asUint64_t(startBits[0], numBits[0]);
    uint64_t temp;
    for(unsigned int i = 1; i < len; i++){
       temp = asUint64_t(startBits[i], numBits[i]);
       ulong <<= numBits[i];
       ulong |= temp;
    }
    
    //uint64_t temp1 = asUint64_t( startBit1, numBits1 );
    //uint64_t temp2 = asUint64_t( startBit2, numBits2 );
    //unsigned long ulong = (unsigned long) temp1;
    //ulong <<= numBits2;
    //ulong |= temp2;
    
    ulong *= scale; 
    return( ulong ); 
 }
Ejemplo n.º 7
0
        /*  Unpack a sign/mag long */ 
   long PackedNavBits::asSignMagLong(const int startBit, 
                                     const int numBits, 
                                     const int scale) const
   {
         // Get the magnitude
      int startBitMag = startBit + 1;
      int numBitsMag = numBits - 1; 
      unsigned long mag = asUnsignedLong(startBitMag, numBitsMag, scale);

         // Get the sign bit
      uint64_t uint = asUint64_t( startBit, 1 );

      long smag = (long) mag;
      if (uint==1) smag *= -1;
      return smag; 
   }
Ejemplo n.º 8
0
    /* Unpack a split signed long integer */
 long PackedNavBits::asLong(const unsigned startBits[],
                            const unsigned numBits[],
                            const unsigned len,
                            const int scale ) const
 {
    
    int64_t s = SignExtend(startBits[0], numBits[0]);
    uint64_t temp;
    for(unsigned int i = 1; i < len; i++){
       temp = asUint64_t(startBits[i], numBits[i]);
       s <<= numBits[i];
       s |= temp;
    }
    
    //int64_t s = SignExtend( startBit1, numBits1);
    //uint64_t temp2 = asUint64_t( startBit2, numBits2 );
    //s <<= numBits2;
    //s |= temp2;
    
    return( (long) (s * scale ) );
 }
Ejemplo n.º 9
0
      /* Unpack a split signed double */
   double PackedNavBits::asSignedDouble(const unsigned startBits[],
                                        const unsigned numBits[],
                                        const unsigned len,
                                        const int power2) const
   {
      int64_t s = SignExtend(startBits[0], numBits[0]);
      uint64_t temp;
      for(unsigned int i = 1; i < len; i++){
         temp = asUint64_t(startBits[i], numBits[i]);
         s <<= numBits[i];
         s |= temp;
      }
      
      //int64_t s = SignExtend( startBit1, numBits1);
      //uint64_t temp2 = asUint64_t( startBit2, numBits2 );
      //s <<= numBits2;
      //s |= temp2;

         // Convert to double and scale
      double dval = (double) s;
      dval *= pow(static_cast<double>(2), power2);
      return( dval );
   }