Skip to content

Commit

Permalink
Add fp example
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Jun 8, 2023
1 parent 17220fd commit 23ebc5c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ static void test_float(void) {
TEST_FLOAT("%g", HUGE_VAL, "inf");
TEST_FLOAT("%g", -HUGE_VAL, "-inf");
#endif

{
char buf[20];
double d;
json_get_num("1.23", 4, "$", &d); // Parse floating point number
xsnprintf(buf, sizeof(buf), "%g", d); // 1.23 (print parsed number)
}
}

static void out(char ch, void *arg) {
Expand Down

0 comments on commit 23ebc5c

Please sign in to comment.