cancel
Showing results for 
Search instead for 
Did you mean: 

Bitwise

Vmere.1
Senior

"I'll delete this question once someone answers it, as it is not relevant".

0693W00000QMqCCQA1.pngWhy in second line did some one write ch & 0xFF? ch limits are already 0 to 255 right?

1 ACCEPTED SOLUTION

Accepted Solutions

The copy-n-paste coder here took code that use int originally for the parameter/return and changed it to a uint8_t

Classically C libraries have returned negative values for failure around STDIO routines.

The TDR here is 16-bit wide as the U(S)ART support 9-bit values. When reading RDR and using parity, the code needs to strip the parity bit manually/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4
S.Ma
Principal

Maybe because function content was copy pasted from elsewhere which ch may not have been uint8_t. Anyway, compiler are not dumb, they will optimise this, no sweat.

KnarfB
Principal III

You're right. The &0xFF is useless here.

hth

KnarfB

The copy-n-paste coder here took code that use int originally for the parameter/return and changed it to a uint8_t

Classically C libraries have returned negative values for failure around STDIO routines.

The TDR here is 16-bit wide as the U(S)ART support 9-bit values. When reading RDR and using parity, the code needs to strip the parity bit manually/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I'm new to C programming, development and not very confident but after few months (till today) I got used to programming and sometime still don't feel 100% confident, don't know why! But i feel that this emotion will be gone gradually.​