Home » U++ Library support » U++ Core » problem with Format
problem with Format [message #36141] |
Thu, 03 May 2012 18:08 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Hi,
I want to print a double with one decimal place like
57.2m Speed
so naturally I use
String s = Format("%.1fm Speed",height);
and this usually works. However, just now my program complains that it can't find the fm format specifier.
I went to the documentation on Format and it appears to say that I should do this
String s = Format("%1fm Speed",height);
but that really doesn't work. That gives
57.200000m Speed
For now I will have to leave a space between but really I think it should recognise the f and ignore the m.
Cheers,
Nick
|
|
|
Re: problem with Format [message #36142 is a reply to message #36141] |
Thu, 03 May 2012 19:58 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
nixnixnix wrote on Thu, 03 May 2012 12:08 | Hi,
I want to print a double with one decimal place like
57.2m Speed
so naturally I use
String s = Format("%.1fm Speed",height);
and this usually works. However, just now my program complains that it can't find the fm format specifier.
For now I will have to leave a space between but really I think it should recognise the f and ignore the m.
|
Well, actually, it would work in release mode only, by nasty trick to maintain backward compatibility with printf.
Thing is, if we want to have Format extensible, and we do, we need to have a little bit different rules (like eat all the id).
Anyway, what you are looking for is ` escape character:
String s = Format("%.1f`m Speed",height);
|
|
|
Goto Forum:
Current Time: Fri Apr 19 03:33:00 CEST 2024
Total time taken to generate the page: 0.02634 seconds
|