Posted on 2013-07-30 08:45
oathleo 閱讀(182)
評論(0) 編輯 收藏 所屬分類:
Golang
const Ln2= 0.693147180559945309417232121458\ 176568075500134360255254120680009 const Log2E= 1/Ln2 // this is a precise reciprocal const Billion = 1e9 // float constant const hardEight = (1 << 100) >> 97
根據(jù)上面的例子我們可以看到,反斜杠 \
可以在常量表達式中作為多行的連接符使用。
格式化說明符
在格式化字符串里,%d
用于格式化整數(shù)(%x
和 %X
用于格式化 16 進制表示的數(shù)字),%g
用于格式化浮點型(%f
輸出浮點數(shù),%e
輸出科學(xué)計數(shù)表示法),%0d
用于規(guī)定輸出定長的整數(shù),其中開頭的數(shù)字 0 是必須的。
%n.mg
用于表示數(shù)字 n 并精確到小數(shù)點后 m 位,除了使用 g 之外,還可以使用 e 或者 f,例如:使用格式化字符串 %5.2e
來輸出 3.4 的結(jié)果為3.40e+00
。