//二进制,1左移动10位
package main import "fmt" const( _ = iota //丢弃iota的零值,const出现时,iota被重置为零 KB = 1 << (10 * iota) //左移10*1,10位 MB = 1 << (10 * iota)//左移10*2,20位 GB = 1 << (10 * iota)//左移10*3,30位 TB = 1 << (10 * iota)//左移10*4,40位 PB = 1 << (10 * iota)//左移10*5,50位 ) //存储空间单位换算 func main () { s := "Byte" fmt.Printf("KB= %b %s \n",KB,s) fmt.Printf("MB= %b %s \n",MB,s) fmt.Printf("GB= %b %s \n",GB,s) fmt.Printf("TB= %b %s \n",TB,s) fmt.Printf("PB= %b %s \n",PB,s) } |
1000000000
KB= 10000000000 Byte
MB= 100000000000000000000 Byte
GB= 1000000000000000000000000000000 Byte
TB= 10000000000000000000000000000000000000000 Byte
PB= 100000000000000000000000000000000000000000000000000 Byte