please run:
select 50000000*80/10000.00/366*31
select 500000000*80/10000.00/366*31
select 5000000000*80/10000.00/366*31
and kindly tell me the reasonThe first 2, 50000000*80 and 500000000*80, are implicitly converted to INT.
The reason is that 5e7 or 5e8 is less than 2^32-1 (2147483647). So, when you
multiply with 80 (which is also an INT because it's <2147483647) you
overflow.
The 3rd one, 5e9, is >2147483647 thus it's implicitly converted to BIGINT.
-oj
"Matthew" <Matthew@.discussions.microsoft.com> wrote in message
news:5B61BA42-01CC-4130-8DF8-5ECFD06D4660@.microsoft.com...
> please run:
> select 50000000*80/10000.00/366*31
> select 500000000*80/10000.00/366*31
> select 5000000000*80/10000.00/366*31
> and kindly tell me the reason|||Thanks oj,
but why they are not converted to numeric or float implicitly? There's
10000.00 in the statement.
"oj" wrote:
> The first 2, 50000000*80 and 500000000*80, are implicitly converted to INT
.
> The reason is that 5e7 or 5e8 is less than 2^32-1 (2147483647). So, when y
ou
> multiply with 80 (which is also an INT because it's <2147483647) you
> overflow.
> The 3rd one, 5e9, is >2147483647 thus it's implicitly converted to BIGINT.
> --
> -oj
>
> "Matthew" <Matthew@.discussions.microsoft.com> wrote in message
> news:5B61BA42-01CC-4130-8DF8-5ECFD06D4660@.microsoft.com...
>
>|||Shouldn't it?! Not in this case. Math calculation goes from left to right.
Thus, the overflow occurs before the next implicit conversion (int->dec).
It would have honored your desired implicit conversion from INT to DEC if
you divide by 10000.0 first like so.
e.g.
50000000*(80/10000.00)
-oj
"Matthew" <Matthew@.discussions.microsoft.com> wrote in message
news:671D74A0-C962-4CF8-BA1C-BAC061B8DECA@.microsoft.com...
> Thanks oj,
> but why they are not converted to numeric or float implicitly? There's
> 10000.00 in the statement.
> "oj" wrote:
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment