0

What will happen if one of them is double

Example (Double)/ integer......returned value will be???

8th Sep 2018, 6:59 PM
[ ]
[     ] - avatar
6 Antworten
+ 1
double, because in this no precision is lost you can also try this yourself by coding an example and print the type of this value depending on the programming language you also can assign it to a specific datatype (implicit conversion)
8th Sep 2018, 7:18 PM
Matthias
Matthias - avatar
+ 3
// c++ double d=1.23; int i=1; cout << typeid(d/i).name(); Output: d (double)
8th Sep 2018, 7:58 PM
Kirk Schafer
Kirk Schafer - avatar
+ 3
[meta, reader fyi] Note that 'upcasting' to higher precision can have unintended side-effects. A float may have only 15.8 digits of precision and we know the long tail is garbage... ...but upcast that to a double and you'd better handle the garbage or you've just made it significant. I believe this is a concern with all upcasts.
9th Sep 2018, 3:24 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
in Java, if you want too pass this value in an integer it will be error. if you pass this value in double it will be double. you can cast it to integer and then it will be integer
8th Sep 2018, 7:16 PM
Ilias
Ilias - avatar
+ 1
10th Sep 2018, 3:57 AM
[ ]
[     ] - avatar
9th Sep 2018, 3:04 AM
[ ]
[     ] - avatar