decimal

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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