Re: Why don't we accept exponential format for integers?

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема Re: Why don't we accept exponential format for integers?
Дата
Msg-id AANLkTin1aB49XKAUTAXpkPE=C1u888kvVqPHjF-8qUQf@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Why don't we accept exponential format for integers?  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-hackers
On Sat, Dec 18, 2010 at 00:05, Josh Berkus <josh@agliodbs.com> wrote:
> Well, that's stupidly arbitrary.  If we're not going to accept
> '1.234e+01'::Integer, then we shouldn't accept 1.234e+01::Integer either.

Not surprising to me. This is how many languages implement type conversion.

Python:
>>> int(1.234e+01)
12
>>> int('1.234e+01')
ValueError: invalid literal for int() with base 10: '1.234e+01'

PHP:
print intval(1.234e+01) . "\n";
print intval('1.234e+01') . "\n";
gives:
12
1
Because PHP's int->string cast terminates parsing when it sees an
unrecognized character.

Java makes the difference quite explicit and obvious:
int a = (int)1.234e+01;
int a = Integer.parseInt("1.234e+01);

Regards,
Marti


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why don't we accept exponential format for integers?
Следующее
От:
Дата:
Сообщение: Re: Why don't we accept exponential format for integers?