10 examples of 'golang int to float64' in Go

Every line of 'golang int to float64' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
18func (stdRecipes) int8ToFloat64(c Converter, in int8, out *float64) error {
19 *out = float64(in)
20 return nil
21}
54func uint64tofloat64(y uint64) float64 {
55 hi := float64(uint32(y >> 32))
56 lo := float64(uint32(y))
57 d := hi*(1<<32) + lo
58 return d
59}
68func (stdRecipes) float64ToInt32(c Converter, in float64, out *int32) error {
69 *out = int32(in)
70 return nil
71}
46func (stdRecipes) uint32ToFloat64(c Converter, in uint32, out *float64) error {
47 *out = float64(in)
48 return nil
49}
26func (stdRecipes) int32ToFloat64(c Converter, in int32, out *float64) error {
27 *out = float64(in)
28 return nil
29}
68func (stdRecipes) float64ToUint(c Converter, in float64, out *uint) error {
69 *out = uint(in)
70 return nil
71}
76func Float64ToInt8(v float64) (int8, error) {
77 if v > math.MaxInt8 || v < math.MinInt8 {
78 return 0, errOverflowValue
79 }
80 return int8(v), nil
81}
46func interface_to_float64(dat []interface{}) []float64 {
47 ret := make([]float64, len(dat))
48 for i, val := range dat {
49 switch v := val.(type) {
50 case int:
51 ret[i] = float64(v)
52 case float64:
53 ret[i] = v
54 default:
55 ret[i] = 0.0
56 }
57 }
58
59 return ret
60}
85func (p *parser) Float64(i int, context string) float64 {
86 s := p.String(i, context)
87 if p.err != nil {
88 return 0
89 }
90 if s == "" {
91 return 0
92 }
93 v, err := strconv.ParseFloat(s, 64)
94 if err != nil {
95 p.SetErr(context, s)
96 }
97 return v
98}
32func float64FromC(c C.int, d C.double) (float64, error) {
33 if c == 0 {
34 return 0.0, Error()
35 }
36 return float64(d), nil
37}

Related snippets