delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/08/12/19:45:08

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Newsgroups: comp.os.msdos.djgpp
Subject: Help PLZ
From: Dumas <dumas AT hotmail DOT com>
Message-ID: <Xns9543C4B53396000yy77@207.35.177.135>
User-Agent: Xnews/5.04.25
Lines: 65
Date: Thu, 12 Aug 2004 23:17:38 GMT
NNTP-Posting-Host: 64.230.170.81
X-Complaints-To: abuse AT sympatico DOT ca
X-Trace: news20.bellglobal.com 1092352658 64.230.170.81 (Thu, 12 Aug 2004 19:17:38 EDT)
NNTP-Posting-Date: Thu, 12 Aug 2004 19:17:38 EDT
Organization: Bell Sympatico
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi
I'm using Dev-C++ to learning C++. I want to make some math programs that 
run from the DOS console.
I had tried unsuccessfully using unsigned integers, double (with 15 
pecision digits) and long double (with 19 precision digits) variables, so 
I made a short code to try the variables I need to use: 
=========================================================================
#include <iostream>
#include <stdlib.h>


using namespace std;

main()
{
 int                x1 = 2147483647;  
    	// output int OK
 unsigned long      x2 = 4294967294; 
    	/*unsigned long:[Warning] decimal constant is so large that is     
	  unsigned.
    	  I'm trying use unsigned, unsigned long with the same sesult */
 signed int         x3 = -2147483647; 
    //signed int:output max value acepted (not acept -2147483648
 short int          x4 = -32768;      
    //short int: output OK
 unsigned short int x5 = 65535;       
    //unsigned short: output OK

 float pi_float;
 double pi_double;
 long double pi_long_double;

 pi_float = 3.1415;                  
    	//flotad (precision 5 digit): output OK
 pi_double = 3.14159265358979;       
    	//double (precision 15 digits): output  3.14159
 pi_long_double = 3.141592653589793238; 
    	//long double (precision 19 digits): output  3.14159

    cout <<"int x1(2147483647) = " << x1 << endl;
    cout <<"unsigned int x2(4294967295) = " << x2 << endl;
    cout <<"signed int x3(-2147483648) = " << x3 << endl;
    cout <<"short int x4(-32768) = " << x4 << endl;
    cout <<"Unsigned short int x5(65535) = " << x5 << endl;
    cout <<"Pi float (3.1415) = " << pi_float << endl;
    cout <<"Pi double(3.14159265358979) = "<< pi_double << endl; 
    cout <<"Pi long double(3.141592653589793238) = "<< pi_long_double << 
endl;
    
  
  system("PAUSE");	
  return 0; 
}
==================================================================
Why I cannot get 15 and 19 precision digits with double and long double?
Why unsigned int doesn't work?
I have Windows XP - Athlon 2000
I'm reading C++ Interactive Course, C++ by disection and The C++ 
Programming Language 3rd Edition
I would appreciate any help and any bibliography.

Thanks in advance,
Dumas

PS: Sorry for my english.

- Raw text -


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