diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-22 16:21:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-22 16:21:56 -0400 |
| commit | 6272847917be186fa83f92b0580ed27f459014bd (patch) | |
| tree | 85b35863cc49d4c5c83c05e6d6dffb3f0a8a83a9 /src/bigfloat.cpp | |
| parent | 1ca78e39e4497821df352e0343132228e08894c3 (diff) | |
| parent | 02767690e0084ccbad2268c4f4abb0b2d2e8c30a (diff) | |
| download | zig-6272847917be186fa83f92b0580ed27f459014bd.tar.gz zig-6272847917be186fa83f92b0580ed27f459014bd.zip | |
Merge pull request #2094 from ziglang/f128-decimal-literal
float literals now parse using musl's 128 bit float code
Diffstat (limited to 'src/bigfloat.cpp')
| -rw-r--r-- | src/bigfloat.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/bigfloat.cpp b/src/bigfloat.cpp index cc442fa3b7..d746f1b68f 100644 --- a/src/bigfloat.cpp +++ b/src/bigfloat.cpp @@ -9,6 +9,7 @@ #include "bigint.hpp" #include "buffer.hpp" #include "softfloat.hpp" +#include "parse_f128.h" #include <stdio.h> #include <math.h> #include <errno.h> @@ -65,22 +66,18 @@ void bigfloat_init_bigint(BigFloat *dest, const BigInt *op) { } } -int bigfloat_init_buf_base10(BigFloat *dest, const uint8_t *buf_ptr, size_t buf_len) { +Error bigfloat_init_buf(BigFloat *dest, const uint8_t *buf_ptr, size_t buf_len) { char *str_begin = (char *)buf_ptr; char *str_end; errno = 0; - double value = strtod(str_begin, &str_end); // TODO actual f128 parsing + dest->value = parse_f128(str_begin, &str_end); if (errno) { return ErrorOverflow; } - float64_t value_f64; - memcpy(&value_f64, &value, sizeof(double)); - f64_to_f128M(value_f64, &dest->value); - assert(str_end <= ((char*)buf_ptr) + buf_len); - return 0; + return ErrorNone; } void bigfloat_add(BigFloat *dest, const BigFloat *op1, const BigFloat *op2) { |
