Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 985 Bytes

README.md

File metadata and controls

27 lines (21 loc) · 985 Bytes

MIT GoDoc Go Report Card

numcn

Interconversion between Chinese numbers & Numbers. 中文数字与数字的相互转换。

Example

func main() {
	chNum := "负十七亿零五十三万七千零一十六"
	num, _ := numcn.DecodeToInt64(chNum)
	fmt.Println(num) // -1700537016
	chNumAgain := numcn.EncodeFromInt64(num)
	fmt.Println(chNumAgain) // 负十七亿零五十三万七千零一十六

	chFloatNum := "负零点零七三零六"
	fNum, _ := numcn.DecodeToFloat64(chFloatNum)
	fmt.Printf("%f\n", fNum) // -0.073060
	chFloatNumAgain := numcn.EncodeFromFloat64(fNum)
	fmt.Println(chFloatNumAgain) // 负零点零七三零六
}