Thursday, February 27, 2014

JNI turn inside char int not a sign extension? ? ?


RT

JNI code:
 
# Include
# Define LOGI (...) ((void) __android_log_print (ANDROID_LOG_INFO, "zc", __ VA_ARGS__))


{
char c = -2;
long l = c;
LOGI ("c:% d, l:% d ==> (% ld,% ld) -> (% d)", c, l, c, l, sizeof (char));
}

The results are output to:
 
c: 254, l: 254 ==> (254, 254) -> (1)


Question:
The output result is not what -2 l? ? ? char turn int not a sign extension? Become unsigned extended? ?
How can we achieve a signed char to int extension? ?

Seek advice ~ ~ thanks.

ps: the results of the investigation program in the wrong half, head ache are checked before they found, actually here are the results ... so depressed ...





<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
This feeling is char ascii code corresponding value was converted to int the

Reply:
cited a floor birdsaction reply:
this feeling is char ascii code corresponding value was converted to int a

This is not the equivalent of an unsigned extension it ..........

No comments:

Post a Comment