mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 19:00:06 +00:00
Fix %g in fmt, and make %v default to %g for floats
This commit is contained in:
@@ -2,6 +2,8 @@ package strconv
|
||||
|
||||
import "decimal"
|
||||
|
||||
import "core:runtime"
|
||||
|
||||
Decimal_Slice :: struct {
|
||||
digits: []byte,
|
||||
count: int,
|
||||
@@ -103,8 +105,11 @@ generic_ftoa :: proc(buf: []byte, val: f64, fmt: byte, precision, bit_size: int)
|
||||
}
|
||||
} else {
|
||||
switch fmt {
|
||||
case 'e', 'E': decimal.round(d, prec+1)
|
||||
case 'f', 'F': decimal.round(d, d.decimal_point+prec)
|
||||
case 'e', 'E':
|
||||
prec += 1
|
||||
decimal.round(d, prec)
|
||||
case 'f', 'F':
|
||||
decimal.round(d, d.decimal_point+prec)
|
||||
case 'g', 'G':
|
||||
if prec == 0 {
|
||||
prec = 1
|
||||
|
||||
Reference in New Issue
Block a user