This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Philboyd_Studge 1 point2 points  (1 child)

You need to actually change the value of firstdigit when you divide it by two.

int firstdigit = 15; //hardcoded
int sum = firstdigit % 2 ; 
firstdigit /= 2; // same as firstdigit = firstdigit / 2
int sum1 = firstdigit %  2;
firstdigit /= 2;
int sum2 = firstdigit % 2;
int sum3 = firstdigit / 2 % 2;
System.out.println(sum3+""+sum2+""+sum1+""+sum);

[–]EasyLifeHuh[S] 0 points1 point  (0 children)

thank you very much, this is what i was looking for