%f: -ddddddd.ddddd
(dst EncodingBuffer, neg bool, d decimalSlice, prec int)
| 391 | |
| 392 | // %f: -ddddddd.ddddd |
| 393 | func fmtF(dst EncodingBuffer, neg bool, d decimalSlice, prec int) { |
| 394 | // sign |
| 395 | if neg { |
| 396 | dst.WriteByte('-') |
| 397 | } |
| 398 | |
| 399 | // integer, padded with zeros as needed. |
| 400 | if d.dp > 0 { |
| 401 | m := min(d.nd, d.dp) |
| 402 | dst.Write(d.d[:m]) |
| 403 | for ; m < d.dp; m++ { |
| 404 | dst.WriteByte('0') |
| 405 | } |
| 406 | } else { |
| 407 | dst.WriteByte('0') |
| 408 | } |
| 409 | |
| 410 | // fraction |
| 411 | if prec > 0 { |
| 412 | dst.WriteByte('.') |
| 413 | for i := 0; i < prec; i++ { |
| 414 | ch := byte('0') |
| 415 | if j := d.dp + i; 0 <= j && j < d.nd { |
| 416 | ch = d.d[j] |
| 417 | } |
| 418 | dst.WriteByte(ch) |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | return |
| 423 | } |
| 424 | |
| 425 | // %b: -ddddddddp±ddd |
| 426 | func fmtB(dst EncodingBuffer, neg bool, mant uint64, exp int, flt *floatInfo) { |
no test coverage detected
searching dependent graphs…