Skip to content

Commit a76b0da

Browse files
committed
Replace some uses of sign with sig
It seems like "sign" was used as a shortened version of "significand", but that is easy to confuse with "sign". Update these to use "sig" like most other places.
1 parent 9ded153 commit a76b0da

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/float/extend.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ where
1515
let src_zero = F::Int::ZERO;
1616
let src_one = F::Int::ONE;
1717
let src_bits = F::BITS;
18-
let src_sign_bits = F::SIG_BITS;
18+
let src_sig_bits = F::SIG_BITS;
1919
let src_exp_bias = F::EXP_BIAS;
2020
let src_min_normal = F::IMPLICIT_BIT;
2121
let src_infinity = F::EXP_MASK;
@@ -25,12 +25,12 @@ where
2525
let src_nan_code = src_qnan - src_one;
2626

2727
let dst_bits = R::BITS;
28-
let dst_sign_bits = R::SIG_BITS;
28+
let dst_sig_bits = R::SIG_BITS;
2929
let dst_inf_exp = R::EXP_SAT;
3030
let dst_exp_bias = R::EXP_BIAS;
3131
let dst_min_normal = R::IMPLICIT_BIT;
3232

33-
let sign_bits_delta = dst_sign_bits - src_sign_bits;
33+
let sig_bits_delta = dst_sig_bits - src_sig_bits;
3434
let exp_bias_delta = dst_exp_bias - src_exp_bias;
3535
let a_abs = a.to_bits() & src_abs_mask;
3636
let mut abs_result = R::Int::ZERO;
@@ -41,8 +41,8 @@ where
4141
// exponent into the proper position and rebiasing the exponent.
4242
let abs_dst: R::Int = a_abs.cast();
4343
let bias_dst: R::Int = exp_bias_delta.cast();
44-
abs_result = abs_dst.wrapping_shl(sign_bits_delta);
45-
abs_result += bias_dst.wrapping_shl(dst_sign_bits);
44+
abs_result = abs_dst.wrapping_shl(sig_bits_delta);
45+
abs_result += bias_dst.wrapping_shl(dst_sig_bits);
4646
} else if a_abs >= src_infinity {
4747
// a is NaN or infinity.
4848
// Conjure the result by beginning with infinity, then setting the qNaN
@@ -51,18 +51,18 @@ where
5151
let qnan_dst: R::Int = (a_abs & src_qnan).cast();
5252
let nan_code_dst: R::Int = (a_abs & src_nan_code).cast();
5353
let inf_exp_dst: R::Int = dst_inf_exp.cast();
54-
abs_result = inf_exp_dst.wrapping_shl(dst_sign_bits);
55-
abs_result |= qnan_dst.wrapping_shl(sign_bits_delta);
56-
abs_result |= nan_code_dst.wrapping_shl(sign_bits_delta);
54+
abs_result = inf_exp_dst.wrapping_shl(dst_sig_bits);
55+
abs_result |= qnan_dst.wrapping_shl(sig_bits_delta);
56+
abs_result |= nan_code_dst.wrapping_shl(sig_bits_delta);
5757
} else if a_abs != src_zero {
5858
// a is denormal.
5959
// Renormalize the significand and clear the leading bit, then insert
6060
// the correct adjusted exponent in the destination type.
6161
let scale = a_abs.leading_zeros() - src_min_normal.leading_zeros();
6262
let abs_dst: R::Int = a_abs.cast();
6363
let bias_dst: R::Int = (exp_bias_delta - scale + 1).cast();
64-
abs_result = abs_dst.wrapping_shl(sign_bits_delta + scale);
65-
abs_result = (abs_result ^ dst_min_normal) | (bias_dst.wrapping_shl(dst_sign_bits));
64+
abs_result = abs_dst.wrapping_shl(sig_bits_delta + scale);
65+
abs_result = (abs_result ^ dst_min_normal) | (bias_dst.wrapping_shl(dst_sig_bits));
6666
}
6767

6868
let sign_result: R::Int = (a.to_bits() & src_sign_mask).cast();

src/float/trunc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ where
1717
let src_exp_bias = F::EXP_BIAS;
1818

1919
let src_min_normal = F::IMPLICIT_BIT;
20-
let src_significand_mask = F::SIG_MASK;
20+
let src_sig_mask = F::SIG_MASK;
2121
let src_infinity = F::EXP_MASK;
2222
let src_sign_mask = F::SIGN_MASK;
2323
let src_abs_mask = src_sign_mask - src_one;
@@ -40,7 +40,7 @@ where
4040
let dst_qnan = R::Int::ONE << (R::SIG_BITS - 1);
4141
let dst_nan_code = dst_qnan - dst_one;
4242

43-
let sign_bits_delta = F::SIG_BITS - R::SIG_BITS;
43+
let sig_bits_delta = F::SIG_BITS - R::SIG_BITS;
4444
// Break a into a sign and representation of the absolute value.
4545
let a_abs = a.to_bits() & src_abs_mask;
4646
let sign = a.to_bits() & src_sign_mask;
@@ -50,7 +50,7 @@ where
5050
// The exponent of a is within the range of normal numbers in the
5151
// destination format. We can convert by simply right-shifting with
5252
// rounding and adjusting the exponent.
53-
abs_result = (a_abs >> sign_bits_delta).cast();
53+
abs_result = (a_abs >> sig_bits_delta).cast();
5454
// Cast before shifting to prevent overflow.
5555
let bias_diff: R::Int = src_exp_bias.wrapping_sub(dst_exp_bias).cast();
5656
let tmp = bias_diff << R::SIG_BITS;
@@ -85,7 +85,7 @@ where
8585
let a_exp: u32 = (a_abs >> F::SIG_BITS).cast();
8686
let shift = src_exp_bias - dst_exp_bias - a_exp + 1;
8787

88-
let significand = (a.to_bits() & src_significand_mask) | src_min_normal;
88+
let significand = (a.to_bits() & src_sig_mask) | src_min_normal;
8989

9090
// Right shift by the denormalization amount with sticky.
9191
if shift > F::SIG_BITS {

0 commit comments

Comments
 (0)