Skip to content

Commit

Permalink
fix fractional floating point values on platforms where unsigned < 64…
Browse files Browse the repository at this point in the history
… bits (#220)
  • Loading branch information
mateoconlechuga authored Jul 29, 2022
1 parent 5278931 commit 06b7f4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nanoprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,10 @@ int npf_fsplit_abs(float f, uint64_t *out_int_part, uint64_t *out_frac_part,
}

{ // Convert the fractional part to base 10.
unsigned frac_part = 0;
uint64_t frac_part = 0;
for (int i = 0; frac && (i < NPF_MAX_FRACTION_DEC_DIGITS); ++i) {
frac_part *= 10;
frac_part += (unsigned)(frac >> (NPF_FRACTION_BIN_DIGITS - 4));
frac_part += (uint64_t)(frac >> (NPF_FRACTION_BIN_DIGITS - 4));
frac &= 0x0fffffffffffffffllu;
frac *= 10;
}
Expand Down

0 comments on commit 06b7f4b

Please sign in to comment.