add while and forever loops

This commit is contained in:
2023-03-12 01:10:31 +00:00
parent 27a1abe160
commit 4619f1c278
23 changed files with 655 additions and 112 deletions

24
src/rounding.go Normal file
View 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)
}