linmath: Fix vector printing issues with big values on emscripten

This commit is contained in:
rdb 2024-11-03 23:59:23 +01:00
parent 8ff71aeb15
commit c060b2f3fe
2 changed files with 5 additions and 3 deletions

View File

@ -46,7 +46,8 @@
#define FLOATTYPE_REPR(v, str) do { \
double v_copy = (v); \
char *into_str = (str); \
if ((double)(long long)v_copy == v_copy) { \
if (v_copy < 1e16 && v_copy > -1e16 && \
(double)(long long)v_copy == v_copy) { \
snprintf(into_str, 32, "%lld", (long long)v_copy); \
} else { \
pdtoa(v_copy, into_str); \

View File

@ -46,8 +46,9 @@
#define FLOATTYPE_REPR(v, str) do { \
float v_copy = (v); \
char *into_str = (str); \
if ((float)(int)v_copy == v_copy) { \
snprintf(into_str, 32, "%d", (int)v_copy); \
if (v_copy < 1e16f && v_copy > -1e16f && \
(float)(long long)v_copy == v_copy) { \
snprintf(into_str, 32, "%lld", (long long)v_copy); \
} else { \
pftoa(v_copy, into_str); \
} \