1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GML Convert precise number from string

Discussion in 'Programming' started by Vulpes_Coders, Jul 1, 2019.

  1. Vulpes_Coders

    Vulpes_Coders Member

    Joined:
    Nov 22, 2018
    Posts:
    12
    Is there any way to convert string like "‭0.01780942‬" to a number ?
    I used real() function but it automatically rounds to "0.02".

    code (file_read is a string):
    Code:
    file_read = real(file_read);
    output:
    Code:
    DECODE_fileRead: 0.02
    (file_text_read_real() gives the same result)
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,423
    The function does return the precise result, is is rather that you are converting it to string via regular string() (which is 2-point precision) rather than string_format
     
    Rob and Vulpes_Coders like this.
  3. Vulpes_Coders

    Vulpes_Coders Member

    Joined:
    Nov 22, 2018
    Posts:
    12
    Oh yea, you are right. Thanks.
     

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