我正在跟随我的Scala教科书,我看到了这一点:
scala> val hex = 0x5
hex: Int = 5
scala> val hex2 = 0x00ff
hex2: Int = 255
scala> val hex3 = 0xff
hex2: Int = 255
scala> var hex4 = 0xbe
magic: Int = 190
scala> var hex5 = 0xFF
magic: Int = 255
val magic = 0xcafebabe
magic: Int = -889275714
scala> var prog = 0xCAFEBABEL
prog: Long = 3405691582
scala> val tower = 35l
tower: Long = 35
我的问题:
为什么在00
x
之后需要额外的0x00FF
?
我明白为什么FF
= 255 ...十六进制是从16 = 0和0F = 15开始的基数16.但为什么0xcafebabe
= -889275714?
为什么要继续使用多头?我不明白发生了什么事?
答案 0 :(得分:0)
答案 1 :(得分:-1)