This commit is contained in:
hoteas 2018-01-28 17:30:47 +00:00
parent c726c66758
commit 6ecdd575aa
4 changed files with 39 additions and 4 deletions

5
map.go
View File

@ -78,7 +78,12 @@ func (this Map) GetCeilInt(key string, err ...*Error) int {
return v
}
//获取向上取整float64
func (this Map) GetCeilFloat64(key string, err ...*Error) float64 {
v := ObjToCeilFloat64((this)[key], err...)
return v
}
//获取Float64
func (this Map) GetFloat64(key string, err ...*Error) float64 {

16
obj.go
View File

@ -31,6 +31,16 @@ func (this *Obj) ToFloat64(err ...Error) float64 {
return ObjToFloat64(this.Data, &this.Error)
}
//获取向上取整float64
func (this *Obj) ToCeilFloat64(err ...*Error) float64 {
if len(err) != 0 {
this.Error = *err[0]
}
v := ObjToCeilFloat64(this.Data, err...)
return v
}
func (this *Obj) ToStr() string {
return ObjToStr(this.Data)
@ -57,12 +67,18 @@ func (this *Obj) ToObj() interface{} {
//获取向上取整Int64
func (this *Obj) ToCeilInt64(err ...*Error) int64 {
if len(err) != 0 {
this.Error = *err[0]
}
v := ObjToCeilInt64(this.Data, err...)
return v
}
//获取向上取整Int
func (this *Obj) ToCeilInt(err ...*Error) int {
if len(err) != 0 {
this.Error = *err[0]
}
v := ObjToCeilInt(this.Data, err...)
return v

View File

@ -134,14 +134,22 @@ func ObjToFloat64(obj interface{}, e ...*Error) float64 {
}
//向上取整
func ObjToCeilInt64(obj interface{}, e ...*Error)int64{
f:=ObjToFloat64(obj,e...)
return ObjToInt64(math.Ceil(f))
f:=ObjToCeilFloat64(obj,e...)
return ObjToInt64(math.Ceil(f))
}
//向上取整
func ObjToCeilFloat64(obj interface{}, e ...*Error)float64{
f:=ObjToFloat64(obj,e...)
return math.Ceil(f)
}
//向上取整
func ObjToCeilInt(obj interface{}, e ...*Error)int{
f:=ObjToFloat64(obj,e...)
return ObjToInt(math.Ceil(f))
f:=ObjToCeilFloat64(obj,e...)
return ObjToInt(f)
}

View File

@ -38,6 +38,12 @@ func (this Slice) GetCeilInt(key int, err ...*Error) int {
v := ObjToCeilInt((this)[key], err...)
return v
}
//获取向上取整float64
func (this Slice) GetCeilFloat64(key int, err ...*Error) float64 {
v := ObjToCeilFloat64((this)[key], err...)
return v
}
//获取Float64