String to integer

Discussion in 'Programming' started by nick13579, Jul 21, 2016.

  1. nick13579

    nick13579 Member

    Joined:
    Jul 20, 2016
    Posts:
    43
    Is there a way to convert a string to an integer?
     
  2. Humayun

    Humayun Member

    Joined:
    Jun 20, 2016
    Posts:
    89
  3. nick13579

    nick13579 Member

    Joined:
    Jul 20, 2016
    Posts:
    43
    Ok thanks!
     
  4. Imperial

    Imperial Member

    Joined:
    Jun 29, 2016
    Posts:
    133
    Code:
    str = "0";
    number = real(str);
    //number = 0;
     
    The Otterman likes this.
  5. elementbound

    elementbound Member

    Joined:
    Jun 30, 2016
    Posts:
    114
    Also note that real converts to a number with decimals. So, real("8.72") will not result in an integer, but a float. If you suspect that the string might not contain an integer, use floor() or round() after that, like so: floor(real("8.72"))
     
    The Otterman likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice