- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Double precision problems in C++ ( aCC compile...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:20 AM
12-18-2003 01:20 AM
Double precision problems in C++ ( aCC compiler)
I have aCC compiler (A. 3.33) in HP 11.0( 32 bit)
I faced the problem with compiler truncating some digits in decimals.
I wrote a sample program.
double d = 123456789.123456789123456789;
cout << setprecision(30) << d;
I got the program output as
123456789.12345679
I have read in some of the books that a double variable occypying 64 bits , can keep upto a maximum of 19 digits before decimal and 16 digits after the decimal. But, this does not seem to be happening.
Could somebody help me in solving this problem.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:30 AM
12-18-2003 01:30 AM
Re: Double precision problems in C++ ( aCC compiler)
Seems like you reach some limits..
-Tomek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 03:02 AM
12-19-2003 03:02 AM
Re: Double precision problems in C++ ( aCC compiler)
I think IEEE-754 is the standard for floating point, and you get 14 significant figures with double precision and 28 with long double. Below is an example of 28 sig. figures:
H:src:357$ cat test.C
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
long double ld = 0.9999999999999999999999999999l;
cout << setprecision(28) << 0.9999999999999999999999999999l << ' '
<< ld << endl;
return 0;
}
H:src:358$ aCC +DA2.0W -AA test.C
H:src:359$ ./a.out
0.9999999999999999999999999999 0.9999999999999999999999999999
Regards,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2003 07:19 PM
12-20-2003 07:19 PM
Re: Double precision problems in C++ ( aCC compiler)
IEEE standard has 3 types of floating point:
1) single precision figured on 32 bit
2) double precision figured on 64 bit
2) long double precision figured on 80 bit.
Notice IEEE doesn't refer to language but to CPU rappresentation.
The FP number has 2 section: the exponent and mantissa. Now I don't remember the the # of bits for every precision but I'm sure of limit:
1) single precision +/- 1.6 E30: you have 6 digits 1/2 of precision (for example 199999);
2) double precision +/- 1.9 E300: you have 18 digits 1/2 of precision (for example 1123456789012345678).
This means you can see any number of double precision with 18 digit plus digit 1 as most significative digit; also FP doesn't different digit before or after decimal point; so you can see 1.123456789012345678 or 11234567890.12345678 or 1123456789012345678 etc.
Also note you can't see follow 2123456789012345678 because 1st digit before 18 digits may be only 0 or 1.
IEEE can figure also NaN (invalid value) and infinite with double and long double precision; thees value are not avaiable in single precision.
At least, IEEE required compiler use long double in computate and result must be coonvert in less precision; this means avery compiler could convert any variable to long double, compute the result and reconvert to original precision.
H.T.H.
Antoniov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2003 04:47 PM
12-21-2003 04:47 PM
Re: Double precision problems in C++ ( aCC compiler)
My special thanks to Anatov, which clarified my understanding about precision limits.
It looks like, I have to look for some other solutions to retain precision ( One solution could be , to use arbitary precision math library)
-Hari