+ 3

Float and double

Could someone explain me, what the dofference between float and double is?

19th Jun 2018, 9:34 AM
Adam
Adam - avatar
6 Answers
+ 12
Double can store value with higher precision which is up to 64 bit. Float can store value up to 16 bit
19th Jun 2018, 1:30 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 6
Hello, Adam The principal nuance here is that you operate with decimal numbers, and float and double are binary ones. Those numbers that you divide and receive as a result are unimaginable in a binary number system without periodic fractions. What you observe is not rounding and chopping, but computer attempts to cram things that are not intractable and pretend that everything is actually in order. Since the number of bits in the mantissa and the exponents of the float and double types is different, then "rounding" and "chopping" will occur from your point of view "unpredictable". This situation is exacerbated by the fact that the accuracy of calculations on the conscience of the processor, which, generally speaking, is not required to give accuracy to the last sign. On another computer, you can see other results - unless you turn on a special "predictable" mode, which is slower. But even in this case you will get only the same, but "unpredictable" results on different computers.
19th Jun 2018, 9:39 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 5
Float can store significant digits after decimal at a limit but Double can store higher than that particular limit. In simple language,Double can be used where the numbers are decimal should be high or needs accuracy whereas Float can be used where we don't need Double.
19th Jun 2018, 3:34 PM
Sujal Kumar
Sujal Kumar - avatar
+ 3
wouldn't slow the performance, sometimes isn't necessary, and is convenient save memory for other things... Although it seems insignificant, truly these details make the project effective
21st Jun 2018, 1:02 PM
Leo Vertiz
Leo Vertiz - avatar
+ 2
The capacity for store, Double can store 64 bites or 8 bytes, more than float with 32 bites (4 bytes)
21st Jun 2018, 5:30 AM
Leo Vertiz
Leo Vertiz - avatar
+ 1
Since double can store 64 bits,why don't we use double alone.. What is the need of float?is it may be because if we use larger memory space using double instead of float would slow the performance?
21st Jun 2018, 8:53 AM
Karthik
Karthik - avatar