Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Problem: Real numbers
char *dispstr; int ddec, dsign; double immservice; . . //suppose immservice = 832.3343 and I convert it... dispstr = _fcvt(immservice, 5, &ddec, &dsign); //I will get dispstr = 8323345, ddec = 3; dsign = 0; // please guide me to obtain something to fit here... SetDlgItemText(hdlg,ID_TIMEQUEUE, ****** ); //...so that the displayed text is "832.3345" Thank you. Apr 08 2001
The sprintf function is an easier way of doing this. Use of --------------- char str[30]; sprintf(str, "%7.3f", immservice); SetDlgItemText(hdlg,ID_TIMEQUEUE, str ); ---------------- should do the trick. If you are using C++ (and why not? it is better!) why not define a class that does the following: (Based on the code above)(This is an excersize for you!) ----------------- FloatText ft(hdlg, ID_TIMEQUEUE); ft = immservice; ----------------- This will be quite useful if you need to do it often. - Rajiv Elisha Kendagor <kendagor iconnect.co.ke> wrote in message news:3AD0BA05.1DDC8AF4 iconnect.co.ke...char *dispstr; int ddec, dsign; double immservice; . . file://suppose immservice = 832.3343 and I convert it... dispstr = _fcvt(immservice, 5, &ddec, &dsign); file://I will get dispstr = 8323345, ddec = 3; dsign = 0; // please guide me to obtain something to fit here... SetDlgItemText(hdlg,ID_TIMEQUEUE, ****** ); file://...so that the displayed text is "832.3345" Thank you. Apr 10 2001
FloatText ft(hdlg, ID_TIMEQUEUE); ft = immservice; Apr 10 2001
Sorry, if that felt like a nag. You are right, a function will do. I thought of a class with overloaded assignment operators for printing ints and doubles and even user defined types, but overloaded functions can do these as well. Rajiv Jan Knepper <jan smartsoft.cc> wrote in message news:3AD33A0D.3B073D50 smartsoft.cc...FloatText ft(hdlg, ID_TIMEQUEUE); ft = immservice; Apr 10 2001
Rajiv Bhagwat wrote:I thought of a class with overloaded assignment operators for printing ints and doubles and even user defined types. Apr 11 2001
Jan Knepper <jan smartsoft.cc> wrote in message news:3AD4ADFF.2764579F smartsoft.cc...Rajiv Bhagwat wrote:I thought of a class with overloaded assignment operators for printing ints and doubles and even user defined types. Apr 11 2001
Kar Gay Lim wrote:(Isn't it kinda surprizing that functions like these are still not part of the Windows API...) Apr 11 2001
Hey all, Thanks a lot for your help. It really Knepped it! Jan Knepper wrote:Kar Gay Lim wrote:(Isn't it kinda surprizing that functions like these are still not part of the Windows API...) Apr 13 2001
|