Skip to content

Commit

Permalink
Fix decimal parsing for special encoding for 0
Browse files Browse the repository at this point in the history
- This was in a previously approved but not merged PR (#23)
  • Loading branch information
cedelavergne-ledger committed Sep 28, 2023
1 parent 425f52d commit 323f28a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/xrp/amount.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ static int parse_decimal_number(char *dst,
return -1;
}

// 0. Abort early if number matches special case for zero
if (sign == 0 && exponent == 0 && mantissa == 0) {
dst[0] = '0';
return 0;
}

if (exponent < EXP_MIN || exponent > EXP_MAX) {
return -1;
}
Expand All @@ -80,12 +86,6 @@ static int parse_decimal_number(char *dst,
return -1;
}

// 0. Abort early if number matches special case for zero
if (sign == 0 && exponent == 0 && mantissa == 0) {
dst[0] = '0';
return 0;
}

// 1. Add leading minus sign if number is negative
if (sign == 0) {
dst[0] = '-';
Expand Down

0 comments on commit 323f28a

Please sign in to comment.