Skip to content

Commit

Permalink
Fixed formatting of some decimal numbers
Browse files Browse the repository at this point in the history
Corrected bugs:
- Loss of precision in NUM_DECIMAL numbers
- Redundant trailing zero in decimal part
  • Loading branch information
Patrik Sletmo authored and TamtamHero committed Apr 29, 2020
1 parent f8c8cf5 commit 876226c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/xrp/parse/numberHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void formatNumberData(char* dst, uint16_t len, int16_t exponent, uint64_t mantis

void removeTrailingZeros(char* dst, int16_t *exponentParam) {
size_t strEnd = strlen(dst);
for (size_t i = strEnd - 1; i > 1; --i) {
for (size_t i = strEnd - 1; i > 0; --i) {
if (dst[i] == '0') {
(*exponentParam)++;
dst[i] = '\0';
Expand Down Expand Up @@ -163,7 +163,7 @@ void parseDecimal(char *dst, uint16_t len, int16_t *exponentParam) {
}

uint32_t uPosShift = (uint32_t) posShift;
os_memmove(dst + posShift, dst, uPosShift);
os_memmove(dst + posShift, dst, mantissaLength);
os_memset(dst, '0', uPosShift);

dst[1] = '.';
Expand Down

0 comments on commit 876226c

Please sign in to comment.