Shop OBEX P1 Docs P2 Docs Learn Events
Decimal to Binary conversion — Parallax Forums

Decimal to Binary conversion

webcrawler42webcrawler42 Posts: 3
edited 2008-07-09 15:09 in Propeller 1
What would be the easiest way to convert from Decimal to Binary? I'm coming from mainly a C background.

Is there a strcat() or something similar to build strings?

Is there something like atoi(), but dtob?

Comments

  • AleAle Posts: 2,363
    edited 2008-07-08 18:29
    For C ? for Spin or for assembler ?. For the last one I'd recommend my article about math at the propellerwiki, propeller.wikispaces.org/MATH.

    What you want to convert is a string to binary... that is something else. I'm sure you can use one of the routines in the floating point package for the propeller wink.gif
  • webcrawler42webcrawler42 Posts: 3
    edited 2008-07-08 19:24
    I figured it out using the %, so %00000000 or %11111111
  • grasshoppergrasshopper Posts: 438
    edited 2008-07-08 21:26
    To convert form decimal to binary use this example
    Decimal

    Tempdata := 34
    
    



    to binary

    Tempdata := %34
    
    



    and to hex

    Tempdata := $34
    
    
  • webcrawler42webcrawler42 Posts: 3
    edited 2008-07-09 14:34
    that is easy enough, thanks grasshopper
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2008-07-09 15:09
    Glad you figured out your problem.

    Also, can't you assign variables to bits of a byte and push the number into a byte and review the "bit" variables? I saw that on a stamp anyway.
Sign In or Register to comment.