Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
fixed8: handling <0 amounts properly
Browse files Browse the repository at this point in the history
  • Loading branch information
notatestuser committed Feb 13, 2019
1 parent 673efd2 commit a3a3669
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fixed8.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string.h>

#define DECIMAL_SCALE 8
#define ZERO_FRACTION "00000000"

int fixed8_str_conv(char *output, char *input) {
size_t input_len = strlen(input);
Expand All @@ -28,7 +29,8 @@ int fixed8_str_conv(char *output, char *input) {
strcpy(tmp, input);
output[0] = '0';
output[1] = '.';
strcpy(&output[2], tmp);
strcpy(&output[2], ZERO_FRACTION);
strcpy(&output[2 + (DECIMAL_SCALE - strlen(tmp))], tmp);
return 1;
}
int input_dec_offset = input_len - DECIMAL_SCALE;
Expand Down

0 comments on commit a3a3669

Please sign in to comment.