Shop OBEX P1 Docs P2 Docs Learn Events
Significance of underscore in binary number. — Parallax Forums

Significance of underscore in binary number.

FranklinFranklin Posts: 4,747
edited 2007-05-27 03:15 in Propeller 1
I'm not sure I understand the significance of the underscore in the binary number in this code.
 bs2.shiftout(MOSI,SCK,%000011_10,BS2#MSBFIRST,8)  

Could someone explain? Thanks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Post Edited (Franklin) : 5/27/2007 1:35:33 AM GMT

Comments

  • codemonkeycodemonkey Posts: 38
    edited 2007-05-27 01:24
    Underscores in constants are just placeholders, useful to people, ignored by the compiler/interpreter/assembler.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-05-27 01:59
    Good when you write out an entire 32 bit number, it lets you find where you are easily.

    01001010_01001010_01001010_01001010

    Rather than:

    01001010010010100100101001001010

    Same goes for hex

    FFFF_FFFF

    Sometimes they can be used when a number has different bits for different tasks, you split with an _ to make it clear.

    Graham

    Post Edited (Graham Stabler) : 5/27/2007 2:29:59 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2007-05-27 03:15
    Thanks, I suspected the underscore might have been a marker because of the context but wasn't sure. the last two bits in this byte signify read/write and the last one is always zero

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.