From 671f81137ee2e5de632526109e02c4b79197e432 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 10 Aug 2024 16:03:00 -0400 Subject: Make Num32/Num64 literals explicitly typed to aid in macros using __typeof --- builtins/nums.h | 2 ++ compile.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builtins/nums.h b/builtins/nums.h index ec1663a2..b426f6ef 100644 --- a/builtins/nums.h +++ b/builtins/nums.h @@ -11,6 +11,8 @@ #define Num_t double #define Num32_t float +#define N32(n) ((float)n) +#define N64(n) ((double)n) CORD Num$as_text(const double *f, bool colorize, const TypeInfo *type); int32_t Num$compare(const double *x, const double *y, const TypeInfo *type); diff --git a/compile.c b/compile.c index 14a72a29..8ac4d37a 100644 --- a/compile.c +++ b/compile.c @@ -1307,7 +1307,7 @@ CORD compile(env_t *env, ast_t *ast) } case Int: return CORD_asprintf("I%ld(%ld)", Match(ast, Int)->bits, Match(ast, Int)->i); case Num: { - return CORD_asprintf(Match(ast, Num)->bits == 64 ? "%.9g" : "(float)%.9g", Match(ast, Num)->n); + return CORD_asprintf(Match(ast, Num)->bits == 64 ? "N64(%.9g)" : "N32(%.9g)", Match(ast, Num)->n); } case Length: { ast_t *expr = Match(ast, Length)->value; -- cgit v1.2.3