#does subtracting characters subtract their ascii values?
1 messages ยท Page 1 of 1 (latest)
Here is an AI assisted attempt to answer your question ๐ค. Maybe it helps! In any case, a human is on the way ๐. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
In Java, when you subtract two characters, it actually subtracts their ASCII values. So, the expression 'B' - 'A' will indeed result in 1 because the ASCII value of 'B' is 66 and the ASCII value of 'A' is 65.
There is no bad or unknown behavior when subtracting characters in this way. It is a well-defined behavior in Java and will always give you the expected result.
this is not undefined behavior, its clearly defined what should happen
and yes, it will convert the chars to int
which is their ascii index
and then do the operation on that
the result is an int
this is indeed equal to 1, chars are ints
Closed the thread.