aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-19 01:46:37 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-19 01:46:37 -0400
commit752be14eed4c56186b0a814980445b279ea88661 (patch)
treeca9d03e9e6c8b21e50758f62eac33d2c248ed7ea /compile.c
parent14b4a674e82967b14d32eb52dfe5fa7d6ca60ee9 (diff)
Fix some numeric precision issues with how nums are printed
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 f9d1090a..03e0a077 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(%.99g)" : "N32(%.99g)", n);
+ ? "N64(%.20g)" : "N32(%.10g)", 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(%.99g)" : "N32(%.99g)", n);
+ ? "N64(%.20g)" : "N32(%.10g)", 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(%.99g)", Match(ast, Num)->n);
+ return CORD_asprintf("N64(%.20g)", Match(ast, Num)->n);
case NBITS32:
- return CORD_asprintf("N32(%.99g)", Match(ast, Num)->n);
+ return CORD_asprintf("N32(%.10g)", Match(ast, Num)->n);
default: code_err(ast, "This is not a valid number bit width");
}
}