2
Watch
33
Star
8
Fork
0
Issue

Simple library for calculate percentages in Go.

dariubs
dariubs
pushedAt 1 month ago

dariubs/percent

percent.go

test workflow GoDoc Go Report Card

Calculate percentage in Golang.

Install

go get github.com/dariubs/percent

Usage

// Percent - calculate what %[number1] of [number2] is.
percent.Percent(25, 200) // return 50
percent.PercentFloat(25.0, 200.0) // return 50.0

// PercentOf - calculate what percent [number1] is of [number2].
percent.PercentOf(300, 2400) // return 12.5
percent.PercentOfFloat(300.0, 2400.0) // return 12.5

// Change - calculate the percent increase/decrease from two numbers.  
percent.Change(20, 60) // return 200.0
percent.ChangeFloat(20.0, 60.0) // return 200.0

Documentation

GoDoc

License

MIT

Author

Dariush Abbasi (@dariubs )

ucloud ads