update
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/kataras/iris/v12/context"
|
||||
"io"
|
||||
"math"
|
||||
"pet-house.com/business/models"
|
||||
"time"
|
||||
)
|
||||
@@ -112,3 +113,7 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||
}
|
||||
return dayHoursMap
|
||||
}
|
||||
|
||||
func RoundToOneDecimalPlace(value float64) float64 {
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"pet-house.com/business/models"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -30,3 +31,26 @@ func TestCalc1(t *testing.T) {
|
||||
i := float64(85) / 100
|
||||
fmt.Println(i)
|
||||
}
|
||||
|
||||
func roundToOneDecimalPlace(value float64) float64 {
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
func TestCalc3(t *testing.T) {
|
||||
i := float64(348) * 0.95
|
||||
fmt.Println(i)
|
||||
}
|
||||
func TestCalc4(t *testing.T) {
|
||||
value := 267.77
|
||||
roundedValue := roundToOneDecimalPlace(value)
|
||||
fmt.Printf("%.1f\n", roundedValue) // 输出 3.1
|
||||
}
|
||||
func TestCalc5(t *testing.T) {
|
||||
var a = 1596
|
||||
float := strconv.FormatFloat(float64(a/10.0), 'f', 1, 64)
|
||||
fmt.Printf(float)
|
||||
}
|
||||
func TestMath(t *testing.T) {
|
||||
i := int(float64(256) * (85 / 100.0) * 10)
|
||||
fmt.Println(i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user