How to extract the individual parts of a number.

Hi, tis' me again! :stuck_out_tongue:

I've looked, and I've thought, but I can't see a way to do this. Basically, I have a two-digit LED display, and the numbers to be displayed are in a 2-element array. Now, what I want to do is display the PSI reading from a pressure sensor on the LED display. So, I need a way to extract, say, the individual numbers 5 and 2 from the ADC value (value from the ADC is divided by ten to get PSI) of 52, and set the array elements to those extracted numbers.

Have I explained myself clearly? Any solutions?

So, I need a way to extract, say, the individual numbers 5 and 2 from the ADC value (value from the ADC is divided by ten to get PSI) of 52

Here's a hint:
52 / 10 = 5
52 % 10 = 2

PaulS:

So, I need a way to extract, say, the individual numbers 5 and 2 from the ADC value (value from the ADC is divided by ten to get PSI) of 52

Here's a hint:
52 / 10 = 5
52 % 10 = 2

I had thought of that, but if the number was higher than 55 then wouldn't it round and return 6?

I had thought of that, but if the number was higher than 55 then wouldn't it round and return 6?

No. Integer division truncates. It does not round.

PaulS:

I had thought of that, but if the number was higher than 55 then wouldn't it round and return 6?

No. Integer division truncates. It does not round.

I hadn't known that. Annnnd.... It works! Thanks! 8)