
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
No explanation!
The bug (?!) shows in the intermediate results ONLY (for all bitwise operators).
However, assignment (Num >>= 1) works as expected, (luckily).
All integral sub-types of int are processed internally as int.
All integral sub-types of int are processed internally as int.
The bitwise operators promote small integers (such as char/uchar) to signed ints. https://stackoverflow.com/a/28142065
The integral promotions of small integers do have side effects to be aware of. In the next example, the uchar/char value can be left shifted more than its width (<< more than 8-bits)
There also another issue with bitwise operators (Signed types):
When doing bitwise operations, if you want strictly well-defined (according to the standard) results, you generally have to ensure that the values being operated on are unsigned. You can do that either with explicit casts, or by using explicitly unsigned constants (U-suffix) in binary operations.
All integral subtypes of int are treated internally as int.
Thanks.
The bitwise operators promote small integers (such as char/uchar) to signed ints. https://stackoverflow.com/a/28142065
The integral promotions of small integers do have side effects to be aware of. In the next example, the uchar/char value can be left shifted more than its width (<< more than 8-bits)
There also another issue with bitwise operators (Signed types):
When doing bitwise operations, if you want strictly well-defined (according to the standard) results, you generally have to ensure that the values being operated on are unsigned. You can do that either with explicit casts, or by using explicitly unsigned constants (U-suffix) in binary operations.
It's probably better to avoid bitwise operations with char/uchar or short/ushort.
Why would you want to do that anyway ?
If you want to use bits to represent Tick data, just count how much bits you need and use enough int (or long ?) to match them. I don't have time to do it, but could be interesting.