hi all.....
i have Transaction ids 1000000 or greater in size
i want to do a math computation to represent any number in smaller digits...
example
838 some math function(s) would calculate back to starting number
starting number 18347868 calculate some math to smaller number and then
back
TIA
DaveP
I am not quite clear what it is you want to do. I have two
suggestions that might, or might not, be what you want.
1. Purely to compress the string representation of the number you
could use Binary Coded Decimal (BCD) This packs two decimal digits
into a single byte, so your 1000000 would take up four bytes in packed
BCD. For example your 18347868 -> { 0x18 0x34 0x78 0x68 } in BCD,
four bytes.
2. If you want to reduce the actual size of the numbers used
internally then pick a reasonable sized prime number, like 1019, and
make all your Transaction IDs multiples of that number. Just store
T_ID / 1019 and multiply when you need to restore the full Transaction
ID.
T_ID Internal Representation
18347095 18005
18348114 18006
18349133 18007
18350152 18008
This means that you cannot use every possible Transaction ID, your
18347868 is not allowed for instance because it is not a multiple of
1019. If this is a problem for you then do not use this method.
rossum