0
What will happen if one of them is double
Example (Double)/ integer......returned value will be???
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)
+ 3
// c++
double d=1.23;
int i=1;
cout << typeid(d/i).name();
Output: d (double)
+ 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.
+ 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
+ 1
Thanks Kirk Schafer
0