Click here to Skip to main content
16,013,548 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalthank you very much Pin
baboguru22-Feb-05 15:17
baboguru22-Feb-05 15:17 
Generalsqrt( ) question Pin
joe_man18-Feb-05 15:31
joe_man18-Feb-05 15:31 
GeneralRe: sqrt( ) question Pin
Steve Mayfield18-Feb-05 15:39
Steve Mayfield18-Feb-05 15:39 
GeneralRe: sqrt( ) question Pin
joe_man18-Feb-05 15:50
joe_man18-Feb-05 15:50 
Generalleading 0 in float point variable 0.233 Pin
tnvols18-Feb-05 14:49
tnvols18-Feb-05 14:49 
GeneralRe: leading 0 in float point variable 0.233 Pin
Steve Mayfield18-Feb-05 15:42
Steve Mayfield18-Feb-05 15:42 
GeneralRe: leading 0 in float point variable 0.233 Pin
tnvols18-Feb-05 18:08
tnvols18-Feb-05 18:08 
GeneralRe: leading 0 in float point variable 0.233 Pin
Steve Mayfield19-Feb-05 11:09
Steve Mayfield19-Feb-05 11:09 
I'm surprised that you are not allowed to use something like

CString str;
float xnum = 0.123;
str.Format("%4.3f", xnum);

[equivalent to char str[8]; sprintf(str, "4.3f", xnum);]
-------------------------------
but you can also use _fcvt

int decimal, sign;
char *buffer;
double source = 0.123;

buffer = _fcvt( source, 3, &decimal, &sign);
--------------
result:

buffer = "123"
decimal = 0;
sign = 0;

from MSDN:
"The _fcvt function converts a floating-point number to a null-terminated character string. The value parameter is the floating-point number to be converted. _fcvt stores the digits of value as a string and appends a null character ('\0'). The count parameter specifies the number of digits to be stored after the decimal point. Excess digits are rounded off to count places. If there are fewer than count digits of precision, the string is padded with zeros.

Only digits are stored in the string. The position of the decimal point and the sign of value can be obtained from dec and sign after the call. The dec parameter points to an integer value; this integer value gives the position of the decimal point with respect to the beginning of the string. A zero or negative integer value indicates that the decimal point lies to the left of the first digit. The parameter sign points to an integer indicating the sign of value. The integer is set to 0 if value is positive and is set to a nonzero number if value is negative."
-------------------------
Note that you will get last digit rounding.

You did not indicate if you have to manually do the conversion.

Steve
GeneralDesperate to make List Box work from a text file Pin
macrophobia18-Feb-05 14:03
macrophobia18-Feb-05 14:03 
GeneralRe: Desperate to make List Box work from a text file Pin
Ravi Bhavnani18-Feb-05 15:52
professionalRavi Bhavnani18-Feb-05 15:52 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:13
macrophobia18-Feb-05 16:13 
GeneralRe: Desperate to make List Box work from a text file Pin
Ravi Bhavnani18-Feb-05 16:24
professionalRavi Bhavnani18-Feb-05 16:24 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:41
macrophobia18-Feb-05 16:41 
GeneralRe: Desperate to make List Box work from a text file Pin
Steve Mayfield19-Feb-05 11:16
Steve Mayfield19-Feb-05 11:16 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia19-Feb-05 17:02
macrophobia19-Feb-05 17:02 
GeneralRe: Desperate to make List Box work from a text file Pin
Steve Mayfield18-Feb-05 15:59
Steve Mayfield18-Feb-05 15:59 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:39
macrophobia18-Feb-05 16:39 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 17:53
macrophobia18-Feb-05 17:53 
GeneralProcess name shows up in short dos format Pin
SassenFrassenRassen18-Feb-05 12:23
SassenFrassenRassen18-Feb-05 12:23 
GeneralRe: Process name shows up in short dos format Pin
ThatsAlok18-Feb-05 19:17
ThatsAlok18-Feb-05 19:17 
GeneralImplementing a mouse click Pin
Mohammad A Gdeisat18-Feb-05 11:05
Mohammad A Gdeisat18-Feb-05 11:05 
GeneralRe: Implementing a mouse click Pin
Michael Dunn18-Feb-05 16:19
sitebuilderMichael Dunn18-Feb-05 16:19 
QuestionView All Records in Queue Question??? Pin
s2h13198518-Feb-05 10:47
s2h13198518-Feb-05 10:47 
GeneralGDI+ Print Bug Pin
Jorgen E.18-Feb-05 9:55
Jorgen E.18-Feb-05 9:55 
GeneralRe: GDI+ Print Bug Pin
Shog918-Feb-05 11:05
sitebuilderShog918-Feb-05 11:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.