0 Favourites

[Solved] Geolocation Showing a lot of numbers.

  • Hello to you all.

    I'm having an issue when using Geolocation: most of the times I get the position with 9 digits: 43.4759862, but sometimes I get a lot of numbers: 43.475898199999996.

    Is there a way to make the result to appear always the same way, with 9 digits?

    I've tried

    round(((Geolocation.Latitude)*10000000)/10000000)[/code:b6woo8f3]
    But it rounds the number to 40 (Because it's not a "real" decimal number, I guess, I'm not very good with GPS  formats).
    
    Thanks in advance.
  • ..maybe?..or not?

    left(str(Geolocation.Latitude),10)

  • ..maybe?..or not?

    left(str(Geolocation.Latitude),10)

    Works perfectly, Thank you very much korbaach !!

    Edit: Just looked for the explanation and found in the manual:

    [quote:6353udw3]left(text, count)

    Return the first count characters of text.

    Not clear at all if you don't know exactly what you're looking for.

  • FERdeBOER

    left(text, count) ......count=10

    Return the first 10 characters of text...

    Geolocation.Latitude=43.475898199999996

    4=1

    3=2

    .=3

    4=4

    7=5

    5=6

    ...etc

    ...but .. 43.475898199999996 its a number... u need to use "str" to convert number 43.475898199999996

    in text "43.475898199999996"

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Thank you for the clarification korbaach.

    Sorry if I wasn't clear, I understood it once you pointed me to it and then found it in the manual, but I'm pretty sure it will help others.

    I'm starting to learn some coding while I'm not messing with construct 2 (or working) and I already "knew" (I was supposed to, but I forgot, as this post proves) the character's count and remembered it when I saw your line and the manual... But I don't think the manual alone would have been useful for me in this case if I wouldn't know something about the subject already.

    Thank you again!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)