decimal

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 2 Imported by: 0

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

type Decimal = decimal.Decimal

Decimal type alias for basic decimal.Decimal

func New

func New(value int64, exp int32) Decimal

New create new decimal with value and exp

func NewFromBigInt

func NewFromBigInt(value *big.Int, exp int32) Decimal

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

func NewFromFloat(val float64) Decimal

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

func NewFromString(val string) (Decimal, error)

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

Jump to

Keyboard shortcuts

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