cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/29/21:46:36

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: c++ problem
Date: Sat, 29 Aug 1998 20:42:23 -0300
Organization: NBTel Internet
Lines: 56
Message-ID: <35E891DF.9CAFCBF7@unb.ca>
References: <6s9qs3$su6$4 AT planja DOT arnes DOT si>
NNTP-Posting-Host: fctnts10c33.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Iztok Polanic wrote:
> Hello !!!
> I've bought myself a book called Beginning C++ ANSI/ISO Compliant by Ivor
> Horton. But the example doesn't want to compile. I always receive this
> error:
> --------------
> 2.6A.cpp:3: warning: namespaces are mostly broken in this version of g++
	This warning should be VERY self-explaining.  Name spaces don't work properly
in DJGPP yet.

> Here's the source code:
> --------------
> #include <iostream.h>
> #include <iomanip.h>
> using namespace std;
> 
> int main()
> {
>         float value1 = 0.1f;
>         float value2 = 2.1f;
>         value1 -= 0.09f;
>         value2 -= 2.09f;
> 
>         cout << setprecision(14) << fixed;
>         cout << value1 - value2 << endl;
> 
>         cout << setprecision(5) << scientific;
>         cout << value1 - value2 << endl;
> 
>         return 0;
Here's code that'll work in DJGPP:
#include <iostream.h>
#include <iomanip.h>

int main()
{
        float value1 = 0.1f;
        float value2 = 2.1f;
        value1 -= 0.09f;
        value2 -= 2.09f;

        cout << setprecision(14) << setiosflags(ios::fixed);
        cout << value1 - value2 << endl;

        cout << setprecision(5) << setiosflags(ios::scientific);
        cout << value1 - value2 << endl;

        return 0;
}

-- 
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019