From: Ivan Hoo <[email protected]> - 11 Dec 1998
> [...] if i were to perform a c4_View::SelectRange on this signed int > column with the unsigned int rowref values pass to it as min > and max, the range returned might not actually be the expected one > considering that the signed int range is not actually the same as in > the case of unsigned int...
You are right. This matters when your integers can potentially be 32 bits in magnitoude - everything below will work as is, evidently.
I can think of three ways to get around this:
1) Split the integer into two or more independent fields, and split recombine as needed. Sorting will work, using a multi-level key. Selection of ranges will not work without extra effort. 2) Store the value as a c4_Bytes property. To make sure sorting works, you should probably reorganize each value as 7-bit chunks, since comparison uses memcmp, which may/may-not be signed. This is more work for access/storage, but sorts/selects will work. 3) Flip the sign bit (bit 31) during storage. This is a nasty trick which will let comparisons work as expected, thus enabling the sorting and selection. You just have to make sure you flip the sign bit around on every occasion, including as selection value.
-- JC