By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,945 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,945 IT Pros & Developers. It's quick & easy.

setting floating point precision problem

P: 35
hi,

i need to set precision for floating point operations in the c++ program.
i have a number of files.Please tell me how to do it ,so that i don't have to make the change in all the files in the program.
Nov 15 '08 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
You can't set the precision of floating point calculations in C++.

You can use one of the basic types float, double and long double. These 3 types each have fix precision (7 digits for a float and 15 for a double), on many platforms double and long double have the same precision but for some it is bigger (18 for example on by Ubuntu using GCC).

You set the precision by choosing which basic type to use, the normal choice would be double. You would only choose float if lack on memory on your platform was an issue (a float takes 4 bytes of ram and a double 8). If you required extra precision and you platform supported it you might use long double.
Nov 15 '08 #2

P: 35
You can't set the precision of floating point calculations in C++.

You can use one of the basic types float, double and long double. These 3 types each have fix precision (7 digits for a float and 15 for a double), on many platforms double and long double have the same precision but for some it is bigger (18 for example on by Ubuntu using GCC).

You set the precision by choosing which basic type to use, the normal choice would be double. You would only choose float if lack on memory on your platform was an issue (a float takes 4 bytes of ram and a double 8). If you required extra precision and you platform supported it you might use long double.

Thanks a lot for the reply.
:)
Nov 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.