#does subtracting characters subtract their ascii values?

1 messages ยท Page 1 of 1 (latest)

lunar reefBOT
#

<@&987246399047479336> please have a look, thanks.

#

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.

lilac ibex
#

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

opaque kite
#

this is indeed equal to 1, chars are ints

lunar reefBOT
#

Closed the thread.