aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-19 01:32:27 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-19 01:32:27 -0400
commit14b4a674e82967b14d32eb52dfe5fa7d6ca60ee9 (patch)
tree940fb77750ef4206c9d0084ea4c46781e9971b11 /compile.c
parent08d6385674d7035f4e41e2f30e4f65f39c1cbf7e (diff)
Fix precision of compiled numbers
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 0fa19eb0..f9d1090a 100644
--- a/compile.c
+++ b/compile.c
@@ -1320,7 +1320,7 @@ CORD compile_arguments(env_t *env, ast_t *call_ast, arg_t *spec_args, arg_ast_t
Int_t int_val = Int$from_text(Match(call_arg->value, Int)->str);
double n = Int_to_Num(int_val);
value = CORD_asprintf(Match(spec_arg->type, NumType)->bits == TYPE_NBITS64
- ? "N64(%.9g)" : "N32(%.9g)", n);
+ ? "N64(%.99g)" : "N32(%.99g)", n);
} else {
env_t *arg_env = with_enum_scope(env, spec_arg->type);
type_t *actual_t = get_type(arg_env, call_arg->value);
@@ -1348,7 +1348,7 @@ CORD compile_arguments(env_t *env, ast_t *call_ast, arg_t *spec_args, arg_ast_t
Int_t int_val = Int$from_text(Match(call_arg->value, Int)->str);
double n = Int_to_Num(int_val);
value = CORD_asprintf(Match(spec_arg->type, NumType)->bits == TYPE_NBITS64
- ? "N64(%.9g)" : "N32(%.9g)", n);
+ ? "N64(%.99g)" : "N32(%.99g)", n);
} else {
env_t *arg_env = with_enum_scope(env, spec_arg->type);
type_t *actual_t = get_type(arg_env, call_arg->value);
@@ -1511,9 +1511,9 @@ CORD compile(env_t *env, ast_t *ast)
case Num: {
switch (Match(ast, Num)->bits) {
case NBITS_UNSPECIFIED: case NBITS64:
- return CORD_asprintf("N64(%.9g)", Match(ast, Num)->n);
+ return CORD_asprintf("N64(%.99g)", Match(ast, Num)->n);
case NBITS32:
- return CORD_asprintf("N32(%.9g)", Match(ast, Num)->n);
+ return CORD_asprintf("N32(%.99g)", Match(ast, Num)->n);
default: code_err(ast, "This is not a valid number bit width");
}
}