Negative Integers
remeolb
Posts: 79
DATA_EVENT[dvAUDIO_SWITCH] { STRING: { STACK_VAR CHAR sMYBUF[50] STACK_VAR INTEGER nSTRING_LENGTH STACK_VAR INTEGER nAUDIO_SWITCH_OUTPUT WHILE(FIND_STRING(sAUDIO_RXBUF,'SL2',1)) // WHILE THE MESSAGE IS A STATUS UPDATE { REMOVE_STRING(sAUDIO_RXBUF,'SL2',1) sMYBUF = REMOVE_STRING(sAUDIO_RXBUF,')',1) IF(LEFT_STRING(sMYBUF,1) == 'O') { GET_BUFFER_CHAR(sMYBUF) nAUDIO_SWITCH_OUTPUT = ATOI(LEFT_STRING(sMYBUF,1)) REMOVE_STRING(sMYBUF,' ',1) nSTRING_LENGTH = LENGTH_STRING(sMYBUF) sMYBUF = LEFT_STRING(sMYBUF,(nSTRING_LENGTH - 2)) sAUDIO_SWITCH_VOLUME = sMYBUF nSTRING_LENGTH = LENGTH_STRING(sMYBUF) IF(FIND_STRING(sAUDIO_SWITCH_VOLUME,'M',1)) { nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = -700 } ELSE IF(FIND_STRING(sAUDIO_SWITCH_VOLUME,'-',1)) { nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = (ATOI(RIGHT_STRING(sAUDIO_SWITCH_VOLUME,(nSTRING_LENGTH -1))) * (-1)) } ELSE { nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = ATOI(sAUDIO_SWITCH_VOLUME) } REMOVE_STRING(sMYBUF,LEFT_STRING(sMYBUF,nSTRING_LENGTH),1) fnAUDIO_SWITCH_VOLUME_UPDATE() } } } }
Why if sAUDIO_SWITCH_VOLUME is '-150' does my integer nAUDIO_SWITCH_VOLUME[] store as 65386 instead of -150? I know that 65386 - 65536 = -150 but I don't get why it is storing info that way. nAUDIO_SWITCH_VOLUME is defined as an sinteger.
0
Comments
http://en.wikipedia.org/wiki/Two's_complement
--D
This is my variable declaration and I'm still getting issues.
I actually don't believe that I've ever seen the debugger show a negative number for a sinteger. If there's a way to do that, I'll be very happy.