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

Function parseCompatibleNumericLiteral

go/fory/compatible_scalar.go:835–961  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

833}
834
835func parseCompatibleNumericLiteral(s string) (*big.Rat, bool, bool) {
836 if len(s) == 0 || len(s) > maxCompatibleNumericTextLen {
837 return nil, false, false
838 }
839
840 pos := 0
841 neg := s[pos] == '-'
842 if neg {
843 pos++
844 if pos == len(s) {
845 return nil, false, false
846 }
847 }
848
849 intStart := pos
850 significantDigits := int64(0)
851 seenNonZero := false
852 if s[pos] == '0' {
853 countCompatibleDigit(s[pos], &seenNonZero, &significantDigits)
854 pos++
855 if pos < len(s) && isASCIIDigit(s[pos]) {
856 return nil, false, false
857 }
858 } else if s[pos] >= '1' && s[pos] <= '9' {
859 for pos < len(s) && isASCIIDigit(s[pos]) {
860 countCompatibleDigit(s[pos], &seenNonZero, &significantDigits)
861 pos++
862 }
863 } else {
864 return nil, false, false
865 }
866 intEnd := pos
867
868 fracStart := pos
869 fracEnd := pos
870 if pos < len(s) && s[pos] == '.' {
871 pos++
872 fracStart = pos
873 for pos < len(s) && isASCIIDigit(s[pos]) {
874 countCompatibleDigit(s[pos], &seenNonZero, &significantDigits)
875 pos++
876 }
877 if pos == fracStart {
878 return nil, false, false
879 }
880 fracEnd = pos
881 }
882
883 exponent := int64(0)
884 if pos < len(s) && (s[pos] == 'e' || s[pos] == 'E') {
885 pos++
886 expNegative := false
887 if pos < len(s) && s[pos] == '-' {
888 expNegative = true
889 pos++
890 }
891 if pos == len(s) {
892 return nil, false, false

Callers 2

compatibleValueToDecimalFunction · 0.85

Calls 8

countCompatibleDigitFunction · 0.85
isASCIIDigitFunction · 0.85
compatibleDecimalShapeFunction · 0.85
pow10IntFunction · 0.85
NegMethod · 0.80
MulMethod · 0.80
decimalDigitCountFunction · 0.70
int64Function · 0.50

Tested by

no test coverage detected