summaryrefslogtreecommitdiff
path: root/asl/format_float.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/format_float.cpp')
-rw-r--r--asl/format_float.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/asl/format_float.cpp b/asl/format_float.cpp
new file mode 100644
index 0000000..425586f
--- /dev/null
+++ b/asl/format_float.cpp
@@ -0,0 +1,21 @@
+#include "asl/format.hpp"
+
+#include <cstdio>
+
+// @Todo Use something like ryu or dragonbox
+
+void asl::AslFormat(Formatter& f, float value)
+{
+ static constexpr isize_t kBufferLength = 64;
+ char buffer[kBufferLength];
+ int output_length = snprintf(buffer, kBufferLength, "%f", (double)value);
+ f.write(string_view(buffer, output_length));
+}
+
+void asl::AslFormat(Formatter& f, double value)
+{
+ static constexpr isize_t kBufferLength = 64;
+ char buffer[kBufferLength];
+ int output_length = snprintf(buffer, kBufferLength, "%f", value);
+ f.write(string_view(buffer, output_length));
+}