+ 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
怌ļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć€ 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