Golang strconv.AppendFloat() function example
package strconv
Golang strconv.AppendFloat() function usage example.
package main
import (
"fmt"
"strconv"
)
func main() {
//func AppendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte
dst := []byte("Float is ")
fmt.Println("Before : ", string(dst))
b := strconv.AppendFloat(dst, 2, 'e', 5, 64)
fmt.Println("After : ", string(b))
b = strconv.AppendFloat(dst, 523, 'e', 2, 64)
fmt.Println("After : ", string(b))
}
Output :
Before : Float is
After : Float is 2.00000e+00
After : Float is 5.23e+02
Reference :
Advertisement
Something interesting
Tutorials
+17.5k Golang : Find smallest number in array
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+10k Golang : Setting variable value with ldflags
+17k Golang : Get input from keyboard
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax
+9.6k Golang : Copy map(hash table) example
+7.8k Golang : Scan files for certain pattern and rename part of the files
+12k Golang : Decompress zlib file example
+6.5k PHP : Shuffle to display different content or advertisement
+15.3k nginx: [emerg] unknown directive "ssl"
+6.9k Golang : Fibonacci number generator examples
+10k Golang : Read file and convert content to string