X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: "Alex Vinokur" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp Subject: Re: setw & notation Date: Tue, 23 Apr 2002 16:31:13 +0200 Organization: Scopus Lines: 97 Message-ID: References: <3CC55D84 DOT 5FA93D1 AT earthlink DOT net> NNTP-Posting-Host: gateway.scopus.net (62.90.123.5) X-Trace: fu-berlin.de 1019568587 8059650 62.90.123.5 (16 [79865]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Martin Ambuhl" wrote in message news:3CC55D84 DOT 5FA93D1 AT earthlink DOT net... | Alex Vinokur wrote: | | > 5e-05 || MY COMMENT : Why not 0.00005 ? | > 6e-06 || MY COMMENT : Why not 0.000006 ? | | If you want fixed point, say so. Change | cout << setw(show_size_i) << value_i << endl; | to | cout << fixed << setw(show_size_i) << value_i << endl; | [snip] I don't want fixed point. I want the output to be as following : 0.1 0.02 0.003 0.0004 0.00005 0.000006 Using 'fixed' causes a new problem. (P.S. I don't want to define value's maximal size beforehand.) ###### Source C-file : BEGIN ###### // File t2.cpp #include #include using namespace std; // ----------------------- template void show_it ( unsigned int show_size_i, const T1& value_i ) { cout.setf (ios::right, ios::adjustfield); cout << fixed << setw (show_size_i) << value_i << endl; } // ----------------------- int main () { #define SHOW_SIZE_CNS 15 show_it (SHOW_SIZE_CNS, 0.1); show_it (SHOW_SIZE_CNS, 0.02); show_it (SHOW_SIZE_CNS, 0.003); show_it (SHOW_SIZE_CNS, 0.0004); show_it (SHOW_SIZE_CNS, 0.00005); show_it (SHOW_SIZE_CNS, 0.000006); show_it (SHOW_SIZE_CNS, 0.0000007); show_it (SHOW_SIZE_CNS, 0.00000008); return 0; } ###### Source C-file : END ######## ###### Compilation & Run : BEGIN ###### %gpp t2.cpp %a.exe 0.100000 0.020000 0.003000 0.000400 0.000050 0.000006 0.000001 || Shows invalid value 0.000000 || Shows invalid value ###### Compilation & Run : END ######## ==================== Alex Vinokur http://up.to/alexvn http://go.to/alexv_math mailto:alexvn AT bigfoot DOT com mailto:alexvn AT go DOT to ====================