用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
jdlsfl的公告
If If you can keep your head when all about you Are losing theirs and blaming it on you; If you can trust yourself when all men doubt you, But make allowance for their doubting too; If you can wait and not be tired by waiting, Or, being lied about, don’t deal in lies, Or, being hated, don’t give way to hating, And yet don’t look too good, nor talk too wise; If you can dream - and not make dreams your master; If you can think - and not make thoughts your aim; If you can meet with triumph and disaster And treat those two impostors just the same; If you can bear to hear the truth you’ve spoken Twisted by knaves to make a trap for fools, Or watch the things you gave your life to broken, And stoop and build ’em up with 5)worn-out tools; If you can make one heap of all your winnings And risk it on one turn of pitch-and-toss, And lose, and start again at your beginnings And never breathe a word about your loss; If you can force your heart and nerve and sinew To serve your turn long after they are gone, And so hold on when there is nothing in you Except the Will which says to them: “Hold on !”; If you can talk with crowds and keep your virtue, Or walk with Kings - nor lose the common touch; If neither foes nor loving friends can hurt you; If all men count with you, but none too much; If you can fill the unforgiving minute With sixty seconds “worth of distance run”Yours is the Earth and everything that’s in it, And - which is more - you’ll be a Man !
文章分类
IT
csdn(RSS)
存档

转载  Java的位移操作 收藏

“<<”, “>>”, “>>>”在Java中是左移、有符号右移和无符号右移运算符。位移运算符只对int值进行操作,如果不是int,编译器会报错。在Java中,一个int的长度始终是32bit,也就是4个字节。

比如t>>>n的含义就是把整数t右移n位,高位补上零。所以如果t是个负数,最高位是1,那么经过无符号右移之后,就成了一个正数。比如 -1>>>31=1。

值得注意的是,虚拟机在进行位移操作之前,把位移的位数(即“t>>>n”中的n)对32取了模,左移或右移33位等价于移动1位,而且无论任何数,使其移动32位,其值都不会发生变化。因为在虚拟机看来,t>>>32与t>>>0是等价的(同理t<<32等价于t<<0)。移动64位也是如此,以此类推。

那如果移动的位数 n 是负数怎么办呢?。 这时虚拟机会先让n对32取模,变成一个绝对值小于32的负数,然后再加上32,直到 n 变成一个正数。比如(k>>>-1) ==> (k>>>31); (k>>-43) ==> (k>>-11) ==> (k>>>21)。

发表于 @ 2008年06月21日 15:26:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:如何操作Cookie | 新一篇:Oracle10g 数据类型

  • 发表评论
  • 评论内容:
  •  
Copyright © jdlsfl
Powered by CSDN Blog