java/dfp/src/main/java/com/epam/deltix/dfp/JavaImplRound.java [451:500]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        long /*BID_UINT64*/ res = 0xbaddbaddbaddbaddL;
        long /*BID_UINT64*/ x_sign;
        int exp;            // unbiased exponent
        // Note: C1.w[1], C1.w[0] represent x_signif_hi, x_signif_lo (all are BID_UINT64)
        //BID_UI64DOUBLE tmp1;
        int x_nr_bits;
        int q, ind, shift;
        long /*BID_UINT64*/ C1;
        long /*BID_UINT128*/ fstar_w0 = 0x0L, fstar_w1 = 0x0L;
        long /*BID_UINT128*/ P128_w0, P128_w1;

        x_sign = x & MASK_SIGN;    // 0 for positive, MASK_SIGN for negative

        // check for NaNs and infinities
        if ((x & MASK_NAN) == MASK_NAN) {    // check for NaN
            if ((x & 0x0003ffffffffffffL) >= 1000000000000000L)
                x = x & 0xfe00000000000000L;    // clear G6-G12 and the payload bits
            else
                x = x & 0xfe03ffffffffffffL;    // clear G6-G12
            if ((x & MASK_SNAN) == MASK_SNAN) {    // SNaN
                // set invalid flag
//                __set_status_flags(pfpsf, BID_INVALID_EXCEPTION);
                // return quiet (SNaN)
                res = x & 0xfdffffffffffffffL;
            } else {    // QNaN
                res = x;
            }
            return res;
        } else if ((x & MASK_INF) == MASK_INF) {    // check for Infinity
            return x_sign | 0x7800000000000000L;
        }
        // unpack x
        if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
            // if the steering bits are 11 (condition will be 0), then
            // the exponent is G[0:w+1]
            exp = (int) (((x & MASK_BINARY_EXPONENT2) >>> 51) - 398);
            C1 = (x & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
            if (C1 > 9999999999999999L) {    // non-canonical
                C1 = 0;
            }
        } else {    // if ((x & MASK_STEERING_BITS) != MASK_STEERING_BITS)
            exp = (int) (((x & MASK_BINARY_EXPONENT1) >>> 53) - 398);
            C1 = (x & MASK_BINARY_SIG1);
        }

        // if x is 0 or non-canonical
        if (C1 == 0) {
            if (exp < 0)
                exp = 0;
            return x_sign | (((long) exp + 398) << 53);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



java/dfp/src/main/java/com/epam/deltix/dfp/JavaImplRound.java [719:769]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        long /*BID_UINT64*/ res = 0xbaddbaddbaddbaddL;
        long /*BID_UINT64*/ x_sign;
        int exp;            // unbiased exponent
        // Note: C1.w[1], C1.w[0] represent x_signif_hi, x_signif_lo (all are BID_UINT64)
        //BID_UI64DOUBLE tmp1;
        int x_nr_bits;
        int q, ind, shift;
        long /*BID_UINT64*/ C1;
        // BID_UINT64 res is C* at first - represents up to 34 decimal digits ~ 113 bits
        long /*BID_UINT128*/ fstar_w0 = 0x0L, fstar_w1 = 0x0L;
        long /*BID_UINT128*/ P128_w0, P128_w1;

        x_sign = x & MASK_SIGN;    // 0 for positive, MASK_SIGN for negative

        // check for NaNs and infinities
        if ((x & MASK_NAN) == MASK_NAN) {    // check for NaN
            if ((x & 0x0003ffffffffffffL) >= 1000000000000000L)
                x = x & 0xfe00000000000000L;    // clear G6-G12 and the payload bits
            else
                x = x & 0xfe03ffffffffffffL;    // clear G6-G12
            if ((x & MASK_SNAN) == MASK_SNAN) {    // SNaN
                // set invalid flag
//                __set_status_flags(pfpsf, BID_INVALID_EXCEPTION);
                // return quiet (SNaN)
                res = x & 0xfdffffffffffffffL;
            } else {    // QNaN
                res = x;
            }
            return res;
        } else if ((x & MASK_INF) == MASK_INF) {    // check for Infinity
            return x_sign | 0x7800000000000000L;
        }
        // unpack x
        if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
            // if the steering bits are 11 (condition will be 0), then
            // the exponent is G[0:w+1]
            exp = (int) (((x & MASK_BINARY_EXPONENT2) >>> 51) - 398);
            C1 = (x & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
            if (C1 > 9999999999999999L) {    // non-canonical
                C1 = 0;
            }
        } else {    // if ((x & MASK_STEERING_BITS) != MASK_STEERING_BITS)
            exp = (int) (((x & MASK_BINARY_EXPONENT1) >>> 53) - 398);
            C1 = (x & MASK_BINARY_SIG1);
        }

        // if x is 0 or non-canonical
        if (C1 == 0) {
            if (exp < 0)
                exp = 0;
            return x_sign | (((long) exp + 398) << 53);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



