Hello everybody,
I have seen the operator %= used in a code meant for Keil C. Can somebody explain me its purpose? Thanks.
www.8051projects.net/.../forum_viewtopic.php
char getchar() { volatile char c; while(RxInChar == RxOutChar); ES = 0; /* Disable Interrupts */ c = RxBuffer[ RxOutChar++ ]; RxOutChar %= BUF_SIZE; ES = 1; /* Enable Interrupts */ return( c ); }
Sorry but I don't think so.
RxOutChar %= BUF_SIZE;
From the code it seems that RxOutChar points to a location in receive buffer RxBuffer of size BUF_SIZE. So after incrementing RxOutChar if it exceeds BUF_SIZE it should become zero, otherwise no change.
If I am correct, what is the exact meaning of %= . What mathematical/logical operation it does?