34 lines
691 B
Go
34 lines
691 B
Go
package attribute
|
|
|
|
func NewFixedNumeric(pData float32) FixedNumeric {
|
|
fixed := FixedNumeric{}
|
|
fixed.Set(pData)
|
|
return fixed
|
|
}
|
|
|
|
type FixedNumeric struct {
|
|
baseValue FixedPoint
|
|
}
|
|
|
|
func (this FixedNumeric) Set(value float32) float32 {
|
|
this.baseValue = NewFixedPoint(value)
|
|
return this.baseValue.Scalar()
|
|
}
|
|
func (this FixedNumeric) Fixed() FixedPoint {
|
|
return this.baseValue
|
|
}
|
|
func (this FixedNumeric) Value() float32 {
|
|
return this.baseValue.Scalar()
|
|
}
|
|
|
|
/// <summary>
|
|
/// 减少基本值
|
|
/// </summary>
|
|
func (this FixedNumeric) Minus(value float32) float32 {
|
|
this.baseValue.Reduce(value)
|
|
if this.baseValue.Scalar() < 0 {
|
|
this.baseValue.SetInt(0)
|
|
}
|
|
return this.baseValue.Scalar()
|
|
}
|