boolean Indexed = (bits & index) != 0 什么意思?

SHOUYU2 2008-09-25 02:20:08
看到一个程序部分代码如下
byte bits = 0x0
static final byte index = 0x1;
boolean Indexed = (bits & index) != 0
主要最后一句的意思不是很明白
先是bits和index项羽,然后为什么是非0?
...全文
97 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
junjun1984 2008-09-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lclg_silver 的回复:]
Java code
public static void main(String[] args){
System.out.println(true & true);
System.out.println(true & false);
System.out.println(4 & 5);
System.out.println('t' & 's');
}




输出结果是:
true
false
4
112

是不是这样:
如果&两端是boolean型,&就表示逻辑与
如果&两端是int型或char型,&就表示按位与
[/Quote]
4 & 5 ,100和101与,结果为100 = 4.
无尽飞羽 2008-09-25
  • 打赏
  • 举报
回复

public static void main(String[] args){
System.out.println(true & true);
System.out.println(true & false);
System.out.println(4 & 5);
System.out.println('t' & 's');
}


输出结果是:
true
false
4
112

是不是这样:
如果&两端是boolean型,&就表示逻辑与
如果&两端是int型或char型,&就表示按位与
SHOUYU2 2008-09-25
  • 打赏
  • 举报
回复
2楼正解,懂了
胡须棉花糖 2008-09-25
  • 打赏
  • 举报
回复
0跟1与,结果是0,所以indexed 值是false
fangsp 2008-09-25
  • 打赏
  • 举报
回复
我也看得不太懂
You are visitor as of October 17, 1996.The Art of Assembly Language ProgrammingForward Why Would Anyone Learn This Stuff?1 What's Wrong With Assembly Language2 What's Right With Assembly Language?3 Organization of This Text and Pedagogical Concerns4 Obtaining Program Source Listings and Other Materials in This TextSection One: Machine OrganizationArt of Assembly Language: Chapter OneChapter One - Data Representation1.0 - Chapter Overview1.1 - Numbering Systems1.1.1 - A Review of the Decimal System1.1.2 - The Binary Numbering System1.1.3 - Binary Formats1.2 - Data Organization1.2.1 - Bits1.2.2 - Nibbles1.2.3 - Bytes1.2.4 - Words1.2.5 - Double Words1.3 - The Hexadecimal Numbering System1.4 - Arithmetic Operations on Binary and Hexadecimal Numbers1.5 - Logical Operations on Bits1.6 - Logical Operations on Binary Numbers and Bit Strings1.7 - Signed and Unsigned Numbers1.8 - Sign and Zero Extension1.9 - Shifts and Rotates1.10 - Bit Fields and Packed Data1.11 - The ASCII Character Set1.12 Summary1.13 Laboratory Exercises1.13.1 Installing the Software1.13.2 Data Conversion Exercises1.13.3 Logical Operations Exercises1.13.4 Sign and Zero Extension Exercises1.13.5 Packed Data Exercises1.14 Questions1.15 Programming ProjectsChapter Two - Boolean Algebra2.0 - Chapter Overview2.1 - Boolean Algebra2.2 - Boolean Functions and Truth Tables2.3 - Algebraic Manipulation of Boolean Expressions2.4 - Canonical Forms2.5 - Simplification of Boolean Functions2.6 - What Does This Have To Do With Computers, Anyway?2.6.1 - Correspondence Between Electronic Circuits and Boolean Functions2.6.2 - Combinatorial Circuits2.6.3 - Sequential and Clocked Logic2.7 - Okay, What Does It Have To Do With Programming, Then?2.8 - Generic Boolean Functions2.9 Laboratory Exercises<

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧