Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Zero = decimal.Zero
Zero type alias for basic decimal.Zero
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
Decimal type alias for basic decimal.Decimal
func NewFromBigInt ¶
NewFromBigInt create decimal number from big int
Example ¶
package main import ( "fmt" "math/big" "github.com/cryptopay-dev/yaga/decimal" ) func main() { var bigInt big.Int bigInt.SetInt64(777) d := decimal.NewFromBigInt(&bigInt, 0) fmt.Println(d.String()) }
Output: 777
func NewFromFloat ¶
NewFromFloat return decimal from float number
Example ¶
package main import ( "fmt" "github.com/cryptopay-dev/yaga/decimal" ) func main() { d := decimal.NewFromFloat(0.5) fmt.Println(d) }
Output: 0.5
func NewFromString ¶
NewFromString return decimal and error from number in string
Example ¶
package main import ( "fmt" "github.com/cryptopay-dev/yaga/decimal" ) func main() { d, err := decimal.NewFromString("0.234") if err != nil { panic(err) } fmt.Println(d) }
Output: 0.234
Click to show internal directories.
Click to hide internal directories.