go_dreamfactory/modules/battle/fight/attribute/fixedpoint.go
2022-09-08 10:39:55 +08:00

25 lines
369 B
Go

package attribute
import (
"math"
)
//基准倍数
const CARDINAL_NUMBER int = 10000
func NewFixedPoint(value float32) *FixedPoint {
return &FixedPoint{
rawValue: int(math.Round(float64(value * float32(CARDINAL_NUMBER)))),
}
}
type FixedPoint struct {
rawValue int
scalar float32
}
func (this *FixedPoint) Scalar() float32 {
return this.scalar * 0.0001
}