Questions tagged [bitshift]

3 questions
1
vote
2 answers

Confusion on bit shifting

I am trying to read-in two separate, 3 byte messages over CAN, add them together, and send back out over CAN, on a CANBED V1 which uses a Leonardo. My confusion is using bit shifting. If I attempt to shift 1 by 1..14 bits I seem to…
Greg Smith
  • 19
  • 2
0
votes
1 answer

Why is char being "extended" to an int?

I know I'm missing something so simple here, but I can't figure it out. If I do char letter = 'A'; then letter = letter << 8, letter = 0, as one should expect, since we are shifting the bits "off the shelf" to the left. But, if we do this: char…
AJ_Smoothie
  • 504
  • 4
  • 13
-1
votes
2 answers

How 2 bytes can produce negative number, mind blowing?

I am trying to use LoRAWAN and sending tempurature values as less bytes. I found that way and tested it works fine it can send negative and positive numbers as 2 bytes instead of "float" as 4 bytes or "double" as 8 bytes but still I can not…
mehmet
  • 297
  • 2
  • 19