Skip to content
This repository has been archived by the owner on Nov 14, 2019. It is now read-only.

Fix precision bug of ftoa while exp is greater than 23 #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.default.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"server_name" : "brubeck_debug",
"dumpfile" : "./brubeck.dump",
"capacity" : 15,
"expire" : 5,
"expire" : 20,
"http" : ":8080",

"backends" : [
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void url_to_inaddr2(struct sockaddr_in *addr, const char *url, int port)

#define FLOAT_PRECISION 4

int brubeck_itoa(char *ptr, uint32_t number)
int brubeck_itoa(char *ptr, uint64_t number)
{
char *origin = ptr;
int size;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void sock_enlarge_in(int fd);

char *find_substr(const char *s, const char *find, size_t slen);

int brubeck_itoa(char *ptr, uint32_t number);
int brubeck_itoa(char *ptr, uint64_t number);
int brubeck_ftoa(char *outbuf, float f);

static inline int starts_with(const char *str, const char *prefix)
Expand Down
1 change: 1 addition & 0 deletions tests/ftoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ void test_ftoa(void)
check_eq(1234.567, "1234.567");
check_eq(99999.999, "100000");
check_eq(0.999, "0.999");
check_eq(43427902563.12, "43427901440");
}