diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-07-04 14:54:45 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-07-04 14:54:45 +0900 |
| commit | 1efecaef1f867cb218366e2b4ab4b901fdd2835f (patch) | |
| tree | 3080a3d80a1a0671e8e82819d3f785465aace162 /src/mcp/json.c | |
| parent | 34e00404e9561dcaf8d2d99df7470757a4fee915 (diff) | |
途中経過コミット
Diffstat (limited to 'src/mcp/json.c')
| -rw-r--r-- | src/mcp/json.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mcp/json.c b/src/mcp/json.c index 62f31c9..59e2395 100644 --- a/src/mcp/json.c +++ b/src/mcp/json.c @@ -1,6 +1,7 @@ #include "mcp/json.h" #include <stdio.h> +#include <math.h> #include <stdlib.h> #include <string.h> @@ -172,3 +173,15 @@ tiny_json_i64(tiny_json_buffer_t *buffer, long long value) snprintf(text, sizeof(text), "%lld", value); return tiny_json_raw(buffer, text); } + +bool +tiny_json_number(tiny_json_buffer_t *buffer, double value) +{ + char text[32]; + if (!isfinite(value)) + { + return false; + } + snprintf(text, sizeof(text), "%.17g", value); + return tiny_json_raw(buffer, text); +} |
