Announcement

Collapse
No announcement yet.

convert string to int32

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

  • convert string to int32

    Hello,

    i try to convert a string to a number.

    /*convert string to int16*/
    func GetNumber(var str)
    var ch, n;
    n := 0 ;
    while ( str_GetC(&str, &ch))
    if ((ch > '9') || (ch < '0')) break;
    n := n * 10;
    n := n + (ch -'0');
    wend
    return n;
    endfunc

    with this function i can convert all strings up to 32768.
    i need a function, that can convert larger strings/ numbers.

    maybe some of you, have an idea how to get this kind of function-->

    func getNumber32(var str)
    //string to int32
    //int32 devided by 60
    // int32 to string
    //--> return string
    endfunc

    Example: GetNumber("65999")


    best regards,
    alex

  • #2
    Hello Alex,

    Since the Diablo16 is a 16 bit processor, the maximum value that could be stored in a single variable is 32767.

    Have you had a chance to look at the str_GetD(&ptr,&var) function?

    Additionally, you can use the unsigned math functions or floating point math functions to compute for larger values.

    These forum threads might be relevant for you.

    Converitng a number to a string
    https://forum.4dsystems.com.au/node/48864

    Large values calculation
    https://forum.4dsystems.com.au/node/65083

    Best regards,
    Last edited by michael_4D; 23rd February 2019, 04:34 PM.
    Michael

    Comment


    • #3
      Hello Michael,

      i think str_GetD() is very helpful.
      Thanks a lot

      Best regards,
      Alex

      Comment

      Working...
      X