# How can I input more than one digit numbers on my calculator I made?

I made a calculator and everything works fine, I just don’t know how I would make it able to do more than one digit numbers. Can you please help me out? Here is the code:

``````using UnityEngine;
using System.Collections;

public class Calculator : MonoBehaviour {

string asmd = ""; //Addition, subtraction...
int num1 = 0;
int num2 = 0;
bool num1chosen = false;

void OnGUI() {
GUI.Box(new Rect(10, 10, 370, 315), "");
GUI.Box(new Rect(15, 15, 80, 30), "" + num1);
GUI.Box(new Rect(100, 15, 50, 30), "" + asmd);
GUI.Box(new Rect(155, 15, 80, 30), "" + num2);
GUI.Box(new Rect(240, 15, 50, 30), "=");
GUI.Box(new Rect(295, 15, 80, 30), "" + answer);
if(GUI.Button(new Rect(15, 50, 80, 50), "7")) {
if(num1chosen == false) {
num1 = 7;
}
else {
num2 = 7;
}
}
if(GUI.Button(new Rect(100, 50, 80, 50), "8")) {
if(num1chosen == false) {
num1 = 8;
}
else {
num2 = 8;
}
}
if(GUI.Button(new Rect(185, 50, 80, 50), "9")) {
if(num1chosen == false) {
num1 = 9;
}
else {
num2 = 9;
}
}
if(GUI.Button(new Rect(15, 105, 80, 50), "4")) {
if(num1chosen == false) {
num1 = 4;
}
else {
num2 = 4;
}
}
if(GUI.Button(new Rect(100, 105, 80, 50), "5")) {
if(num1chosen == false) {
num1 = 5;
}
else {
num2 = 5;
}
}
if(GUI.Button(new Rect(185, 105, 80, 50), "6")) {
if(num1chosen == false) {
num1 = 6;
}
else {
num2 = 6;
}
}
if(GUI.Button(new Rect(15, 160, 80, 50), "1")) {
if(num1chosen == false) {
num1 = 1;
}
else {
num2 = 1;
}
}
if(GUI.Button(new Rect(100, 160, 80, 50), "2")) {
if(num1chosen == false) {
num1 = 2;
}
else {
num2 = 2;
}
}
if(GUI.Button(new Rect(185, 160, 80, 50), "3")) {
if(num1chosen == false) {
num1 = 3;
}
else {
num2 = 3;
}
}
if(GUI.Button(new Rect(15, 215, 165, 50), "0")) {
if(num1chosen == false) {
num1 = 0;
}
else {
num2 = 0;
}
}
if(GUI.Button(new Rect(185, 215, 80, 50), "AC")) {
num1 = 0;
num2 = 0;
asmd = "";
num1chosen = false;
}
if(GUI.Button(new Rect(15, 270, 360, 50), "=")) {
if(asmd == "+") {
}
else if(asmd == "-") {
}
else if(asmd == "*") {
}
else if(asmd == "/") {
}
}
if(GUI.Button(new Rect(270, 50, 105, 50), "+")) {
asmd = "+";
num1chosen = true;
}
if(GUI.Button(new Rect(270, 105, 105, 50), "-")) {
asmd = "-";
num1chosen = true;
}
if(GUI.Button(new Rect(270, 160, 105, 50), "*")) {
asmd = "*";
num1chosen = true;
}
if(GUI.Button(new Rect(270, 215, 105, 50), "/")) {
asmd = "/";
num1chosen = true;
}
}
}
``````

Let say you have answere 737

then try this

``````int _ans = 737; // put your answere here
int digit;
int lastDigit;

int i=0;
while(Math.abs(_ans) >0){
digit= _ans%10;
_ans = _ans/10;

digitArray*= digit;   // here you can collect digit into array or some other data structure*
``````

i++; // digits would be in reverse order
if(_ans <10 ) _ans =0;
print(digit);
}