MCPcopy
hub / github.com/pquerna/ffjson / fmtF

Function fmtF

fflib/v1/ftoa.go:393–423  ·  view source on GitHub ↗

%f: -ddddddd.ddddd

(dst EncodingBuffer, neg bool, d decimalSlice, prec int)

Source from the content-addressed store, hash-verified

391
392// %f: -ddddddd.ddddd
393func 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
426func fmtB(dst EncodingBuffer, neg bool, mant uint64, exp int, flt *floatInfo) {

Callers 1

formatDigitsFunction · 0.70

Calls 3

minFunction · 0.85
WriteByteMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…