c++.windows.32-bits - wsprintf with floats
- Steve & Denise De Chellis (3/3) Jul 03 2002 How do I use wsprintf with a float? I tried %f but it just printed f
- Walter (3/6) Jul 03 2002 %g for floats, %d for integers. -Walter
- Steve & Denise De Chellis (6/16) Jul 03 2002 wsprintf (szBuffer, TEXT ("c %g "), fEncumb);
- Steve & Denise De Chellis (5/24) Jul 03 2002 Changing it to sprintf did work though....
- Walter (3/33) Jul 03 2002 Try replacing TEXT("c %g") with L"c %g".
- Matthew Wilson (8/46) Jul 03 2002 Guys
- Walter (3/8) Jul 04 2002 It should work just like sprintf, but for wchar's.
- Matthew Wilson (12/22) Jul 05 2002 Walter,
- Walter (5/14) Jul 05 2002 Oh, I think you're right. My goof! I always have to stop and think if it...
- Matthew Wilson (7/23) Jul 09 2002 No worries. I guess I'm more attuned only because I chronically spend so
- mindstorm (8/11) May 08 2006 I don't know who's still listening here, but after finding this paste vi...
- asdfsa (1/1) Feb 14 2007 This forum is dead, but thanks for the tip.
How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
%g for floats, %d for integers. -Walter "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:afvcvu$26q7$1 digitaldaemon.com...How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
wsprintf (szBuffer, TEXT ("c %g "), fEncumb); SetDlgItemText (hDlg, 28, szBuffer); That is the code I tried but in the Dialog I end up with "c g" Steve "Walter" <walter digitalmars.com> wrote in message news:afvo5v$2hge$1 digitaldaemon.com...%g for floats, %d for integers. -Walter "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:afvcvu$26q7$1 digitaldaemon.com...How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
Changing it to sprintf did work though.... Anyone know why? Steve De Chellis "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:ag0auc$25p$1 digitaldaemon.com...wsprintf (szBuffer, TEXT ("c %g "), fEncumb); SetDlgItemText (hDlg, 28, szBuffer); That is the code I tried but in the Dialog I end up with "c g" Steve "Walter" <walter digitalmars.com> wrote in message news:afvo5v$2hge$1 digitaldaemon.com...%g for floats, %d for integers. -Walter "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:afvcvu$26q7$1 digitaldaemon.com...How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
Try replacing TEXT("c %g") with L"c %g". "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:ag0isj$aq9$1 digitaldaemon.com...Changing it to sprintf did work though.... Anyone know why? Steve De Chellis "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:ag0auc$25p$1 digitaldaemon.com...wsprintf (szBuffer, TEXT ("c %g "), fEncumb); SetDlgItemText (hDlg, 28, szBuffer); That is the code I tried but in the Dialog I end up with "c g" Steve "Walter" <walter digitalmars.com> wrote in message news:afvo5v$2hge$1 digitaldaemon.com...%g for floats, %d for integers. -Walter "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:afvcvu$26q7$1 digitaldaemon.com...How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
Guys Maybe I've missed something all these years, but I never thought that wsprintf handled floating point. The help for wsprintf certainly does not mention any floating point format sequences. Matthew "Walter" <walter digitalmars.com> wrote in message news:ag0k94$bu6$1 digitaldaemon.com...Try replacing TEXT("c %g") with L"c %g". "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:ag0isj$aq9$1 digitaldaemon.com...fChanging it to sprintf did work though.... Anyone know why? Steve De Chellis "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:ag0auc$25p$1 digitaldaemon.com...wsprintf (szBuffer, TEXT ("c %g "), fEncumb); SetDlgItemText (hDlg, 28, szBuffer); That is the code I tried but in the Dialog I end up with "c g" Steve "Walter" <walter digitalmars.com> wrote in message news:afvo5v$2hge$1 digitaldaemon.com...%g for floats, %d for integers. -Walter "Steve & Denise De Chellis" <dbouton snet.net> wrote in message news:afvcvu$26q7$1 digitaldaemon.com...How do I use wsprintf with a float? I tried %f but it just printedIf i use %i it cuts off the decimal... Steve De Chellis
Jul 03 2002
It should work just like sprintf, but for wchar's. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:ag0lbp$d39$1 digitaldaemon.com...Guys Maybe I've missed something all these years, but I never thought that wsprintf handled floating point. The help for wsprintf certainly does not mention any floating point format sequences. Matthew
Jul 04 2002
Walter, No offense, but I think you're getting mixed up with swprintf - the wide version of sprintf - which is an ANSI function. Steve is talking (as am I) about wsprintf - the USER32 sprintf replacement (apart from floating points) - which is a shorthand for all those people (wise souls, at least when using MSVC) who do not wish to link to the C-runtime libaries. Neither the ANSI (wsprintfA) or Unicode (wsprintfW) versions use floating points, I'm afraid Matthew "Walter" <walter digitalmars.com> wrote in message news:ag0vqq$o8r$1 digitaldaemon.com...It should work just like sprintf, but for wchar's. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:ag0lbp$d39$1 digitaldaemon.com...notGuys Maybe I've missed something all these years, but I never thought that wsprintf handled floating point. The help for wsprintf certainly doesmention any floating point format sequences. Matthew
Jul 05 2002
Oh, I think you're right. My goof! I always have to stop and think if it's sw or ws. Argh. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:ag3g4m$5dc$1 digitaldaemon.com...Walter, No offense, but I think you're getting mixed up with swprintf - the wide version of sprintf - which is an ANSI function. Steve is talking (as am I) about wsprintf - the USER32 sprintf replacement (apart from floating points) - which is a shorthand for all those people (wise souls, at least when using MSVC) who do not wish to link to the C-runtime libaries.Neitherthe ANSI (wsprintfA) or Unicode (wsprintfW) versions use floating points, I'm afraid Matthew
Jul 05 2002
No worries. I guess I'm more attuned only because I chronically spend so much effort in avoiding M$'s C-runtime library ... "Walter" <walter digitalmars.com> wrote in message news:ag4kcs$1bdq$2 digitaldaemon.com...Oh, I think you're right. My goof! I always have to stop and think if it's sw or ws. Argh. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:ag3g4m$5dc$1 digitaldaemon.com...I)Walter, No offense, but I think you're getting mixed up with swprintf - the wide version of sprintf - which is an ANSI function. Steve is talking (as amleastabout wsprintf - the USER32 sprintf replacement (apart from floating points) - which is a shorthand for all those people (wise souls, atpoints,when using MSVC) who do not wish to link to the C-runtime libaries.Neitherthe ANSI (wsprintfA) or Unicode (wsprintfW) versions use floatingI'm afraid Matthew
Jul 09 2002
In article <afvcvu$26q7$1 digitaldaemon.com>, Steve & Denise De Chellis says...How do I use wsprintf with a float? I tried %f but it just printed f If i use %i it cuts off the decimal... Steve De ChellisI don't know who's still listening here, but after finding this paste via a google link, I later worked out a solution. So wsprintf() doesn't support floating point numbers at all. Just do "wsprintf(yourBuffer, "%d.%d", (int)smallvalue, (int)(smallvalue/1000));", it works too. Thought I'd share that tip. Mindstorm www.mindstormgames.com
May 08 2006