
|
Limit or Bug?
- From: "Jared Still" <jkstill@xxxxxxxxx>
- To: "Oracle-L Freelists" <oracle-l@xxxxxxxxxxxxx>
- Date: Thu, 3 Jul 2008 13:44:59 -0700
The following bit of SQL uses the mod() function to determine modulus 2 of
two large numbers
13:37:20 SQL>set echo on
13:37:24 SQL>@mod_test
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,127)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,127)-1,2)
---------------------
1
1 row selected.
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,128)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,128)-1,2)
---------------------
-1
1 row selected.
13:37:25 SQL>
--------------------------------------------------
Notice that mod(power(2,128)-1,2) returns an incorrect answer, while the
answer for mod(power(2,127)-1,2) is correct.
Does someone here know why?
Is it a limit?
Or is it a bug?
Please supply an explanation and/or URL for your answer. :)
My guess (yes Alex, it's a guess, or rather, a hunch) is that this is
related to two's complement binary numbers, but I haven't been able
to (yet) find any explanation for this.
--
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist
Other related posts:Limit or Bug? Re: Limit or Bug? Re: Limit or Bug? Re: Limit or Bug? Re: Limit or Bug?
|

|

|
[ Home |
Signup |
Help |
Login |
Archives |
Lists
]
All trademarks and copyrights within the FreeLists archives are owned
by their respective owners. Everything else ©2008 Avenir Technologies, LLC.
|

|
|