简体   繁体   中英

C# UL and >> operators

What does this meaning mean in words?

(SomeVariable * 330UL >> 10)

Is it: SomeVariable times 3.3 shift right 10 bit??

No.

It means SomeVariable times 330, promote to long and shift non-cyclically right 10bits.

(it would be cyclic, or arithmetic shift without the promotion).

Right-shifting an integral value by one is equivalent to dividing it by 2. Two shifts equivalent to dividing by 4. Etcetera. Which makes the expression equivalent to:

ulong value = ((ulong)SomeVariable * 330) / 1024;

UL stands for Unsigned Long. >> yes it is bitwise arithmetic shift.

可变时间330作为无符号长移位右移10位

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM