about summary refs log tree commit diff stats
path: root/js/scripting-lang/baba-yaga-c/test_precision.c
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/baba-yaga-c/test_precision.c')
-rw-r--r--js/scripting-lang/baba-yaga-c/test_precision.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/scripting-lang/baba-yaga-c/test_precision.c b/js/scripting-lang/baba-yaga-c/test_precision.c
new file mode 100644
index 0000000..e6a986d
--- /dev/null
+++ b/js/scripting-lang/baba-yaga-c/test_precision.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <string.h> // Added for strlen
+int main() {
+    double x = 1.0 / 3.0;
+    printf("x = %.15g\n", x);
+    printf("(long)x = %ld\n", (long)x);
+    printf("x == (long)x: %s\n", x == (long)x ? "true" : "false");
+    
+    char buffer[128];
+    if (x == (long)x) {
+        snprintf(buffer, sizeof(buffer), "%ld", (long)x);
+        printf("Using integer format: '%s'\n", buffer);
+    } else {
+        snprintf(buffer, sizeof(buffer), "%.15g", x);
+        printf("Using float format: '%s'\n", buffer);
+    }
+    return 0;
+}
1fcd51a5fd891b7dae7e7aa53de4'>^
b96af395 ^




f184c95e ^

0ca35d02 ^
d4b4d018 ^
7d2c2d55 ^
4b62edd8 ^
7d2c2d55 ^
f184c95e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22