Wrong string to integer conversion ?

1,679 views
Skip to first unread message

tuxshadow

unread,
Jul 14, 2009, 12:21:12 PM7/14/09
to H2 Database
Hi

can someone explain me why these two statement returns different
values ?

select convert('023',integer)

return 19

select convert('023',double)

return 23

I'm running version 1.1.115 on java 1.6.0_13

Thanks in advance

E.

Johann Schleier-Smith

unread,
Jul 14, 2009, 1:54:05 PM7/14/09
to h2-da...@googlegroups.com
In the first case, the leading '0' indicates an octal representation of the number.

Thomas Mueller

unread,
Jul 17, 2009, 12:51:58 PM7/17/09
to h2-da...@googlegroups.com
Hi,

I will add this to the documentation of CAST:

"When converting a text to a number, the default Java conversion
rules are used (prefixes 0x or # for hexadecimal numbers, prefix 0 for
octal numbers)."

Regards,
Thomas

Chad McHenry

unread,
Jul 17, 2009, 1:44:16 PM7/17/09
to h2-da...@googlegroups.com
Is there a reason why converting to integer honors octal formatting, but converting to double does not?

Thomas Mueller

unread,
Jul 20, 2009, 2:18:10 AM7/20/09
to h2-da...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages