I have a very simple sketch, something like this:

int aFour = 4; 

Which gives the following output:


Why don't they print both as 0100?

EDIT: the output was in one line : 10010011, I falsely asumed the output should be split into twice 4 bits.

  • Works for me. How it's even separated? Maybe it's 100 100 11 or so because you did just print not println ...
    – KIIV
    Commented Oct 25, 2016 at 22:02
  • 1
    I also got a 100 when I tried it. @KIIV did raised a good point about println.
    – Dat Ha
    Commented Oct 25, 2016 at 22:06

1 Answer 1

  • print never prints leading zeroes (how many should it print anyway?).
  • print doesn't start a new line - you need println for that

So you get your 4 in binary printed twice followed by something else (not sure what - maybe something else in your program that you're not showing us?): 10010011

That's 100 100 11 when split up.

  • I indeed falsely assumed the output to be split 4 bits each. println clarified the issue. The lagging 11 originated from some other print statement not displayed in my question above. Thanks! Commented Oct 26, 2016 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.