Documentation ¶
Overview ¶
Package rusnum contains functions to represent numbers and numerical quantities in russian words.
Index ¶
- func Billions(n int64) string
- func Centuries(n int64) string
- func Days(n int64) string
- func FloatInFractions(f float64, frac Fraction, showZero bool) string
- func FloatInFractionsAuto(f float64, showZero bool) string
- func FloatInWords(f float64, frac Fraction, binder Binder, zeroInt, zeroFrac, withZeros bool) string
- func FloatInWordsAuto(f float64, binder Binder, zeroInt, zeroFrac, withZeros bool) string
- func Hours(n int64) string
- func IntAndItems(n int64, showZero bool, items string) string
- func IntInWords(n int64, withZeros bool, gender GrammaticalGender) string
- func IntInWordsAndItems(n int64, showZero, withZeros bool, gender GrammaticalGender, items string) string
- func Kopecks(n int64) string
- func Microseconds(n int64) string
- func Milliards(n int64) string
- func MilliardsInWords(n int64) string
- func Millions(n int64) string
- func MillionsInWords(n int64) string
- func Milliseconds(n int64) string
- func Minutes(n int64) string
- func Months(n int64) string
- func NBillions(n int64, showZero bool) string
- func NCenturies(n int64, showZero bool) string
- func NDays(n int64, showZero bool) string
- func NHours(n int64, showZero bool) string
- func NInWordsCenturies(n int64, showZero, withZeros bool) string
- func NInWordsDays(n int64, showZero, withZeros bool) string
- func NInWordsHours(n int64, showZero, withZeros bool) string
- func NInWordsKopecks(n int64, showZero, withZeros bool) string
- func NInWordsMicroseconds(n int64, showZero, withZeros bool) string
- func NInWordsMilliseconds(n int64, showZero, withZeros bool) string
- func NInWordsMinutes(n int64, showZero, withZeros bool) string
- func NInWordsMonths(n int64, showZero, withZeros bool) string
- func NInWordsNanoseconds(n int64, showZero, withZeros bool) string
- func NInWordsRubles(n int64, showZero, withZeros bool) string
- func NInWordsSeconds(n int64, showZero, withZeros bool) string
- func NInWordsWeeks(n int64, showZero, withZeros bool) string
- func NInWordsYears(n int64, showZero, withZeros bool) string
- func NKopecks(n int64, showZero bool) string
- func NMicroseconds(n int64, showZero bool) string
- func NMilliards(n int64, showZero bool) string
- func NMillions(n int64, showZero bool) string
- func NMilliseconds(n int64, showZero bool) string
- func NMinutes(n int64, showZero bool) string
- func NMonths(n int64, showZero bool) string
- func NNanoseconds(n int64, showZero bool) string
- func NQuadrillions(n int64, showZero bool) string
- func NQuintillions(n int64, showZero bool) string
- func NRubles(n int64, showZero bool) string
- func NSeconds(n int64, showZero bool) string
- func NThousands(n int64, showZero bool) string
- func NTrillions(n int64, showZero bool) string
- func NWeeks(n int64, showZero bool) string
- func NYears(n int64, showZero bool) string
- func Nanoseconds(n int64) string
- func OnesInWords(n int64, gender GrammaticalGender) string
- func Quadrillions(n int64) string
- func QuadrillionsInWords(n int64) string
- func Quintillions(n int64) string
- func QuintillionsInWords(n int64) string
- func Rubles(n int64) string
- func Seconds(n int64) string
- func Thousands(n int64) string
- func ThousandsInWords(n int64) string
- func Trillions(n int64) string
- func TrillionsInWords(n int64) string
- func Weeks(n int64) string
- func Years(n int64) string
- type Binder
- type Fraction
- type GrammaticalGender
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Billions ¶
Billions returns russian for "milliard" corresponding to 'n'. ("billion" is called "milliard" in russian.)
func FloatInFractions ¶ added in v0.4.0
FloatInFractions returns 'f' expressed in 'fracs' in russian words. If result is 0 and 'showZero' is false, empty string is returned.
Example ¶
fmt.Println(FloatInFractions(21, Tenth, false)) fmt.Println(FloatInFractions(math.Ln2, Tenmilliardth, false))
Output: двести десять десятых шесть миллиардов девятьсот тридцать один миллион четыреста семьдесят одна тысяча восемьсот пять десятимиллиардных
func FloatInFractionsAuto ¶ added in v0.4.0
FloatInFractionsAuto is like FloatInFractions but determines the Fraction automatically.
Example ¶
fmt.Println(FloatInFractionsAuto(21, false)) fmt.Println(FloatInFractionsAuto(12.34, false)) fmt.Println(FloatInFractionsAuto(0.123456789, false)) fmt.Println(FloatInFractionsAuto(math.Log10E, false))
Output: двадцать один одна тысяча двести тридцать четыре сотых сто двадцать три миллиона четыреста пятьдесят шесть тысяч семьсот восемьдесят девять миллиардных сорок три миллиарда четыреста двадцать девять миллионов четыреста сорок восемь тысяч сто девянoсто стомиллиардных
func FloatInWords ¶
func FloatInWords(f float64, frac Fraction, binder Binder, zeroInt, zeroFrac, withZeros bool) string
FloatInWords returns 'f' in russian words. If f's integer part is 0 and 'zeroInt' is false, no integer part is returned. If f's fractional part is 0 and 'zeroFrac' is false, no fractional part is returned (see FloatInFractions). 'withZeros' is used by f's integer part (see IntInWords).
Example ¶
fmt.Println(FloatInWords(21, Tenth, Whole, false, true, false)) fmt.Println(FloatInWords(math.E, Hundredth, NoBinder, false, true, false)) fmt.Println(FloatInWords(math.E, Thousandth, And, false, true, false)) fmt.Println(FloatInWords(math.E, Millionth, Whole, false, true, false))
Output: двадцать одна целая ноль десятых два семьдесят одна сотая два и семьсот восемнадцать тысячных две целых семьсот восемнадцать тысяч двести восемьдесят одна миллионная
func FloatInWordsAuto ¶ added in v0.3.0
FloatInWordsAuto is like FloatInWords but determines the Fraction automatically.
Example ¶
fmt.Println(FloatInWordsAuto(21, Whole, false, false, false)) fmt.Println(FloatInWordsAuto(math.Pi, Whole, false, false, false))
Output: двадцать одна целая три целых четырнадцать миллиардов сто пятьдесят девять миллионов двести шестьдесят пять тысяч триста пятьдесят восемь стомиллиардных
func IntAndItems ¶
IntAndItems returns string containing 'n' and 'items'. If 'n' is 0 and 'showZero' is false, empty string is returned.
func IntInWords ¶
func IntInWords(n int64, withZeros bool, gender GrammaticalGender) string
IntInWords returns 'n' in russian words. If 'withZeros' is false, zero triples are omitted. 'gender' determines russian grammatical gender for ones of numbers ending in 1 or 2.
Example ¶
fmt.Println(IntInWords(21, true, Neuter)) fmt.Println(IntInWords(-1032, true, Feminine)) fmt.Println(IntInWords(2000001, true, Feminine)) fmt.Println(IntInWords(2000000001, false, Masculine))
Output: двадцать одно минус одна тысяча тридцать две два миллиона ноль тысяч одна два миллиарда один
func IntInWordsAndItems ¶
func IntInWordsAndItems(n int64, showZero, withZeros bool, gender GrammaticalGender, items string) string
IntInWordsAndItems returns string containing 'n' in russian words and 'items'. If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
Example ¶
fmt.Println(IntInWordsAndItems(2, false, false, Masculine, "кирпича"))
Output: два кирпича
func Microseconds ¶
Microseconds returns russian for "microsecond" corresponding to 'n'.
func MilliardsInWords ¶ added in v0.6.1
MilliardsInWords returns milliards (next three digits after millions) of 'n' in russian words.
func MillionsInWords ¶ added in v0.6.1
MillionsInWords returns millions (next three digits after thousands) of 'n' in russian words.
func Milliseconds ¶
Milliseconds returns russian for "millisecond" corresponding to 'n'.
func NBillions ¶
NBillions returns string containing 'n' and corresponding russian for "milliard". ("billion" is called "milliard" in russian.) If 'n' is 0 and 'showZero' is false, empty string is returned.
func NCenturies ¶
NCenturies returns string containing 'n' and corresponding russian for "century". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NDays ¶
NDays returns string containing 'n' and corresponding russian for "day". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NHours ¶
NHours returns string containing 'n' and corresponding russian for "hour". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NInWordsCenturies ¶
NInWordsCenturies returns string containing 'n' in russian words and corresponding russian for "century". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsDays ¶
NInWordsDays returns string containing 'n' in russian words and corresponding russian for "day". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsHours ¶
NInWordsHours returns string containing 'n' in russian words and corresponding russian for "hour". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsKopecks ¶
NInWordsKopecks returns string containing 'n' in russian words and corresponding russian for "kopeck". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsMicroseconds ¶
NInWordsMicroseconds returns string containing 'n' in russian words and corresponding russian for "microsecond". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsMilliseconds ¶
NInWordsMilliseconds returns string containing 'n' in russian words and corresponding russian for "millisecond". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsMinutes ¶
NInWordsMinutes returns string containing 'n' in russian words and corresponding russian for "minute". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsMonths ¶
NInWordsMonths returns string containing 'n' in russian words and corresponding russian for "month". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsNanoseconds ¶
NInWordsNanoseconds returns string containing 'n' in russian words and corresponding russian for "nanosecond". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsRubles ¶
NInWordsRubles returns string containing 'n' in russian words and corresponding russian for "ruble". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
Example ¶
fmt.Println(NInWordsRubles(2, false, false)) fmt.Println(NInWordsRubles(2000001, false, true))
Output: два рубля два миллиона ноль тысяч один рубль
func NInWordsSeconds ¶
NInWordsSeconds returns string containing 'n' in russian words and corresponding russian for "second". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsWeeks ¶
NInWordsWeeks returns string containing 'n' in russian words and corresponding russian for "week". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NInWordsYears ¶
NInWordsYears returns string containing 'n' in russian words and corresponding russian for "year". If 'n' is 0 and 'showZero' is false, empty string is returned. If 'withZeros' is false, zero triples are omitted.
func NKopecks ¶
NKopecks returns string containing 'n' and corresponding russian for "kopeck". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMicroseconds ¶
NMicroseconds returns string containing 'n' and corresponding russian for "microsecond". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMilliards ¶
NMilliards returns string containing 'n' and corresponding russian for "milliard". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMillions ¶
NMillions returns string containing 'n' and corresponding russian for "million". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMilliseconds ¶
NMilliseconds returns string containing 'n' and corresponding russian for "millisecond". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMinutes ¶
NMinutes returns string containing 'n' and corresponding russian for "minute". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NMonths ¶
NMonths returns string containing 'n' and corresponding russian for "month". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NNanoseconds ¶
NNanoseconds returns string containing 'n' and corresponding russian for "nanosecond". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NQuadrillions ¶
NQuadrillions returns string containing 'n' and corresponding russian for "quadrillion". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NQuintillions ¶
NQuintillions returns string containing 'n' and corresponding russian for "quintillion". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NRubles ¶
NRubles returns string containing 'n' and corresponding russian for "ruble". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NSeconds ¶
NSeconds returns string containing 'n' and corresponding russian for "second". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NThousands ¶
NThousands returns string containing 'n' and corresponding russian for "thousand". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NTrillions ¶
NTrillions returns string containing 'n' and corresponding russian for "trillion". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NWeeks ¶
NWeeks returns string containing 'n' and corresponding russian for "week". If 'n' is 0 and 'showZero' is false, empty string is returned.
func NYears ¶
NYears returns string containing 'n' and corresponding russian for "year". If 'n' is 0 and 'showZero' is false, empty string is returned.
func Nanoseconds ¶
Nanoseconds returns russian for "nanosecond" corresponding to 'n'.
func OnesInWords ¶ added in v0.6.1
func OnesInWords(n int64, gender GrammaticalGender) string
OnesInWords returns ones (three lower digits) of 'n' in russian words. 'gender' determines russian grammatical gender for ones of numbers ending in 1 or 2.
func Quadrillions ¶
Quadrillions returns russian for "quadrillion" corresponding to 'n'.
func QuadrillionsInWords ¶ added in v0.6.1
QuadrillionsInWords returns quadrillions (next three digits after trillions) of 'n' in russian words.
func Quintillions ¶
Quintillions returns russian for "quintillion" corresponding to 'n'.
func QuintillionsInWords ¶ added in v0.6.1
QuintillionsInWords returns quintillions (next three digits after quadrillions) of 'n' in russian words.
func ThousandsInWords ¶ added in v0.6.1
ThousandsInWords returns thousands (next three digits after ones) of 'n' in russian words.
func TrillionsInWords ¶ added in v0.6.1
TrillionsInWords returns trillions (next three digits after milliards) of 'n' in russian words.
Types ¶
type GrammaticalGender ¶
type GrammaticalGender int
GrammaticalGender - russian grammatical gender.
const ( // Neuter grammatical gender. Neuter GrammaticalGender = iota // Masculine grammatical gender. Masculine // Feminine grammatical gender. Feminine )