Monday, April 27, 2009

Stupid SQL, First Edition - now with support for negative numbers

This one handles negative numbers too, up to negative 2^64:

select
lpad(rawtohex(chr(floor(mod(MyNumber + 18446744073709551616, 18446744073709551616) / 4294967296))), 8, '0') ||
lpad(rawtohex(chr(mod(MyNumber + 18446744073709551616, 4294967296))), 8, '0')
from dual

No comments:

Post a Comment