1 Star 1 Fork 0

iceinto / ipkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
float.go 750 Bytes
一键复制 编辑 原始数据 按行查看 历史
package iconv
import (
"gitee.com/iceinto/ipkg/ibinary"
"strconv"
)
// Float64 converts `any` to float64.
func Float64(any interface{}) float64 {
if any == nil {
return 0
}
switch value := any.(type) {
case float32:
return float64(value)
case float64:
return value
case []byte:
return ibinary.DecodeToFloat64(value)
default:
v, _ := strconv.ParseFloat(String(any), 64)
return v
}
}
// Float32 converts `any` to float32.
func Float32(any interface{}) float32 {
if any == nil {
return 0
}
switch value := any.(type) {
case float32:
return value
case float64:
return float32(value)
case []byte:
return ibinary.DecodeToFloat32(value)
default:
v, _ := strconv.ParseFloat(String(any), 64)
return float32(v)
}
}
1
https://gitee.com/iceinto/ipkg.git
git@gitee.com:iceinto/ipkg.git
iceinto
ipkg
ipkg
v1.0.2

搜索帮助