Skip to content

Commit 791bb7f

Browse files
committed
std/fmt: add support for complex types
1 parent c29d9f6 commit 791bb7f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

std/fmt/format.jule

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ fn formatByDefault(mut &buf: *strings::Builder, arg: any) {
5555
buf.WriteStr(conv::FormatFloat(f64(arg.(f32)), 'g', -1, 32))!
5656
| f64:
5757
buf.WriteStr(conv::FormatFloat(arg.(f64), 'g', -1, 64))!
58+
| cmplx64:
59+
buf.WriteStr(conv::FormatCmplx(cmplx128(arg.(cmplx64)), 'g', -1, 64))!
60+
| cmplx128:
61+
buf.WriteStr(conv::FormatCmplx(arg.(cmplx128), 'g', -1, 128))!
5862
| int:
5963
buf.WriteStr(conv::FormatInt(i64(arg.(int)), 10))!
6064
| i8:
@@ -200,6 +204,10 @@ fn bprintgw[T](mut &sb: *strings::Builder, t: T) {
200204
sb.WriteStr(conv::FormatFloat(f64(t), 'g', -1, 32))!
201205
| comptime::F64:
202206
sb.WriteStr(conv::FormatFloat(f64(t), 'g', -1, 64))!
207+
| comptime::Cmplx64:
208+
sb.WriteStr(conv::FormatCmplx(cmplx128(t), 'g', -1, 64))!
209+
| comptime::Cmplx128:
210+
sb.WriteStr(conv::FormatCmplx(cmplx128(t), 'g', -1, 128))!
203211
| comptime::Int | comptime::I8 | comptime::I16 | comptime::I32 | comptime::I64:
204212
sb.WriteStr(conv::FormatInt(i64(t), 10))!
205213
| comptime::Uint | comptime::U8 | comptime::U16 | comptime::U32 | comptime::U64:

0 commit comments

Comments
 (0)