| 1. |
Which Is Better A Char, Short Or Int Type For Optimization? |
|
Answer» Where possible, it is best to avoid using char and short as local variables. For the types char and short the compiler needs to reduce the size of the local variable to 8 or 16 bits after each assignment. This is called sign-extending for SIGNED variables and zero extending for unsigned variables. It is implemented by shifting the register left by 24 or 16 bits, FOLLOWED by a signed or unsigned shift right by the same AMOUNT, taking two instructions (zero-extension of an unsigned char takes one instruction). Where possible, it is best to avoid using char and short as local variables. For the types char and short the compiler needs to reduce the size of the local variable to 8 or 16 bits after each assignment. This is called sign-extending for signed variables and zero extending for unsigned variables. It is implemented by shifting the register left by 24 or 16 bits, followed by a signed or unsigned shift right by the same amount, taking two instructions (zero-extension of an unsigned char takes one instruction). |
|