handle truncation in entering numbers properly
This commit is contained in:
parent
6ab4cfb714
commit
51c2d2e2e7
@ -316,7 +316,6 @@ void build_dec80(__xdata const char* signif_str, __xdata exp_t exponent){
|
||||
// adjust exponent for left-aligned significand input
|
||||
// or for number of digits past decimal point
|
||||
if (num_lr_points > 0){ //left count exists
|
||||
assert(DEC80_NUM_LSU*2 > num_lr_points);
|
||||
new_exponent = exponent + (num_lr_points - 1); //1 digit left of implicit point
|
||||
//overflow is checked later, should be impossible to overflow int16_t:
|
||||
assert(new_exponent >= exponent);
|
||||
|
@ -110,6 +110,10 @@ TEST_CASE("build decn"){
|
||||
decn_to_str_complete(&AccDecn);
|
||||
CHECK_THAT(Buf, Equals("123456789012345678."));
|
||||
|
||||
build_dec80("12345678901234567890", +2);
|
||||
decn_to_str_complete(&AccDecn);
|
||||
CHECK_THAT(Buf, Equals("1.23456789012345678E21"));
|
||||
|
||||
//overflow
|
||||
build_dec80("100", DEC80_MAX_EXP-1);
|
||||
decn_to_str_complete(&AccDecn);
|
||||
|
Loading…
Reference in New Issue
Block a user