So, Im making a calc Add In using the SDK.
I'm wondering, How would I display decimals. I know its f, or a g. But I cant seem to get it to work.
Could you guys please give me an example of using sprintf to stick a floating point number into a string. Also how to make it rounded to 2 decimal places.
Thank You.
Display Decimals
Started by
Fez
, May 14 2008 09:32 AM
3 replies to this topic
#1
Posted 14 May 2008 - 09:32 AM
#2
Posted 14 May 2008 - 01:23 PM
Hey, here's an example:
You also need to make sure that stdio.h is included:
float test = 3.14159; char buffer[20]; Bdisp_AllClr_VRAM(); sprintf(buffer, "%0.2f", test); PrintMini(1, 1, (unsigned char *)buffer, MINI_OVER); Bdisp_PutDisp_DD();
You also need to make sure that stdio.h is included:
#include "stdio.h"
#3
Posted 14 May 2008 - 01:39 PM
OMG thanx XD
So thats what was going wrong.
I wasnt including the file
It works now, so thanx alot. Also thanx for showing me the way to round them XD
So thats what was going wrong.
I wasnt including the file
It works now, so thanx alot. Also thanx for showing me the way to round them XD
#4
Posted 14 May 2008 - 05:11 PM
Heh, no problem.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users