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.

Dark GDK / Problem displaying floats

Author
Message
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 5th Aug 2009 18:55 Edited at: 5th Aug 2009 18:57
Hey! I'm working on a RPG and I'm having a problem. I can't display a float using:
(Don't mind the "FPS:")

When I do this it displays the weight as a 0. But when I do

It displays the weight but obviously not as a float. So how do I display a float on the screen? Thanks!

Use Google first... it's not rocket surgery!
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 5th Aug 2009 19:11
If the weight is an int why do you want to display it as a float?

wsprintf (czText, "FPS %f", (float) Inventory[lastInventorySlot].Weight );

would be the best guess I could make.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 5th Aug 2009 19:15
The weight variable is a float but the only way for me to display it that I know of is as an integer which I don't want. And when I try your code it just displays "FPS f".

Use Google first... it's not rocket surgery!
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Aug 2009 19:16
%d is for integers

%f is for floats

do it like this:



here's a good page to read over:

http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

New Site! Check it out \/
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 5th Aug 2009 19:21 Edited at: 5th Aug 2009 19:34
Got it working! I used:

Found the information here: http://www.digitalmars.com/d/archives/c++/windows/32-bits/285.html

Use Google first... it's not rocket surgery!

Login to post a reply

Server time is: 2024-10-01 10:27:28
Your offset time is: 2024-10-01 10:27:28