Re: BUG #1578: ::bit(n) behaves "differently" if applied to bit
В списке pgsql-bugs по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: BUG #1578: ::bit(n) behaves "differently" if applied to bit |
| Дата | |
| Msg-id | 1991.1115913668@sss.pgh.pa.us обсуждение |
| Ответ на | Re: BUG #1578: ::bit(n) behaves "differently" if applied to bit (Bruce Momjian <pgman@candle.pha.pa.us>) |
| Список | pgsql-bugs |
"Celia McInnis" <celia@drmath.ca> writes:
> select 949::bit(10) gives 1110110101 (as expected).
> select 949::bit(10)::bit(3) gives 111 (the 3 most significant bits)
> select 949::bit(3) gives 101 (the 3 least significant bits).
> As a mathematician, I'd certainly at least want the last two selects to give
> the same results!
Unfortunately, the behavior of casting between bit(m) and bit(n) is not
open to negotiation --- it's given by the SQL standard.
I think the only way to make this stuff truly mathematically consistent
would be to go over to a "little endian" approach in which casting from
integer to bit puts the LSB of the integer into the first, not the last,
bit of the bit string. But that is probably too big a compatibility
hit to consider ... and I for one would find it less useful not more.
regards, tom lane
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера