Re: to_hex() for negative inputs

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема Re: to_hex() for negative inputs
Дата
Msg-id CAJ7c6TNYNiJRYaAnc44Pppmn+qzENDYVT4zwdyLTDZg=G6NT-g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: to_hex() for negative inputs  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
Hi Dean,

> > So in your opinion what is the expected result of to_hex(INT_MIN,
> > with_sign => true)?
> >
>
> "-80000000" or "-0x80000000", depending on whether the prefix is
> requested.

Whether this is the right result is very debatable. 0x80000000 is a
binary representation of -2147483648:

```
(gdb) ptype cur_timeout
type = int
(gdb) p cur_timeout = 0x80000000
$1 = -2147483648
(gdb) p/x cur_timeout
$2 = 0x80000000
```

So what you propose to return is -(-2147483648). For some users this
may be a wanted result, for some it may be not. Personally I would
prefer to get an ERROR in this case. And this is exactly how you end
up with even more flags.

I believe it would be better to let the user write the exact query
depending on what he/she wants.

-- 
Best regards,
Aleksander Alekseev



В списке pgsql-hackers по дате отправления:

Предыдущее
От: gkokolatos@pm.me
Дата:
Сообщение: Re: Add LZ4 compression in pg_dump
Следующее
От: gkokolatos@pm.me
Дата:
Сообщение: Re: Add LZ4 compression in pg_dump