[Solved] Data type conversion [closed]


What do You mean?

You have to cast f to long and b to char and also initialize them.

l = (long) f;
ch = (char) b;

//----
float f = 3.14f;
long l ;
char ch;
byte b = 38;
l= (long) f;
ch= (char) b;   

Check examples:

int first = 3:
int second = 2;
double result = first / second;  // the result is 1 because first and second are integers

first = 3;
second = 2;
double result1 = (double)first / second;  // result is: 1.5

double result2 = first / (double)second;  // result is: 1.5

double result3 = (double)(first / second);  // result is: 1

solved Data type conversion [closed]