percent

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

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 0 Imported by: 1

README

percent.go

Build Status GoDoc Go Report Card

Calculate percentage in Golang.

Moved to new home

Install

go get github.com/negah/percent

Usage

/*
* Calculate what is [percent]% of [number]
*/
percent.Percent(25, 2000) // return 500

/*
* Calculate [number1] is what percent of [number2]
*/
percent.PercentOf(300, 2400) // return 12.5

/*
* Calculate what is the percentage increase/decrease from [number1] to [number2]
*/
percent.Change(20, 60) // return 200

Documentation

GoDoc

License

MIT

Author

Dariush Abbasi (@dariubs )

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Change

func Change(before int, after int) float64

Change calculate what is the percentage increase/decrease from [number1] to [number2] For example 60 is 200% increase from 20 It returns result as float64

func Percent

func Percent(pcent int, all int) float64

Percent calculate what is percent% of [number] using int values. For Example 25% of 200 is 50 It returns result as float64

func PercentFloat

func PercentFloat(pcent float64, all int) float64

PercentFloat calculate what is percent% of [number] using float values. For Example 0.3% of 200 is 0.6 It returns result as float64

func PercentOf

func PercentOf(current int, all int) float64

PercentOf calculate [number1] is what percent of [number2] For example 300 is 12.5% of 2400 It returns result as float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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