Can someone please describe why we need Double within the expression? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can someone please describe why we need Double within the expression?

23rd Jul 2016, 11:48 PM
Cam
5 Answers
+ 2
Double is a cast. The variable is an integer, and will not multiply with a double. To fix this, the integer is cast into a double before multiplying. This causes the multiplication to be done with two doubles.
4th Sep 2016, 5:20 AM
Craig
+ 2
1.5 is a double,4 isn't. you have to convert 4 to double to multiply. hope I helped :)
14th Nov 2016, 5:37 PM
Adith Mathew
Adith Mathew - avatar
2nd Aug 2016, 3:33 AM
John Titor
+ 1
I Believe Double is basically used to return a double value.
4th Oct 2016, 8:39 PM
Ryan Lewis
Ryan Lewis - avatar
0
I believe that it allows swift to read and process decimal numbers. With out using "Double" swift only reads whole numbers.
25th Jul 2016, 6:14 PM
Vlad Averkov
Vlad Averkov - avatar