From float to char* ?
by Xavier "eXoDuS" Amado · in Torque Game Engine · 01/21/2002 (9:59 am) · 8 replies
I was looking for a way to convert a float variable (for example player's health) to a char* to be able to print it in a guiCtrl using renderJustifiedText() function, which only accepts a char* as its text parameter. Or maybe there's another function to render float numbers? I couldnt find it tho.
Please any help would be appreciated.
Thanks
Please any help would be appreciated.
Thanks
About the author
#2
01/21/2002 (10:43 am)
maybe you can give me an example of that kind of conversion? MSDN isnt any helpful :P
#3
01/21/2002 (10:47 am)
Here it isfloat var = 32.467; char buff[256]; sprintf( buff, "%.2f", var ); // 2 decimals after .
#4
What if i would like to eliminate the decimal part completely?
01/21/2002 (11:56 am)
i figured the command out before you posted that .. sorry, but maybe it comes in handy anyway, what do you mean 2 decimal points afterwards?What if i would like to eliminate the decimal part completely?
#7
01/22/2002 (2:09 pm)
you should really be using dSprintf instead of sprintf, as that will ensure platform compatibility
#8
01/22/2002 (5:25 pm)
yes i'm using dSprintf now.. i figured it out later :)
Torque Owner Mz