formating a double value does not work as expected



 DEVELOP > c-Plus-Plus > formating a double value does not work as expected

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Tenacious"
Date: 06 Dec 2007 11:33:21 AM
Object: formating a double value does not work as expected
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);
.

User: "Tenacious"

Title: Re: formating a double value does not work as expected 06 Dec 2007 11:34:47 AM
On Dec 6, 9:33 am, Tenacious <CT_Tay...@yahoo.com> 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.
.


  Page 1 of 1

1

 


Related Articles
Error: aggregate value used where an integer was expected
strftime not working as expected
template template arguments: expected a class template, got `Component
C++ teaser: Is this a compiler bug, or is this expected behavior?
find_if and mem_fun not getting expected results
expected class-name before '{'
Re: Linked list takes 10X more memory than expected. Why?
Compile error : Type name expected in typedef declaration on aCC HPUX11.0
Dependent Template Issue? g++ gives the following ==> error: expected primary-expression before "int"
Error E2303 Type name expected?
Re: Linked list takes 10X more memory than expected. Why?
"expected constructor, destructor, or type conversion before '->' token" using a Singleton
"error C2057: expected constant expression", "error C2466: cannot allocate an array of constant size 0". Why doesn't my simple program work???
"any.h": E2293 ) expected at line 210 ... why?
What does "expected unqualified-id before numeric constant" mean?
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER