However, in most cases, float and double seem to be interchangeable, i.e Using one or the other does not seem to affec. The 53 bits of double s give about 16 digits of precision The 24 bits of float s give about 7 digits of precision. Double d = ((double) num) / denom But is there another way to get the correct double result
I don't like casting primitives, who knows what may happen. 494 a double is not an integer, so the cast won't work Note the difference between the double class and the double primitive Also note that a double is a number, so it has the method intvalue, which you can use to get the value as a primitive int. In my earlier question i was printing a double using cout that got rounded when i wasn't expecting it How can i make cout print a double using full precision?
How can i get double quotes into a string literal? A double has a much higher precision due to it's difference in size If the numbers you are using will commonly exceed the value of a float, then use a double Several other people have mentioned performance isssues That would be exactly last on my list of considerations Correctness should be your #1 consideration.
1 create the double[] first, add the numbers to it, and add that array to the list (the variable should likely be declared as a list, btw, not an arraylist, unless you're specifically passing it to something that explicitly expects an arraylist.) Long double vs double i am new to programming and i am unable to understand the difference between between long double and double in c and c++ I tried to google it but was unab.
OPEN