In a type promotion example I am getting the output as 515.
I know that the value of char
c (which is 'a') after it gets promoted to an int
; but on what system is the value of char decided while promoting it to int
?
public class Main {
public static void main(String args[]) {
char c = 'a';
int i = 50000;
int result = i / c;
System.out.println("i / c is " + result);
}
}
c
is converted to its ASCII value of 97
.
So, 50000 / 97
~= 515
because of integer divisions (no floating decimals obtained in the result).