+ 1
What is the difference between float and double?
4 Respostas
+ 2
Which type to use depends on your needs. If you have a large volume of data use float to save memory. Otherwise, doubles are better because of their higher precision. On Intel desktops and laptops floats will be converted to doubles in the processor anyway.
In short, use double unless you are running low on memory, then use float.
+ 1
the alloted memory float i believe has 4 bytes and double has 2x4 = 8bytes
+ 1
Generally speaking, a float is 32 bits (4 bytes) and a double is 64 bits (8 bytes). Thus a double has greater range and precision than a float. For compiled languages (C, C++, C# and objective C) it may vary depending on the target architecture. In some cases they may be the same, but the standard requires that a double will be at least as large as a float in range and precision. In Java both are determined by the JVM.
+ 1
But why are all those bits important. If I want to define a decimal value, what of these two should I use?