Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / val() for floats?

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2011 13:09 Edited at: 16th Dec 2011 13:10
It seems we cannot get floats from val(), or am I missing another command?




result :

Quote: "
12345
123
0
"


netmon
17
Years of Service
User Offline
Joined: 14th Aug 2006
Location:
Posted: 16th Dec 2011 14:21
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Dec 2011 21:16 Edited at: 16th Dec 2011 21:17
Edit - never mind, misread something.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Dec 2011 22:49 Edited at: 16th Dec 2011 22:50
Thanks netmon, complicated but fixes the problem.

I actually took an alternative approach, which works for me but probably won't for all scenarios. I'm reading values from an ini file, so I have saved all values as value * 100, then I divide by 100 when I read it back in.

[EDIT] - fixed in V107 - http://code.google.com/p/agk/issues/detail?id=54&q=val

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Dec 2011 23:26 Edited at: 16th Dec 2011 23:29
Quote: "I'm reading values from an ini file, so I have saved all values as value * 100, then I divide by 100 when I read it back in."

Do you lose any accuracy with that (on certain numbers anyway e.g 123.45)?

I quickly wrote a function to convert strings to decimals for fun but I loose accuracy when I divide.



It may just be the general loss of accuracy though which many languages suffer from so there's probably no point trying to fix the above.

Quote: "[EDIT] - fixed in V107"

Good to hear.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Dec 2011 11:28
Yes you would lose accuracy, but then you would if you converted the string too I think. 0.1 is a good example, there is no float equivalent.

For me, it's accurate enough. These are seconds and 0.1 is as good as 0.99996....

Login to post a reply

Server time is: 2024-04-25 02:25:03
Your offset time is: 2024-04-25 02:25:03