mathi

package module
v0.0.0-...-775f868 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: MIT Imports: 1 Imported by: 0

README

mathi

mathi going to be a wrapper for golang math package but it going to accept or return int64 instead of float64

how to use

package main

import (
	"fmt"

	"github.com/m7shapan/mathi"
)

func main() {
	fmt.Println(mathi.RoundN(5.12355, 3)) // 5.124
}

supported math func

  • Abs
  • Ceil
  • Copysign
  • Dim
  • Floor
  • Max
  • Min
  • Pow
  • Pow10
  • Round
  • RoundToEven

new mathi func

  • RoundN

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) int64

Abs returns the absolute value of int64 x.

func Ceil

func Ceil(x float64) int64

Ceil returns the least integer value greater than or equal to x.

func Copysign

func Copysign(x, y int64) int64

Copysign returns a value with the magnitude of x and the sign of y.

func Dim

func Dim(x, y int64) int64

Dim returns the maximum of x-y or 0.

func Floor

func Floor(x float64) int64

Floor returns the greatest integer value less than or equal to x.

func Max

func Max(x, y int64) int64

Max returns the larger of x or y.

func Min

func Min(x, y int64) int64

Min returns the smaller of x or y.

func Pow

func Pow(x, y int64) int64

Pow returns x**y, the base-x exponential of y.

func Pow10

func Pow10(n int) int64

Pow10 returns 10**n, the base-10 exponential of n.

func Round

func Round(x float64) int64

Round returns the nearest integer, rounding half away from zero.

func RoundN

func RoundN(x float64, y int) float64

RoundN returns the nearest float64, rounding half away from zero with n number of digits.

func RoundToEven

func RoundToEven(x float64) int64

RoundToEven returns the nearest integer, rounding ties to even.

Types

This section is empty.

Jump to

Keyboard shortcuts

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