Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > formating a double value does not work as expected

Reply
Thread Tools

formating a double value does not work as expected

 
 
Tenacious
Guest
Posts: n/a
 
      12-06-2007
Can anyone tell me why strSpd2 in the example below ends up being a
blank string when formatting a zero value? It would seem to me that
strSpd2 should end up being "0.0"

double val1 = 14.38009
double val2 = 0.0;
string strSpd1 = "";
string strSpd2 = "";

// This formats correctly. strSpd1 = "14.4"
strSpd1 = String.Format("{0:##.#}", val1);

// This does not format. strSpd2 = ""
strSpd2 = String.Format("{0:#.#}", val2);

 
Reply With Quote
 
 
 
 
Tenacious
Guest
Posts: n/a
 
      12-06-2007
On Dec 6, 9:33 am, Tenacious <(E-Mail Removed)> wrote:
> Can anyone tell me why strSpd2 in the example below ends up being a
> blank string when formatting a zero value? It would seem to me that
> strSpd2 should end up being "0.0"
>
> double val1 = 14.38009
> double val2 = 0.0;
> string strSpd1 = "";
> string strSpd2 = "";
>
> // This formats correctly. strSpd1 = "14.4"
> strSpd1 = String.Format("{0:##.#}", val1);
>
> // This does not format. strSpd2 = ""
> strSpd2 = String.Format("{0:#.#}", val2);


Sorry, I put this in the wrong group.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value does not fall within the expected range - Crystal Report hot fix anamika ASP .Net 0 06-15-2006 10:49 AM
CrystalReports: Value does not fall within the expected range. =?Utf-8?B?amF2YXRvcGlh?= ASP .Net 4 10-14-2005 06:16 PM
Config: Allow Roles does not work as expected Brian Takita ASP .Net 3 05-12-2005 06:30 AM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM



Advertisments