Deinnis Thanks for the help. That worked quited well. I think the issue however was that sqlite uses Signed integers And my Number although a valid 64bit hex number was to large to fit into a 64 bit signed value. Sqlite simply coerced it into a "text" field for storage.
I'll proceed with your workaround. In the mean time I wonder if it would be possible as an enhancement to add 64bit unsigned integer storage into sqlite? And also the capability to convert strings such as '0xffff' as this would make writing this type of bit based logic so much easier. Regards, Ken Dennis Cote <[EMAIL PROTECTED]> wrote: Ken wrote: > I've created a table and need to perform some bitwise operations against one > of the fields. I find that 0 is returned back from the select. > > Also I'd like to add a feature request such that sqlite would understand > '0xffff' syntax and convert a hex string into a number. Or at least a > function so that the sql code is more readable. > > Example follows: > Thanks, > Ken > > > Sqlite version is 3.5.4 > > create table x (val integer ); > insert into x values (10083463462913); > > select to_hex(val) from x; (note to_hex is my own function). > to_hex(val) > 0x92bbd420001 > > I want to strip off the 0001 portion. So and it with 18446744073709486080 > which is 0xffffffffffff0000 > > select val&18446744073709486080 from x; > val&18446744073709486080 > 0 > > select (val&18446744073709486080) from x; > (val&18446744073709486080) > 0 > Ken, Sqlite uses signed 64 bit integer values, so your literal 18446744073709486080 is too large and it is approximated as a floating point value 1.84467440737095e+19. You could use the corresponding signed value -65536, but a better way to generate such a mask is to shift a -1 (all F's) value to insert the required zero bits. select 10083463462913 & (-1 << 16); 10083463462912 This is the correctly masked value. HTH Dennis Cote ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------