saint

package module
v0.0.0-...-b5b5ec0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2017 License: MIT Imports: 0 Imported by: 1

README

Docs

saint

License License GoDoc

Go (Golang) Math Library for Integer Operations

Any Math operations that not support integer, can used this library

Index

Support

You can also email iman.tumorang@gmail.com or file an Issue. See documentation in Godoc

Getting Started

Download
go get -u github.com/bxcodec/saint

Example


package main

import (
	"fmt"
	"github.com/bxcodec/saint"
)

func main() {
	 	
    
   arr:=[] int {2,1,3,5,6}
   var x int 

   x= saint.Max(arr...) 
   fmt.Println(x) // 6

   x= saint.Max(4,3,1,5,7) 
   fmt.Println(x) // 7

   x= saint.Min(arr...) 
   fmt.Println(x) // 1

   x= saint.Min(4,3,5,5,7) 
   fmt.Println(x) // 3

   x= saint.Sum(arr...) 
   fmt.Println(x) // 17

   x = saint.Sum(4,5)
   fmt.Println(x) // 9
}


Documentation

Overview

This library only provide some of function that "math" library doesn't support especially in integer's operation (int data type) . Saint also provide some function to ease in some of operations.

Warning!!
Used only with int data type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(arg int) int

Returns the absolute value of integer's value from argument.

Example:
	x:=Abs(-5) // x = 5
	x:=Abs(5)  // x = 5

func Max

func Max(arg ...int) int

Return the maximun value beetwen all the integer's arguments. Return the maximun between two or more params. Return the maximun value from an array.

Example:
	x:=Max(5,6,3,1,2,6) //  x = 6
	y:=Max(5,5,32,2) //  y = 32

	arr:=[] int {2,1,3,5,6}
	x = Max(arr...) // x = 6

func Min

func Min(arg ...int) int

Return the minimun value beetwen all the integer's arguments. Return the minimun between two or more params. Return the minimun value from an array.

Example:
	x:=Min(5,6,3,1,2,6) //  x = 1
	y:=Min(5,5,32,2) //  y = 2

	arr:=[] int {2,1,3,5,6}
	x = Min(arr...) // x = 1

func Multiply

func Multiply(arg int, arg0 int) int

Returns the multiplication result from the integer's argument, between arg to arg0.

Example :

x:=Multiply(2,3) // 6
x:=Multiply(3,3) // 9

func Pow

func Pow(arg int, arg0 int) int

Returns the power value of integer's argument from arg to arg0.

Example :

x:=Pow(2,3) // 8
x:=Pow(3,3) // 27

func Substract

func Substract(arg int, arg0 int) int

Returned substracted of integers from the arguments between arg and arg0.

Example:
	x:=Substract(5,6) //  x = -1
	y:=Substract(5,2) //  y = 3

func Sum

func Sum(arg ...int) int

Returned sum of integers from the arguments. Sum array's value from the arguments. Sum between two or more arguments.

Example:
	x:=Sum(5,6,3,1,2,6) //  x = 23
	y:=Sum(5,2) //  y = 7

	arr:=[] int {2,1,3,5,6}
	x = Sum(arr...) // x =17

Types

This section is empty.

Jump to

Keyboard shortcuts

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