diff options
| author | gingerBill <bill@gingerbill.org> | 2023-01-23 12:46:03 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-01-23 12:46:03 +0000 |
| commit | ea9fe397e572b33f4db70a878ef7c5fc6b8c5d43 (patch) | |
| tree | c11da6c2719860d6abab90c4e596bff2def03c76 | |
| parent | c482432966d3ea61544bd55a598907f3519ef29d (diff) | |
Fix typo in `decimal_to_float_bits`
| -rw-r--r-- | core/strconv/generic_float.odin | 8 | ||||
| -rw-r--r-- | core/strconv/strconv.odin | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/core/strconv/generic_float.odin b/core/strconv/generic_float.odin index 489124fbf..78edf5ca8 100644 --- a/core/strconv/generic_float.odin +++ b/core/strconv/generic_float.odin @@ -287,13 +287,13 @@ round_shortest :: proc(d: ^decimal.Decimal, mant: u64, exp: int, flt: ^Float_Inf @(private) decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64, overflow: bool) { - end :: proc "contextless" (d: ^decimal.Decimal, mant: u64, exp: int, info: ^Float_Info) -> (b: u64) { - bits := mant & (u64(1)<<info.mantbits - 1) + end :: proc "contextless" (d: ^decimal.Decimal, mant: u64, exp: int, info: ^Float_Info) -> (bits: u64) { + bits = mant & (u64(1)<<info.mantbits - 1) bits |= u64((exp-info.bias) & (1<<info.expbits - 1)) << info.mantbits if d.neg { bits |= 1<< info.mantbits << info.expbits } - return bits + return } set_overflow :: proc "contextless" (mant: ^u64, exp: ^int, info: ^Float_Info) -> bool { mant^ = 0 @@ -303,7 +303,7 @@ decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64 mant: u64 exp: int - if d.decimal_point == 0 { + if d.count == 0 { mant = 0 exp = info.bias b = end(d, mant, exp, info) diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index 0f27d5a1d..6d7374760 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -819,7 +819,7 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { } if mantissa>>_f64_info.mantbits != 0 { - return + break trunc_block } f := f64(mantissa) if neg { @@ -841,7 +841,6 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { return f / pow10[-exp], true } } - d: decimal.Decimal decimal.set(&d, str[:nr]) b, overflow := decimal_to_float_bits(&d, &_f64_info) |