diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-22 14:56:03 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-22 14:56:03 -0400 |
| commit | 4615ed5ea003516c8235728ac3f5f0ee2ccea8a7 (patch) | |
| tree | 15d8bf63d72a2c343c13242031f02e746183137e /src/bigfloat.cpp | |
| parent | 127bb124a06dc93f4def23224d400f4050754674 (diff) | |
| download | zig-4615ed5ea003516c8235728ac3f5f0ee2ccea8a7.tar.gz zig-4615ed5ea003516c8235728ac3f5f0ee2ccea8a7.zip | |
float literals now parse using musl's 128 bit float code
fixes float literals not having 128 bit precision
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) { |
