MCPcopy Create free account
hub / github.com/apache/fory / finiteFloatRatString

Function finiteFloatRatString

go/fory/compatible_scalar.go:1125–1141  ·  view source on GitHub ↗
(rat *big.Rat, negZero bool)

Source from the content-addressed store, hash-verified

1123}
1124
1125func finiteFloatRatString(rat *big.Rat, negZero bool) (string, bool) {
1126 if negZero {
1127 return "-0.0", true
1128 }
1129 decimal, ok := canonicalDecimalFromRat(rat)
1130 if !ok {
1131 return "", false
1132 }
1133 text, ok := canonicalDecimalString(decimal)
1134 if !ok {
1135 return "", false
1136 }
1137 if !strings.Contains(text, ".") {
1138 text += ".0"
1139 }
1140 return text, true
1141}
1142
1143func pow10Int(exp int64) *big.Int {
1144 return new(big.Int).Exp(big.NewInt(10), big.NewInt(exp), nil)

Callers 1

compatibleValueToStringFunction · 0.85

Calls 3

canonicalDecimalFromRatFunction · 0.85
canonicalDecimalStringFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected