separate out set_exponent function
This commit is contained in:
parent
14251c91cb
commit
a742bb2059
@ -52,6 +52,15 @@ int16_t get_exponent(const dec80* x){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_exponent(dec80* acc, int16_t exponent, uint8_t num_is_neg){
|
||||||
|
if (num_is_neg){
|
||||||
|
exponent |= 0x8000;
|
||||||
|
} else {
|
||||||
|
exponent &= 0x7fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
acc->exponent = exponent;
|
||||||
|
}
|
||||||
|
|
||||||
static void zero_remaining_dec80(dec80* dest, uint8_t digit100){
|
static void zero_remaining_dec80(dec80* dest, uint8_t digit100){
|
||||||
for ( ; digit100 < DEC80_NUM_LSU; digit100++){
|
for ( ; digit100 < DEC80_NUM_LSU; digit100++){
|
||||||
@ -259,12 +268,7 @@ void build_dec80(dec80* dest, const char* signif_str, int16_t exponent){
|
|||||||
}
|
}
|
||||||
exponent = new_exponent;
|
exponent = new_exponent;
|
||||||
//set negative bit
|
//set negative bit
|
||||||
if (IS_NEG(curr_sign)){
|
set_exponent(dest, exponent, IS_NEG(curr_sign));
|
||||||
exponent |= 0x8000;
|
|
||||||
} else {
|
|
||||||
exponent &= 0x7fff;
|
|
||||||
}
|
|
||||||
dest->exponent = exponent;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf(" num_lr_points (%d), new_exp (%d), sign (%d), exp (%d)\n",
|
printf(" num_lr_points (%d), new_exp (%d), sign (%d), exp (%d)\n",
|
||||||
num_lr_points, new_exponent, curr_sign, exponent);
|
num_lr_points, new_exponent, curr_sign, exponent);
|
||||||
@ -581,11 +585,7 @@ void add_decn(dec80* acc, const dec80* x){
|
|||||||
curr_exp+=2;
|
curr_exp+=2;
|
||||||
}
|
}
|
||||||
//track sign
|
//track sign
|
||||||
if (rel){ //is_neg
|
set_exponent(acc, curr_exp, rel); //rel==is_neg?
|
||||||
acc->exponent = curr_exp | 0x8000;
|
|
||||||
} else {
|
|
||||||
acc->exponent = curr_exp | 0x7fff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user