Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » problem with Format
problem with Format [message #36141] Thu, 03 May 2012 18:08 Go to next message
nixnixnix is currently offline  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 Go to previous message
mirek is currently offline  mirek
Messages: 13032
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);
Previous Topic: Problem with "Time" type in XML strings
Next Topic: Read CSV Line (Solved)
Goto Forum:
  


Current Time: Sat Jan 16 10:06:35 CET 2021

Total time taken to generate the page: 0.01501 seconds