1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin, cgen: more -nofloat fixes

This commit is contained in:
Alexander Medvednikov
2021-09-13 19:06:19 +03:00
parent 8fc0b486a2
commit ae41d1d3c6
7 changed files with 204 additions and 169 deletions

View File

@ -353,62 +353,66 @@ fn (data StrIntpData) get_fmt_format(mut sb strings.Builder) {
match typ {
// floating point
.si_f32 {
// println("HERE: f32")
if use_default_str {
mut f := data.d.d_f32.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
$if !nofloat ? {
// println("HERE: f32")
if use_default_str {
mut f := data.d.d_f32.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} else {
// println("HERE: f32 format")
// println(data.d.d_f32)
if data.d.d_f32 < 0 {
bf.positive = false
}
mut f := strconv.format_fl(data.d.d_f32, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
sb.write_string(f)
f.free()
} else {
// println("HERE: f32 format")
// println(data.d.d_f32)
if data.d.d_f32 < 0 {
bf.positive = false
}
mut f := strconv.format_fl(data.d.d_f32, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
}
.si_f64 {
// println("HERE: f64")
if use_default_str {
mut f := data.d.d_f64.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f64 < 0 {
bf.positive = false
}
f_union := strconv.Float64u{
f: data.d.d_f64
}
if f_union.u == strconv.double_minus_zero {
bf.positive = false
}
$if !nofloat ? {
// println("HERE: f64")
if use_default_str {
mut f := data.d.d_f64.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f64 < 0 {
bf.positive = false
}
f_union := strconv.Float64u{
f: data.d.d_f64
}
if f_union.u == strconv.double_minus_zero {
bf.positive = false
}
mut f := strconv.format_fl(data.d.d_f64, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
mut f := strconv.format_fl(data.d.d_f64, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
sb.write_string(f)
f.free()
}
}
.si_g32 {
@ -552,55 +556,59 @@ fn (data StrIntpData) get_fmt_format(mut sb strings.Builder) {
}
}
.si_e32 {
// println("HERE: e32")
bf.len1 = 6
if use_default_str {
mut f := data.d.d_f32.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
$if !nofloat ? {
// println("HERE: e32")
bf.len1 = 6
if use_default_str {
mut f := data.d.d_f32.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f32 < 0 {
bf.positive = false
}
mut f := strconv.format_es(data.d.d_f32, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f32 < 0 {
bf.positive = false
}
mut f := strconv.format_es(data.d.d_f32, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
}
.si_e64 {
// println("HERE: e64")
bf.len1 = 6
if use_default_str {
mut f := data.d.d_f64.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
$if !nofloat ? {
// println("HERE: e64")
bf.len1 = 6
if use_default_str {
mut f := data.d.d_f64.str()
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f64 < 0 {
bf.positive = false
}
mut f := strconv.format_es(data.d.d_f64, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
sb.write_string(f)
f.free()
} else {
if data.d.d_f64 < 0 {
bf.positive = false
}
mut f := strconv.format_es(data.d.d_f64, bf)
if upper_case {
tmp := f
f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
}
}
// runes