cgen: fix string interpolation float type
parent
332d52f459
commit
54a02996f2
|
@ -18,12 +18,12 @@ pub fn complex(re f64, im f64) Complex {
|
|||
|
||||
// To String method
|
||||
pub fn (c Complex) str() string {
|
||||
mut out := '$c.re'
|
||||
mut out := '${c.re:f}'
|
||||
out += if c.im >= 0 {
|
||||
'+$c.im'
|
||||
'+${c.im:f}'
|
||||
}
|
||||
else {
|
||||
'$c.im'
|
||||
'${c.im:f}'
|
||||
}
|
||||
out += 'i'
|
||||
return out
|
||||
|
|
|
@ -2222,7 +2222,7 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) {
|
|||
[.enum_, .array, .array_fixed] {
|
||||
g.write('%.*s')
|
||||
} else if node.expr_types[i] in [table.f32_type, table.f64_type] {
|
||||
g.write('%f')
|
||||
g.write('%g')
|
||||
} else {
|
||||
g.write('%d')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue