Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UnicodeMinus = string([]rune{0x2212}) // unicode Minus sign, not accepted by math/big (*Float)Parse() ASCIIHyphen = "-" // actual ASCII hyphen-minus character 0x2d )
Functions ¶
func FindIndexes ¶
FindIndexes tries to parse a number from the input string.
Goals:
- numeric value identification find the right-most number in a string
Purpose:
numeric alignment: find the (virtual) position of the decimal point
numeric sorting: find the substring which can be converted into a number for numeric sorting
Notes:
- unicode "minus" (u+2212) will be accepted for negation
- Caution: unicode minus is NOT accepted by math/big.Float.Parse()!
- unicode minus must be translated before parsing by math/big.Float
- finding "numbers" in random strings is fuzzy at best
- the indexes returned, should always be parsable by math/big.Float
- if no number could be found, the "end" index will be 0
Types ¶
type Number ¶
type Number struct {
// alignment info
AlignIndex int // index of the decimal point within the field.Encoded string
// numerical value
Value *big.Float // numerical value of a field
}
Number represents a single numeric value, used for sorting and alignment.
Number structs are only intended for use for rendering, in [field.Field] structs.
See also: [version.Version]
func FromString ¶
FromString parses the right-most numerical value from a string.
If a number could be found, the number will be returned allong with the index of the (possibly virtual) decimal point in the input string.
Click to show internal directories.
Click to hide internal directories.