If I want to convert the number 2, 5, 7 into 257, and also do the inverse (257 to 2, 5, 7)? how do I do that in code? Answered
If I want to convert the number 2, 5, 7 into 257, and also do the inverse (257 to 2, 5, 7)? how do I do that in code?
I have considered using math to do this: 2, 5, 7; 2*100 + 5*10 + 7 = 257; but This will only work with numbers with X number of digits. I need to to work with a variable amount of numbers in an array or stored in separate variables.
If anyone wants to know why I need to do this, I am trying to program a simple calculator app in java, and I would find this useful with the arduino too. I am learning programming here, and this is currently the calculator app: https://www.khanacademy.org/cs/calculator/5724205359824896. It is not finished, but I got over 200 lines of code to draw out the buttons and screen, and make them interactive. I need a way to capture the presses of the buttons and store them in arrays that when an operator is pressed, a new array is created with more numbers inside it and those numbers are joined together.