summary refs log tree commit diff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-03 15:50:55 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-03 15:50:55 -0500
commit8937b6c918bc0814e1046a0ff06a206c3fb5ac34 (patch)
tree9cb7facbaeaf13892b5809e0de7d1a233cc7de87 /lisc
parentcab84cb96b04852f61e2fe1fd0c0ed6ec9fdd0ea (diff)
downloadroux-8937b6c918bc0814e1046a0ff06a206c3fb5ac34.tar.gz
add tool to show ieee representations
Diffstat (limited to 'lisc')
-rw-r--r--lisc/tools/fptox.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisc/tools/fptox.c b/lisc/tools/fptox.c
new file mode 100644
index 0000000..8f07565
--- /dev/null
+++ b/lisc/tools/fptox.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int ac, char *av[])
+{
+	double d;
+	float f;
+
+	if (ac < 2) {
+	usage:
+		fputs("usage: fptox NUMBER\n", stderr);
+		return 1;
+	}
+	f = d = strtod(av[1], 0);
+	printf("0x%08x 0x%016lx\n", *(unsigned *)&f, *(unsigned long long*)&d);
+	return 0;
+}