Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

Assignment of Binary strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Assignment of Binary strings

    I want to set BYTE variables to certain binary values.

    ---
    DIM Switches AS BYTE

    Switches = b'01110111'
    ---
    I was just writing my code and could not find this in the ref
    books. Is this valid? If not, what is the best way. It makes
    my code easy to read if I can use binary rather than a character.

    Thanks,
    TurboBoy

    ------------------
    when things old are new again...making fast cars faster with PBDOS......

  • #2
    Prefix the number by the radix (&B for binary .. &H for hexadecimal
    It should be under Character Set in the DOS help file

    Switches = &b01110111

    Mike


    ------------------

    Comment


    • #3
      Don't forget Octal too:
      Code:
      PRINT &10, &O10, &q10 ' 10 Octal = 8 Decimal
      Oh, and adding a leading zero will force an unsigned evaluation...
      Code:
      PRINT &HFFFF, &H0FFFF, &HFFFF??
      ..Produces:
      Code:
      -1             65535         65535

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Thanks much !!! ......

        TurboBoy

        ------------------
        when things old are new again...making fast cars faster with PBDOS......

        Comment

        Working...
        X