Subject Re: RE: [firebird-support] Cast as Numeric without parenthesis
Author liviuslivius
then why here is an error?
 
SELECT CAST('123456789.23' as numeric) FROM RDB$DATABASE
 
result should be 123 456 789 is less then 2 147 483 647
i assume this, because this working:
 
SELECT CAST('12345678.23' as numeric) FROM RDB$DATABASE
SELECT CAST('123456789' as numeric) FROM RDB$DATABASE
 
PS. good to know that this is Numeric(9, 0)
 
regards,
Karol Bieniaszewski
 
 
W dniu 2015-03-26 11:03:59 użytkownik Rand Random rand.random@... [firebird-support] <firebird-support@yahoogroups.com> napisał:
 
Only the negative range goes to 2147483648 and you used positive value which is ranged till 2147483647,
 
so this should work
 
SELECT CAST('-2147483648' as numeric) FROM RDB$DATABASE
SELECT CAST('-2147483648' as numeric(9,0)) FROM RDB$DATABASE

 

To: firebird-support@yahoogroups.com
From: firebird-support@yahoogroups.com
Date: Thu, 26 Mar 2015 10:05:17 +0100
Subject: RE: [firebird-support] Cast as Numeric without parenthesis

 
I would expect numbers in the range -2147483648 to +2147483647 to be accepted (the size of an integer), and then there’s a separate field for storing whether things are shifted to the left or right. I’ve no experience or theoretical knowledge confirming this, but your examples would fit such a description. Hence, I would guess NUMERIC to default to NUMERIC(9, 0).

I've confirmed that

SELECT CAST('2147483647' as numeric) FROM RDB$DATABASE
SELECT CAST('2147483647' as numeric(9,0) FROM RDB$DATABASE

both are accepted, whereas

SELECT CAST('2147483648' as numeric) FROM RDB$DATABASE
SELECT CAST('2147483648' as numeric(9,0) FROM RDB$DATABASE

are rejected.

HTH,
Set
 
~-|**|PrettyHtmlStart|**|-~