码迷,mamicode.com
首页 > 其他好文 > 详细

3.5

时间:2018-03-22 01:36:26      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:ace   print   sig   base   one   import   logs   fun   UNC   

package main

import (
    "fmt"
)

var integer int64 = 32500
var floatNum float64 = 22000.456

func main() {

    // Common way how to print the decimal
    // number
    fmt.Printf("%d \n", integer)

    // Always show the sign
    fmt.Printf("%+d \n", integer)

    // Print in other base x -16, o-8, b -2, d - 10
    fmt.Printf("%x \n", integer)
    fmt.Printf("%#x \n", integer)

    // Padding with leading zeros
    fmt.Printf("%010d \n", integer)

    // Left padding with spaces
    fmt.Printf("% 10d \n", integer)

    // Right padding
    fmt.Printf("% -10d \n", integer)

    // Print floating
    // point number
    fmt.Printf("%f \n", floatNum)

    // Floating point number
    // with limited precision = 5
    fmt.Printf("%.5f \n", floatNum)

    // Floating point number
    // in scientific notation
    fmt.Printf("%e \n", floatNum)

    // Floating point number
    // %e for large exponents
    // or %f otherwise
    fmt.Printf("%g \n", floatNum)

}

/*
32500
+32500
7ef4
0x7ef4
0000032500
     32500
 32500
22000.456000
22000.45600
2.200046e+04
22000.456

*/

3.5

标签:ace   print   sig   base   one   import   logs   fun   UNC   

原文地址:https://www.cnblogs.com/zrdpy/p/8620768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!