Double and float | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Double and float

void Test(double d) {cout << "1";} void Test(float e) {cout << "2";} int main() { Test(1.0); // calls double function } I am not aware how to call Test from main for float... I mean to say what should be passed as value for float type function call...

16th Mar 2018, 3:11 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Answers
+ 3
Man Ketan Lalcheta you can use float casting to if you are sure about calling function is passing float data. Test((float)1.0); // calls float function
30th May 2018, 10:06 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 2
its better practice to forget about float and always use double. Internally java casts every float to a double and then converts them back anyway
16th Mar 2018, 6:59 AM
Jeremy
Jeremy - avatar
+ 2
「HAPPY TO HELP」 true Double and float void Test(double d) {cout << "1";} void Test(float e) {cout << "2";} int main() { Test(1.0f); // calls float function }
30th May 2018, 10:01 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar