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 / Change Float From "0.50" To "50" / And Trims Excess Decimals?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 27th Aug 2019 20:20
Hi,

How would we change a float from "0.50" to "50"?
We need a function the moves the decimal.
We also need a function that trims everything after "50".
Let us know, thanks!

It's for a loading now screen...

Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
Bored of the Rings
User Banned
Posted: 27th Aug 2019 20:26 Edited at: 27th Aug 2019 20:27
f as float
f= 0.5
i as integer
i = f*100
print (i)
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 27th Aug 2019 20:31
uhm multiply it by 100?
there are a couple ways to trim the decimals; round is the normal method but i'm not sure AppGameKit has a built in round that allows you to set to which decimal place so i usually just convert to string and back
i.e.
f# = 0.56
f$ = str(f#,1)
as it's for a progress bar you can probably stop there but if you want to convert it back to float you do
f# = ValFloat(f$)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Bored of the Rings
User Banned
Posted: 27th Aug 2019 20:42 Edited at: 28th Aug 2019 09:29
yes by 100 if you want, more than 1 way to skin an onion ... of course am doing this code quick going by the OP 0.5, didn't see the progress bar in OP but loading screen progress bars are simple enough:
of course, the choice is yours.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-10-01 10:31:03
Your offset time is: 2024-10-01 10:31:03