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 / Convert integer to float

Author
Message
Reyman
9
Years of Service
User Offline
Joined: 22nd Jan 2015
Location:
Posted: 22nd Jan 2015 16:29
New user - I have searched for this all over and cant seem to find the solution anywhere.

I have a script that needs to convert an integer to a float.

The only way I have been able to do this is convert the integer to a string, then convert the string to a float.

e.g.


Seems a bit long winded, but works. is there a simpler way?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Jan 2015 17:25 Edited at: 22nd Jan 2015 17:26
How about:

myFloat# = myInteger

You don't need any intermediary steps, you can just cast from one to the other.

Sometimes AppGameKit is too easy for it's own good

Quidquid latine dictum sit, altum sonatur
Reyman
9
Years of Service
User Offline
Joined: 22nd Jan 2015
Location:
Posted: 24th Jan 2015 10:52
I dumbed down the example as the actual conversion was within a much larger complex setting, which definately didnt work - just returned zero all the time. I will try again with a new variable to do the conversion first, then apply that my larger equation. Thanks for reply!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 24th Jan 2015 23:56
myFloat = myInt * 1.0
is what I always use

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Feb 2015 21:41
Quote: "myFloat = myInt * 1.0"

This works only if 'myFloat' is first declared as a floating point variable.

Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-11-25 18:01:31
Your offset time is: 2024-11-25 18:01:31