0

Why does the "int" command work for "x=10" but the writer used "double" for "y=20"?

19th Aug 2016, 2:04 AM
Christian Timmermans
Christian Timmermans - avatar
5 Antworten
+ 4
20 can be an int, float, double, or a string. It depends on how you intend to use it
19th Aug 2016, 6:25 PM
oStaiko
oStaiko - avatar
+ 3
Definition: A double is a larger float type that holds both bigger and more precise numbers. Double variables are 8 bytes in size. The range of values is from 2.2250738585072020×10−308to 1.7976931348623157×10308 More importantly, the precision of a double is 15 compared to 6 for a float. The precision of a number is how many digits (before and after the decimal point) it can store without errors occurring
19th Aug 2016, 10:29 PM
Harry Pearson
Harry Pearson - avatar
+ 2
It wasn't required. I think they did that just for variety and to show you can do it. It's also interesting to note that the output stayed 20 and not 20.0 or something.
20th Aug 2016, 11:05 PM
Gregory Vinyard
Gregory Vinyard - avatar
0
You can you int "y=20"; there is no problem with that ...double is mainly used for precise value .
21st Aug 2016, 2:35 PM
Ashish Anand
Ashish Anand - avatar
- 6
cbdbf161c200192b21f25933fb92bc29af375f3d57b2297f7d497
19th Aug 2016, 8:50 AM
Tom Boo
Tom Boo - avatar