currency

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrencyUnit

type CurrencyUnit int64

CurrencyUnit 货币单位类型

const (
	OneUnit = 1000000 // 1元 = 1,000,000 微元(精度6位小数)

	Yuan CurrencyUnit = OneUnit * 1      // 1元 = 1,000,000 微元
	Jiao CurrencyUnit = OneUnit / 10     // 1角 = 100,000 微元
	Fen  CurrencyUnit = OneUnit / 100    // 1分 = 10,000 微元
	Li   CurrencyUnit = OneUnit / 1000   // 1厘 = 1,000 微元
	Mao  CurrencyUnit = OneUnit / 10000  // 1毫 = 100 微元
	Si   CurrencyUnit = OneUnit / 100000 // 1丝 = 10 微元
)

func FromFloat64

func FromFloat64(value float64) CurrencyUnit

FromFloat64 从浮点数创建货币单位

func (CurrencyUnit) ConvertTo

func (c CurrencyUnit) ConvertTo(target Unit) int64

ConvertTo 转换为指定单位

func (CurrencyUnit) Float64

func (c CurrencyUnit) Float64() float64

Float64 转换为浮点数

func (CurrencyUnit) ToYuanString

func (c CurrencyUnit) ToYuanString() string

ToYuanString 转换为元字符串

type Unit

type Unit int

Unit 货币单位

const (
	UnitYuan Unit = iota // 元
	UnitJiao             // 角
	UnitFen              // 分
	UnitLi               // 厘
	UnitMao              // 毫
	UnitSi               // 丝
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL