Skip to content Skip to sidebar Skip to footer

Cursor Getint Return Negative Value

at first I want to notice that english isn't my native language, whatever I hope we won't have missunderstaning I write simple application on Android, and found an issue, also solv

Solution 1:

Are you sure you're using unixtime (seconds since epoch) and not e.g. Java system time (milliseconds since epoch)?

For example, unixtime 1387233645 fits well in a 32-bit int.

However, millisecond stamp 1387233645000 is too large for 32 bits. In hex it's 0x142fd9191c8. Taking the bottom 32 bits leaves us with 0xfd9191c8 which is -40791608 in decimal when interpreted as a Java int i.e. signed two's complement 32-bit integer.

Solution 2:

The value you entered into that database field must be greater than 2^31-1, ie. the max int positive value. As int type is a signed integer, if the left-most bit (position 32) is 1, this value is interpreted as negative.

When you load the value as long, all bits are interpreted differently to mean a positive long number.

Post a Comment for "Cursor Getint Return Negative Value"