find how many times a number appears inside a number
Posted: Thu Oct 06, 2016 9:24 pm
I've a u16 from 1 to 200, I display the number as 3 images from 1 to 9. So if I had 211 it would be 3 image [2] [1] [1].
The problem is I'm struggling to do the calculation to work out how many 100, 10s and 1s are in the u16!
I thought the below code would work but it doesn't :/ can someone help me?
The problem is I'm struggling to do the calculation to work out how many 100, 10s and 1s are in the u16!
I thought the below code would work but it doesn't :/ can someone help me?
Code: Select all
mod = fix16ToRoundedInt(intToFix16(GameVariables.ConcertEnergy) % 100);
intTemp1 = fix16ToRoundedInt(intToFix16((GameVariables.ConcertEnergy) - FIX16(mod) / 100));
mod = fix16ToRoundedInt(intToFix16(GameVariables.ConcertEnergy % 10));
intTemp2 = fix16ToRoundedInt(intToFix16((GameVariables.ConcertEnergy - FIX16(mod)) / 10));