14|01|09 Fun with Modulation and Division

Came across a little problem today that was solved by the power of MODULATION and DIVISION.

I’m using a fancy way to display numbers that splits each number into it’s own box.

The numbers are stored in this list.

The numbers are stored as an image like the one above. In order to work out which image I need to use I have to find out what the value of each number is. For instance in 0213 I need to be able to know that the 3rd digit is 1.

To work out the value of a number that’s in the middle of other number modulation is essential, since we can use the remainder to learn the value. Here’s the formula I used:

1st digit: value/1000

2nd digit: (value%1000)/100

3rd digit: (value%100)/10

4th digit: value%10

The end result is this: Numbers

There’s some other checks for lower numbers, since if we want to display 400 in this way the method above will output 0000.