java单个竖线代表什么,JavaScript中的单个竖线是什么意思?

What does this expression mean in JS?

Value |= this.value

解决方案

It's binary "OR", just like in C or C++ or Java. In this case, it's used in its assignment operator form, so

value |= this.value

means that this.value and value are both converted to 32-bit integers, and a bitwise OR operation is performed. If value were 10 and this.value were 3 before the operation (that is, 01010 and 011 in binary) the result would be 11 (01011 in binary).

The binary logic operators in Javascript are notable in Javascript because the work is carried out on integer values.

The term "bit-wise" is perhaps more accurate than "binary". The operations act on each bit of a numeric value, specifically the numeric values coerced to signed 32-bit integers. The result is also a signed 32-bit integer (according to the spec).

However, JavaScript numbers "at rest" are always 64-bit binary floating point values. Thus the results of bitwise operators, though computed with 32-bit integer math, are stored in floating point form. That works because the range of 32-bit integers fits comfortably and precisely in a 64-bit float.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值