Shop OBEX P1 Docs P2 Docs Learn Events
String to Dec? — Parallax Forums

String to Dec?

TJHJTJHJ Posts: 243
edited 2009-01-27 20:29 in Propeller 1
So maybe Im over thinking this, but I am reciving a string in 4 bytes.

Digit 1, 2, 3, 4 then print it to an LCD screen.

 
repeat 4
      Rx := term.getc
      term.out(rx)
      lcd.str(@Rx)

but I really want to use this number in calculations, so whats a good way to convert it back to a standard number/decimal.

Thanks as always,

TJ

Comments

  • KyeKye Posts: 2,200
    edited 2009-01-27 20:05
    Here use this, its my standard string library.

    No documentation however, but its simple to use

    Ask me if you need help.

    Each method either takes a number and converts it to·a string and returns the pointer to the string. (Note the string last only until the library is called again.)

    Or the methods take a pointer to a string and return the number of the string.

    The decimal methods have a length part in them which specifies how many padded zeros you want.

    Also, i've added in a hook to catch the quirker number -2147483648 which is equal to 2147483648 in binary (meaning that division with it gets &*^%$#) so the library is rather full proof.

    There are also some timing methods.




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 1/27/2009 8:11:52 PM GMT
  • KyeKye Posts: 2,200
    edited 2009-01-27 20:11
    As for your problem:

    Store the characters in the main memory, followed by a NULL or 0. And then call my library.

    As in "1", "2", "3", "4", NULL(zero)

    And then pass the libray the address of the "1", and it will return the number.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • TJHJTJHJ Posts: 243
    edited 2009-01-27 20:29
    Thanks Kye appricate it.



    TJ
Sign In or Register to comment.