src/codec/memcomparable_format.h
/* The following should work for IEEE */
The following should work for IEEE
The following should work for IEEE
__attribute__((unused)) static int PackDouble(const void *from, void *to) {
    if (from == nullptr) {
        return -1;
    }
    uint32_t length = sizeof(double);
    const uchar *ptr = (uchar *)from;  
    double nr;
    memcpy(&nr, ptr, length);
    uchar *tmp = (uchar *)to;  
    if (nr == 0.0) {           
        tmp[0] = (uchar)128;
        memset(tmp + 1, 0, sizeof(nr) - 1);
    } else {
        uchar *ptr = (uchar *)&nr;  
        SwapDoubleBytes(tmp, ptr);
        if (tmp[0] & 128) { 
            uint32_t i;
            for (i = 0; i < sizeof(nr); i++) tmp[i] = tmp[i] ^ (uchar)255;
        } else { 
            uint16_t exp_part = (((uint16_t)tmp[0] << 8) | (uint16_t)tmp[1] | (uint16_t)32768);
            exp_part += (uint16_t)1 << (16 - 1 - DBL_EXP_DIG);
            tmp[0] = (uchar)(exp_part >> 8);
            tmp[1] = (uchar)exp_part;
        }
    }
    return 0;
}
__attribute__ ( ( unused ) ) static int PackDouble ( const void * from , void * to ) { if ( from == nullptr ) { return -1 ; } uint32_t length = sizeof ( double ) ; const uchar * ptr = ( uchar * ) from ; double nr ; memcpy ( & nr , ptr , length ) ; uchar * tmp = ( uchar * ) to ; if ( nr == 0.0 ) { tmp [ 0 ] = ( uchar ) 128 ; memset ( tmp + 1 , 0 , sizeof ( nr ) - 1 ) ; } else { uchar * ptr = ( uchar * ) & nr ; SwapDoubleBytes ( tmp , ptr ) ; if ( tmp [ 0 ] & 128 ) { uint32_t i ; for ( i = 0 ; i < sizeof ( nr ) ; i ++ ) tmp [ i ] = tmp [ i ] ^ ( uchar ) 255 ; } else { uint16_t exp_part = ( ( ( uint16_t ) tmp [ 0 ] << 8 ) | ( uint16_t ) tmp [ 1 ] | ( uint16_t ) 32768 ) ; exp_part += ( uint16_t ) 1 << ( 16 - 1 - DBL_EXP_DIG ) ; tmp [ 0 ] = ( uchar ) ( exp_part >> 8 ) ; tmp [ 1 ] = ( uchar ) exp_part ; } } return 0 ; }
The following should work for IEEE
The following should work for IEEE
// NOLINT // NOLINT /* Change to zero string */ // NOLINT /* Negative */ /* Set high and move exponent one up */