Re: Operation on bit strings with different length

Поиск
Список
Период
Сортировка
Искать

Re: Operation on bit strings with different length

От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
S P Arif Sahari Wibowo writes:

> Do you know how to operate (AND, OR, etc.) on bit strings with
> dynamically different length? It is dynamic, means the length won't be
> determined until run time.
> Is there any function to extend the length of a bit string to a certain
> length?

Something along the lines of

SUBSTRING ( your_value || B'000000000000...long enough...000' FROM 1 FOR max_length )

The reason this is not done automatically is that it's not clear whether
the extension should be to the left or to the right.  Either of these
could be appropriate, depending on whether you consider bit strings to be
strings or numbers.  Once you know what you want in your application you
can wrap the above into a function.  To generate a generic "long enough"
value, look at the REPEAT function.

-- 
Peter Eisentraut   peter_e@gmx.net


Operation on bit strings with different length

От:
S P Arif Sahari Wibowo <arifsaha@yahoo.com>
Дата:
Hi!

Do you know how to operate (AND, OR, etc.) on bit strings with 
dynamically different length? It is dynamic, means the length won't be 
determined until run time.
Is there any function to extend the length of a bit string to a certain 
length?

Thank you!

-- 
                                   S P Arif Sahari Wibowo
  _____  _____  _____  _____ 
 /____  /____/ /____/ /____          arifsaha@yahoo.com
_____/ /      /    / _____/       http://www.arifsaha.com/

FAQ