mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
add while and forever loops
This commit is contained in:
24
src/rounding.go
Normal file
24
src/rounding.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import "github.com/wadey/go-rounding"
|
||||
|
||||
func floor(x number) number {
|
||||
|
||||
n := newNumber().Set(x)
|
||||
if n.Sign() < 0 {
|
||||
return rounding.Round(n, 0, rounding.Up)
|
||||
}
|
||||
return rounding.Round(n, 0, rounding.Down)
|
||||
}
|
||||
|
||||
func ceil(x number) number {
|
||||
n := newNumber().Set(x)
|
||||
if n.Sign() < 0 {
|
||||
return rounding.Round(n, 0, rounding.Down)
|
||||
}
|
||||
return rounding.Round(n, 0, rounding.Up)
|
||||
}
|
||||
|
||||
func round(x number, precision int) number {
|
||||
return rounding.Round(newNumber().Set(x), precision, rounding.HalfUp)
|
||||
}
|
||||
Reference in New Issue
Block a user