Shop OBEX P1 Docs P2 Docs Learn Events
Help on hex to decimal conversion — Parallax Forums

Help on hex to decimal conversion

El PaisaEl Paisa Posts: 375
edited 2006-07-25 18:00 in Propeller 1
I wonder if somebody have in his tools a routine to convert a two digit hex number into a integer.
It·will save me a lot of agravation.

I really thank you in advance.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-25 16:11
    Will this do?
    PRI hexToInteger(h) : v
      if h => "0" and h =< "9"
        v := h - "0"
      elseif h => "A" and h=< "F"
        v := h - "A" + 10
      elseif h => "a" and h =< "f"
        v := h = "a" + 10
    
    PRI twoHextoInteger(h2,h1) : v
      v := hexToInteger(h2) << 4 | hexToInteger(h1)
    
    
  • El PaisaEl Paisa Posts: 375
    edited 2006-07-25 18:00
    I will·certainly try.

    Thanks.
Sign In or Register to comment.