-
Notifications
You must be signed in to change notification settings - Fork 5
/
float64.go
40 lines (33 loc) · 965 Bytes
/
float64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package numtow
import (
"github.com/gammban/numtow/lang"
"github.com/gammban/numtow/lang/en"
"github.com/gammban/numtow/lang/kz"
"github.com/gammban/numtow/lang/ru"
)
// Float64 converts float64 number to words.
func Float64(decimal float64, language lang.Lang, options ...interface{}) (words string, err error) {
switch language {
case lang.KZ:
o := kz.ParseOpts(options...)
return kz.Float64(decimal, o...)
case lang.RU:
o := ru.ParseOpts(options...)
return ru.Float64(decimal, o...)
case lang.EN:
o := en.ParseOpts(options...)
return en.Float64(decimal, o...)
case lang.Unknown:
return words, lang.ErrBadLanguage
default:
return words, lang.ErrBadLanguage
}
}
// MustFloat64 returns float64 number converted to words or empty string on error.
func MustFloat64(decimal float64, language lang.Lang, options ...interface{}) string {
res, err := Float64(decimal, language, options...)
if err != nil {
return ""
}
return res
}