use crate::bid128::*;
use crate::bid_internal::*;
pub (crate) fn bid_round64_2_18(
q: i32,
x: i32,
C: BID_UINT64,
incr_exp: &mut bool,
ptr_is_midpoint_lt_even: &mut bool,
ptr_is_midpoint_gt_even: &mut bool,
ptr_is_inexact_lt_midpoint: &mut bool,
ptr_is_inexact_gt_midpoint: &mut bool) -> BID_UINT64 {
let P128: BID_UINT128;
let mut fstar: BID_UINT128 = Default::default();
let mut Cstar: BID_UINT64;
let tmp64: BID_UINT64;
let shift: i32;
let mut ind: usize;
let mut C: BID_UINT64 = C;
ind = (x - 1) as usize; C += BID_MIDPOINT64[ind];
P128 = __mul_64x64_to_128MACH(C, BID_KX64[ind]);
shift = BID_EX64M64[ind] as i32; Cstar = P128.w[1] >> shift;
fstar.w[1] = P128.w[1] & BID_MASK64[ind];
fstar.w[0] = P128.w[0];
if fstar.w[1] > BID_HALF64[ind] || (fstar.w[1] == BID_HALF64[ind] && fstar.w[0] != 0) {
tmp64 = fstar.w[1] - BID_HALF64[ind];
if tmp64 != 0 || fstar.w[0] > BID_TEN2MXTRUNC64[ind] { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
if fstar.w[1] == 0 && fstar.w[0] <= BID_TEN2MXTRUNC64[ind] {
if (Cstar & 0x01) == 0x01 { Cstar -= 1; *ptr_is_midpoint_gt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
} else { *ptr_is_midpoint_lt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
}
}
ind = (q - x) as usize; if Cstar == BID_TEN2K64[ind] { Cstar = BID_TEN2K64[ind - 1]; *incr_exp = true;
} else { *incr_exp = false;
}
Cstar
}
pub (crate) fn bid_round128_19_38(
q: i32,
x: i32,
C: &BID_UINT128,
incr_exp: &mut bool,
ptr_is_midpoint_lt_even: &mut bool,
ptr_is_midpoint_gt_even: &mut bool,
ptr_is_inexact_lt_midpoint: &mut bool,
ptr_is_inexact_gt_midpoint: &mut bool) -> BID_UINT128 {
let P256: BID_UINT256;
let mut fstar: BID_UINT256 = Default::default();
let mut Cstar: BID_UINT128 = Default::default();
let mut tmp64: BID_UINT64;
let shift: i32;
let mut ind: usize;
let mut C: BID_UINT128 = *C;
ind = (x - 1) as usize; match ind {
val if val <= 18 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT64[ind];
if C.w[0] < tmp64 {
C.w[1] += 1;
}
},
_ => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT128[ind - 19].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
}
C.w[1] += BID_MIDPOINT128[ind - 19].w[1];
}
}
P256 = __mul_128x128_to_256(&C, &BID_KX128[ind]);
shift = BID_EX128M128[ind] as i32; match ind {
val if val <= 18 => { Cstar.w[0] = (P256.w[2] >> shift) | (P256.w[3] << (64 - shift));
Cstar.w[1] = P256.w[3] >> shift;
fstar.w[0] = P256.w[0];
fstar.w[1] = P256.w[1];
fstar.w[2] = P256.w[2] & BID_MASK128[ind];
fstar.w[3] = 0x0u64;
},
_ => { Cstar.w[0] = P256.w[3] >> shift;
Cstar.w[1] = 0x0u64;
fstar.w[0] = P256.w[0];
fstar.w[1] = P256.w[1];
fstar.w[2] = P256.w[2];
fstar.w[3] = P256.w[3] & BID_MASK128[ind];
}
}
match ind {
val if val <= 18 => { if fstar.w[2] > BID_HALF128[ind]
|| (fstar.w[2] == BID_HALF128[ind]
&& (fstar.w[1] != 0
|| fstar.w[0] != 0)) {
tmp64 = fstar.w[2] - BID_HALF128[ind];
if tmp64 != 0
|| fstar.w[1] > BID_TEN2MXTRUNC128[ind].w[1]
|| (fstar.w[1] == BID_TEN2MXTRUNC128[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC128[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
_ => { if fstar.w[3] > BID_HALF128[ind]
|| (fstar.w[3] == BID_HALF128[ind]
&& (fstar.w[2] != 0
|| fstar.w[1] != 0
|| fstar.w[0] != 0)) {
tmp64 = fstar.w[3] - BID_HALF128[ind];
if tmp64 != 0
|| fstar.w[2] != 0
|| fstar.w[1] > BID_TEN2MXTRUNC128[ind].w[1]
|| (fstar.w[1] == BID_TEN2MXTRUNC128[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC128[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
}
}
if fstar.w[3] == 0 && fstar.w[2] == 0
&& (fstar.w[1] < BID_TEN2MXTRUNC128[ind].w[1]
|| (fstar.w[1] == BID_TEN2MXTRUNC128[ind].w[1]
&& fstar.w[0] <= BID_TEN2MXTRUNC128[ind].w[0])) {
if (Cstar.w[0] & 0x01) == 0x01 { Cstar.w[0] -= 1; if Cstar.w[0] == 0xffffffffffffffffu64 {
Cstar.w[1] -= 1;
}
*ptr_is_midpoint_gt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
} else { *ptr_is_midpoint_lt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
}
}
ind = (q - x) as usize; match ind {
val if val <= 19 => {
if Cstar.w[1] == 0x0u64 && Cstar.w[0] == BID_TEN2K64[ind] {
Cstar.w[0] = BID_TEN2K64[ind - 1]; *incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val == 20 => {
if Cstar.w[1] == BID_TEN2K128[0].w[1] && Cstar.w[0] == BID_TEN2K128[0].w[0] {
Cstar.w[0] = BID_TEN2K64[19]; Cstar.w[1] = 0x0u64;
*incr_exp = true;
} else {
*incr_exp = false;
}
},
_ => { if Cstar.w[1] == BID_TEN2K128[ind - 20].w[1]
&& Cstar.w[0] == BID_TEN2K128[ind - 20].w[0] {
Cstar.w[0] = BID_TEN2K128[ind - 21].w[0]; Cstar.w[1] = BID_TEN2K128[ind - 21].w[1];
*incr_exp = true;
} else {
*incr_exp = false;
}
}
}
Cstar
}
pub (crate) fn bid_round192_39_57(
q: i32,
x: i32,
C: &BID_UINT192,
incr_exp: &mut bool,
ptr_is_midpoint_lt_even: &mut bool,
ptr_is_midpoint_gt_even: &mut bool,
ptr_is_inexact_lt_midpoint: &mut bool,
ptr_is_inexact_gt_midpoint: &mut bool) -> BID_UINT192 {
let P384: BID_UINT384;
let mut fstar: BID_UINT384 = BID_UINT384::default();
let mut Cstar: BID_UINT192 = Default::default();
let mut tmp64: BID_UINT64;
let shift: i32;
let mut ind: usize;
let mut C: BID_UINT192 = *C;
ind = (x - 1) as usize; match ind {
val if val <= 18 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT64[ind];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0 {
C.w[2] += 1;
}
}
},
val if val <= 37 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT128[ind - 19].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0 {
C.w[2] += 1;
}
}
tmp64 = C.w[1];
C.w[1] += BID_MIDPOINT128[ind - 19].w[1];
if C.w[1] < tmp64 {
C.w[2] += 1;
}
},
_ => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT192[ind - 38].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0u64 {
C.w[2] += 1;
}
}
tmp64 = C.w[1];
C.w[1] += BID_MIDPOINT192[ind - 38].w[1];
if C.w[1] < tmp64 {
C.w[2] += 1;
}
C.w[2] += BID_MIDPOINT192[ind - 38].w[2];
}
}
P384 = __mul_192x192_to_384(&C, &BID_KX192[ind]);
shift = BID_EX192M192[ind] as i32; match ind {
val if val <= 18 => { Cstar.w[2] = P384.w[5] >> shift;
Cstar.w[1] = (P384.w[5] << (64 - shift)) | (P384.w[4] >> shift);
Cstar.w[0] = (P384.w[4] << (64 - shift)) | (P384.w[3] >> shift);
fstar.w[5] = 0x0u64;
fstar.w[4] = 0x0u64;
fstar.w[3] = P384.w[3] & BID_MASK192[ind];
fstar.w[2] = P384.w[2];
fstar.w[1] = P384.w[1];
fstar.w[0] = P384.w[0];
},
val if val <= 37 => { Cstar.w[2] = 0x0u64;
Cstar.w[1] = P384.w[5] >> shift;
Cstar.w[0] = (P384.w[5] << (64 - shift)) | (P384.w[4] >> shift);
fstar.w[5] = 0x0u64;
fstar.w[4] = P384.w[4] & BID_MASK192[ind];
fstar.w[3] = P384.w[3];
fstar.w[2] = P384.w[2];
fstar.w[1] = P384.w[1];
fstar.w[0] = P384.w[0];
},
_ => { Cstar.w[2] = 0x0u64;
Cstar.w[1] = 0x0u64;
Cstar.w[0] = P384.w[5] >> shift;
fstar.w[5] = P384.w[5] & BID_MASK192[ind];
fstar.w[4] = P384.w[4];
fstar.w[3] = P384.w[3];
fstar.w[2] = P384.w[2];
fstar.w[1] = P384.w[1];
fstar.w[0] = P384.w[0];
}
}
match ind {
val if val <= 18 => { if fstar.w[3] > BID_HALF192[ind]
|| (fstar.w[3] == BID_HALF192[ind]
&& (fstar.w[2] != 0
|| fstar.w[1] != 0
|| fstar.w[0] != 0)) {
tmp64 = fstar.w[3] - BID_HALF192[ind];
if tmp64 != 0
|| fstar.w[2] > BID_TEN2MXTRUNC192[ind].w[2]
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC192[ind].w[1])
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC192[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC192[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
val if val <= 37 => { if fstar.w[4] > BID_HALF192[ind]
|| (fstar.w[4] == BID_HALF192[ind] && (fstar.w[3] != 0|| fstar.w[2] != 0 || fstar.w[1] != 0 || fstar.w[0] != 0)) {
tmp64 = fstar.w[4] - BID_HALF192[ind];
if tmp64 != 0
|| fstar.w[3] != 0
|| fstar.w[2] > BID_TEN2MXTRUNC192[ind].w[2]
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC192[ind].w[1])
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC192[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC192[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
_ => { if fstar.w[5] > BID_HALF192[ind]
|| (fstar.w[5] == BID_HALF192[ind]
&& (fstar.w[4] != 0|| fstar.w[3] != 0 || fstar.w[2] != 0 || fstar.w[1] != 0 || fstar.w[0] != 0)) {
tmp64 = fstar.w[5] - BID_HALF192[ind];
if tmp64 != 0
|| fstar.w[4] != 0
|| fstar.w[3] != 0
|| fstar.w[2] > BID_TEN2MXTRUNC192[ind].w[2]
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC192[ind].w[1])
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC192[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC192[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
}
}
if fstar.w[5] == 0
&& fstar.w[4] == 0
&& fstar.w[3] == 0
&& (fstar.w[2] < BID_TEN2MXTRUNC192[ind].w[2]
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] < BID_TEN2MXTRUNC192[ind].w[1])
|| (fstar.w[2] == BID_TEN2MXTRUNC192[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC192[ind].w[1]
&& fstar.w[0] <= BID_TEN2MXTRUNC192[ind].w[0])) {
if (Cstar.w[0] & 0x01) == 0x01 { Cstar.w[0] -= 1; if Cstar.w[0] == 0xffffffffffffffffu64 {
Cstar.w[1] -= 1;
if Cstar.w[1] == 0xffffffffffffffffu64 {
Cstar.w[2] -= 1;
}
}
*ptr_is_midpoint_gt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
} else { *ptr_is_midpoint_lt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
}
}
ind = (q - x) as usize; match ind {
val if val <= 19 => {
if Cstar.w[2] == 0x0u64 && Cstar.w[1] == 0x0u64 && Cstar.w[0] == BID_TEN2K64[ind] {
Cstar.w[0] = BID_TEN2K64[ind - 1]; *incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val == 20 => {
if Cstar.w[2] == 0x0u64 && Cstar.w[1] == BID_TEN2K128[0].w[1] && Cstar.w[0] == BID_TEN2K128[0].w[0] {
Cstar.w[0] = BID_TEN2K64[19]; Cstar.w[1] = 0x0u64;
*incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val <= 38 => { if Cstar.w[2] == 0x0u64 && Cstar.w[1] == BID_TEN2K128[ind - 20].w[1] && Cstar.w[0] == BID_TEN2K128[ind - 20].w[0] {
Cstar.w[0] = BID_TEN2K128[ind - 21].w[0]; Cstar.w[1] = BID_TEN2K128[ind - 21].w[1];
*incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val == 39 => {
if Cstar.w[2] == BID_TEN2K256[0].w[2] && Cstar.w[1] == BID_TEN2K256[0].w[1] && Cstar.w[0] == BID_TEN2K256[0].w[0] {
Cstar.w[0] = BID_TEN2K128[18].w[0]; Cstar.w[1] = BID_TEN2K128[18].w[1];
Cstar.w[2] = 0x0u64;
*incr_exp = true;
} else {
*incr_exp = false;
}
},
_ => { if Cstar.w[2] == BID_TEN2K256[ind - 39].w[2]
&& Cstar.w[1] == BID_TEN2K256[ind - 39].w[1]
&& Cstar.w[0] == BID_TEN2K256[ind - 39].w[0] {
Cstar.w[0] = BID_TEN2K256[ind - 40].w[0]; Cstar.w[1] = BID_TEN2K256[ind - 40].w[1];
Cstar.w[2] = BID_TEN2K256[ind - 40].w[2];
*incr_exp = true;
} else {
*incr_exp = false;
}
}
}
Cstar
}
pub (crate) fn bid_round256_58_76(
q: i32,
x: i32,
C: &BID_UINT256,
incr_exp: &mut bool,
ptr_is_midpoint_lt_even: &mut bool,
ptr_is_midpoint_gt_even: &mut bool,
ptr_is_inexact_lt_midpoint: &mut bool,
ptr_is_inexact_gt_midpoint: &mut bool) -> BID_UINT256 {
let P512: BID_UINT512;
let mut fstar: BID_UINT512 = BID_UINT512::default();
let mut Cstar: BID_UINT256 = Default::default();
let mut tmp64: BID_UINT64;
let shift: i32;
let mut ind: usize;
let mut C: BID_UINT256 = *C;
ind = (x as usize) - 1; match ind {
val if val <= 18 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT64[ind];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
}
},
val if val <= 37 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT128[ind - 19].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
}
tmp64 = C.w[1];
C.w[1] += BID_MIDPOINT128[ind - 19].w[1];
if C.w[1] < tmp64 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
},
val if val <= 57 => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT192[ind - 38].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0u64 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
}
tmp64 = C.w[1];
C.w[1] += BID_MIDPOINT192[ind - 38].w[1];
if C.w[1] < tmp64 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
tmp64 = C.w[2];
C.w[2] += BID_MIDPOINT192[ind - 38].w[2];
if C.w[2] < tmp64 {
C.w[3] += 1;
}
},
_ => { tmp64 = C.w[0];
C.w[0] += BID_MIDPOINT256[ind - 58].w[0];
if C.w[0] < tmp64 {
C.w[1] += 1;
if C.w[1] == 0x0u64 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
}
tmp64 = C.w[1];
C.w[1] += BID_MIDPOINT256[ind - 58].w[1];
if C.w[1] < tmp64 {
C.w[2] += 1;
if C.w[2] == 0x0 {
C.w[3] += 1;
}
}
tmp64 = C.w[2];
C.w[2] += BID_MIDPOINT256[ind - 58].w[2];
if C.w[2] < tmp64 {
C.w[3] += 1;
}
C.w[3] += BID_MIDPOINT256[ind - 58].w[3];
}
}
P512 = __mul_256x256_to_512(&C, &BID_KX256[ind]);
shift = BID_EX256M256[ind] as i32; match ind {
val if val <= 18 => { Cstar.w[3] = P512.w[7] >> shift;
Cstar.w[2] = (P512.w[7] << (64 - shift)) | (P512.w[6] >> shift);
Cstar.w[1] = (P512.w[6] << (64 - shift)) | (P512.w[5] >> shift);
Cstar.w[0] = (P512.w[5] << (64 - shift)) | (P512.w[4] >> shift);
fstar.w[7] = 0x0u64;
fstar.w[6] = 0x0u64;
fstar.w[5] = 0x0u64;
fstar.w[4] = P512.w[4] & BID_MASK256[ind];
fstar.w[3] = P512.w[3];
fstar.w[2] = P512.w[2];
fstar.w[1] = P512.w[1];
fstar.w[0] = P512.w[0];
},
val if val <= 37 => { Cstar.w[3] = 0x0u64;
Cstar.w[2] = P512.w[7] >> shift;
Cstar.w[1] = (P512.w[7] << (64 - shift)) | (P512.w[6] >> shift);
Cstar.w[0] = (P512.w[6] << (64 - shift)) | (P512.w[5] >> shift);
fstar.w[7] = 0x0u64;
fstar.w[6] = 0x0u64;
fstar.w[5] = P512.w[5] & BID_MASK256[ind];
fstar.w[4] = P512.w[4];
fstar.w[3] = P512.w[3];
fstar.w[2] = P512.w[2];
fstar.w[1] = P512.w[1];
fstar.w[0] = P512.w[0];
},
val if val <= 56 => { Cstar.w[3] = 0x0u64;
Cstar.w[2] = 0x0u64;
Cstar.w[1] = P512.w[7] >> shift;
Cstar.w[0] = (P512.w[7] << (64 - shift)) | (P512.w[6] >> shift);
fstar.w[7] = 0x0u64;
fstar.w[6] = P512.w[6] & BID_MASK256[ind];
fstar.w[5] = P512.w[5];
fstar.w[4] = P512.w[4];
fstar.w[3] = P512.w[3];
fstar.w[2] = P512.w[2];
fstar.w[1] = P512.w[1];
fstar.w[0] = P512.w[0];
},
val if val == 57 => {
Cstar.w[3] = 0x0u64;
Cstar.w[2] = 0x0u64;
Cstar.w[1] = 0x0u64;
Cstar.w[0] = P512.w[7];
fstar.w[7] = 0x0u64;
fstar.w[6] = P512.w[6];
fstar.w[5] = P512.w[5];
fstar.w[4] = P512.w[4];
fstar.w[3] = P512.w[3];
fstar.w[2] = P512.w[2];
fstar.w[1] = P512.w[1];
fstar.w[0] = P512.w[0];
},
_ => { Cstar.w[3] = 0x0u64;
Cstar.w[2] = 0x0u64;
Cstar.w[1] = 0x0u64;
Cstar.w[0] = P512.w[7] >> shift;
fstar.w[7] = P512.w[7] & BID_MASK256[ind];
fstar.w[6] = P512.w[6];
fstar.w[5] = P512.w[5];
fstar.w[4] = P512.w[4];
fstar.w[3] = P512.w[3];
fstar.w[2] = P512.w[2];
fstar.w[1] = P512.w[1];
fstar.w[0] = P512.w[0];
}
}
match ind {
val if val <= 18 => { if fstar.w[4] > BID_HALF256[ind]
|| (fstar.w[4] == BID_HALF256[ind]
&& (fstar.w[3] != 0 || fstar.w[2] != 0 || fstar.w[1] != 0 || fstar.w[0] != 0)) {
tmp64 = fstar.w[4] - BID_HALF256[ind];
if tmp64 != 0
|| fstar.w[3] > BID_TEN2MXTRUNC256[ind].w[2]
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] > BID_TEN2MXTRUNC256[ind].w[2])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC256[ind].w[1])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC256[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC256[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
val if val <= 37 => { if fstar.w[5] > BID_HALF256[ind]
|| (fstar.w[5] == BID_HALF256[ind]
&& (fstar.w[4] != 0 || fstar.w[3] != 0 || fstar.w[2] != 0 || fstar.w[1] != 0 || fstar.w[0] != 0)) {
tmp64 = fstar.w[5] - BID_HALF256[ind];
if tmp64 != 0
|| fstar.w[4] != 0
|| fstar.w[3] > BID_TEN2MXTRUNC256[ind].w[3]
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] > BID_TEN2MXTRUNC256[ind].w[2])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC256[ind].w[1])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC256[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC256[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
val if val <= 57 => { if fstar.w[6] > BID_HALF256[ind]
|| (fstar.w[6] == BID_HALF256[ind]
&& (fstar.w[5] != 0
|| fstar.w[4] != 0
|| fstar.w[3] != 0
|| fstar.w[2] != 0
|| fstar.w[1] != 0
|| fstar.w[0] != 0)) {
tmp64 = fstar.w[6] - BID_HALF256[ind];
if tmp64 != 0
|| fstar.w[5] != 0
|| fstar.w[4] != 0
|| fstar.w[3] > BID_TEN2MXTRUNC256[ind].w[3]
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] > BID_TEN2MXTRUNC256[ind].w[2])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC256[ind].w[1])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC256[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC256[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
},
_ => { if fstar.w[7] > BID_HALF256[ind]
|| (fstar.w[7] == BID_HALF256[ind]
&& (fstar.w[6] != 0
|| fstar.w[5] != 0
|| fstar.w[4] != 0
|| fstar.w[3] != 0
|| fstar.w[2] != 0
|| fstar.w[1] != 0
|| fstar.w[0] != 0)) {
tmp64 = fstar.w[7] - BID_HALF256[ind];
if tmp64 != 0
|| fstar.w[6] != 0
|| fstar.w[5] != 0
|| fstar.w[4] != 0
|| fstar.w[3] > BID_TEN2MXTRUNC256[ind].w[3]
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] > BID_TEN2MXTRUNC256[ind].w[2])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] > BID_TEN2MXTRUNC256[ind].w[1])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC256[ind].w[1]
&& fstar.w[0] > BID_TEN2MXTRUNC256[ind].w[0]) { *ptr_is_inexact_lt_midpoint = true;
} } else { *ptr_is_inexact_gt_midpoint = true;
}
}
}
if fstar.w[7] == 0 && fstar.w[6] == 0
&& fstar.w[5] == 0 && fstar.w[4] == 0
&& (fstar.w[3] < BID_TEN2MXTRUNC256[ind].w[3]
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] < BID_TEN2MXTRUNC256[ind].w[2])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] < BID_TEN2MXTRUNC256[ind].w[1])
|| (fstar.w[3] == BID_TEN2MXTRUNC256[ind].w[3]
&& fstar.w[2] == BID_TEN2MXTRUNC256[ind].w[2]
&& fstar.w[1] == BID_TEN2MXTRUNC256[ind].w[1]
&& fstar.w[0] <= BID_TEN2MXTRUNC256[ind].w[0])) {
if (Cstar.w[0] & 0x01) == 0x01 { Cstar.w[0] -= 1; if Cstar.w[0] == 0xffffffffffffffffu64 {
Cstar.w[1] -= 1;
if Cstar.w[1] == 0xffffffffffffffffu64 {
Cstar.w[2] -= 1;
if Cstar.w[2] == 0xffffffffffffffffu64 {
Cstar.w[3] -= 1;
}
}
}
*ptr_is_midpoint_gt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
} else { *ptr_is_midpoint_lt_even = true;
*ptr_is_inexact_lt_midpoint = false;
*ptr_is_inexact_gt_midpoint = false;
}
}
ind = (q - x) as usize; match ind {
val if val <= 19 => {
if Cstar.w[3] == 0x0u64
&& Cstar.w[2] == 0x0u64
&& Cstar.w[1] == 0x0u64
&& Cstar.w[0] == BID_TEN2K64[ind] {
Cstar.w[0] = BID_TEN2K64[ind - 1]; *incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val == 20 => {
if Cstar.w[3] == 0x0u64
&& Cstar.w[2] == 0x0u64
&& Cstar.w[1] == BID_TEN2K128[0].w[1]
&& Cstar.w[0] == BID_TEN2K128[0].w[0] {
Cstar.w[0] = BID_TEN2K64[19]; Cstar.w[1] = 0x0u64;
*incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val <= 38 => { if Cstar.w[3] == 0x0u64
&& Cstar.w[2] == 0x0u64
&& Cstar.w[1] == BID_TEN2K128[ind - 20].w[1]
&& Cstar.w[0] == BID_TEN2K128[ind - 20].w[0] {
Cstar.w[0] = BID_TEN2K128[ind - 21].w[0]; Cstar.w[1] = BID_TEN2K128[ind - 21].w[1];
*incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val == 39 => {
if Cstar.w[3] == 0x0u64
&& Cstar.w[2] == BID_TEN2K256[0].w[2]
&& Cstar.w[1] == BID_TEN2K256[0].w[1]
&& Cstar.w[0] == BID_TEN2K256[0].w[0] {
Cstar.w[0] = BID_TEN2K128[18].w[0]; Cstar.w[1] = BID_TEN2K128[18].w[1];
Cstar.w[2] = 0x0u64;
*incr_exp = true;
} else {
*incr_exp = false;
}
},
val if val <= 57 => { if Cstar.w[3] == 0x0u64
&& Cstar.w[2] == BID_TEN2K256[ind - 39].w[2]
&& Cstar.w[1] == BID_TEN2K256[ind - 39].w[1]
&& Cstar.w[0] == BID_TEN2K256[ind - 39].w[0] {
Cstar.w[0] = BID_TEN2K256[ind - 40].w[0]; Cstar.w[1] = BID_TEN2K256[ind - 40].w[1];
Cstar.w[2] = BID_TEN2K256[ind - 40].w[2];
*incr_exp = true;
} else {
*incr_exp = false;
}
},
_ => { if Cstar.w[3] == BID_TEN2K256[ind - 39].w[3]
&& Cstar.w[2] == BID_TEN2K256[ind - 39].w[2]
&& Cstar.w[1] == BID_TEN2K256[ind - 39].w[1]
&& Cstar.w[0] == BID_TEN2K256[ind - 39].w[0] {
Cstar.w[0] = BID_TEN2K256[ind - 40].w[0]; Cstar.w[1] = BID_TEN2K256[ind - 40].w[1];
Cstar.w[2] = BID_TEN2K256[ind - 40].w[2];
Cstar.w[3] = BID_TEN2K256[ind - 40].w[3];
*incr_exp = true;
} else {
*incr_exp = false;
}
}
}
Cstar
}