Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 518 | |
| 519 | // Format implements the NodeFormatter interface. |
| 520 | func (d *DDecimal) Format(ctx *FmtCtx) { |
| 521 | // If the number is negative, we need to use parens or the `:::INT` type hint |
| 522 | // will take precedence over the negation sign. |
| 523 | disambiguate := ctx.flags.HasFlags(fmtDisambiguateDatumTypes) |
| 524 | parsable := ctx.flags.HasFlags(FmtParsableNumerics) |
| 525 | quote := parsable && d.Decimal.Form != apd.Finite |
| 526 | needParens := !quote && (disambiguate || parsable) && d.Negative |
| 527 | if needParens { |
| 528 | ctx.WriteByte('(') |
| 529 | } |
| 530 | if quote { |
| 531 | ctx.WriteByte('\'') |
| 532 | } |
| 533 | ctx.WriteString(d.Decimal.String()) |
| 534 | if quote { |
| 535 | ctx.WriteByte('\'') |
| 536 | } |
| 537 | if needParens { |
| 538 | ctx.WriteByte(')') |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | // SizeOfDecimal returns the size in bytes of an apd.Decimal. |
| 543 | func SizeOfDecimal(d apd.Decimal) uintptr { |
nothing calls this directly
no test coverage detected