Few more interesting results: SQL> select 125 + level sno, 2 power(2, 125 + level) pow, 3 (power(2, 125 + level)-1) "pow-1", 4 mod( power(2, 125 + level)-1, 2) "mod" 5 from dual 6 connect BY level <= 25; SNO POW pow-1 mod ---------- ---------- ---------- ---------- 126 8.5071E+37 8.5071E+37 1 127 1.7014E+38 1.7014E+38 1 128 3.4028E+38 3.4028E+38 -1 129 6.8056E+38 6.8056E+38 -1 130 1.3611E+39 1.3611E+39 -1 131 2.7223E+39 2.7223E+39 -1 132 5.4445E+39 5.4445E+39 -1 133 1.0889E+40 1.0889E+40 0 134 2.1778E+40 2.1778E+40 0 135 4.3556E+40 4.3556E+40 0 136 8.7112E+40 8.7112E+40 -100 137 1.7422E+41 1.7422E+41 -100 138 3.4845E+41 3.4845E+41 -100 139 6.9690E+41 6.9690E+41 -100 140 1.3938E+42 1.3938E+42 0 141 2.7876E+42 2.7876E+42 -10000 142 5.5752E+42 5.5752E+42 0 143 1.1150E+43 1.1150E+43 -10000 144 2.2301E+43 2.2301E+43 0 145 4.4601E+43 4.4601E+43 0 146 8.9203E+43 8.9203E+43 0 147 1.7841E+44 1.7841E+44 0 148 3.5681E+44 3.5681E+44 0 149 7.1362E+44 7.1362E+44 -1000000 150 1.4272E+45 1.4272E+45 -1000000 25 rows selected. Regards Asif Momen http://momendba.blogspot.com --- On Thu, 7/3/08, Charles Schultz <sacrophyte@xxxxxxxxx> wrote: From: Charles Schultz <sacrophyte@xxxxxxxxx> Subject: Re: Limit or Bug? To: jkstill@xxxxxxxxx Cc: "Oracle-L Freelists" <oracle-l@xxxxxxxxxxxxx> Date: Thursday, July 3, 2008, 2:19 PM Interesting indeed: SQL > select mod(3.4028E+38,2) from dual; MOD(3.4028E+38,2) ----------------- 0 SQL > select mod(3.4028E+38 + 1,2) from dual; MOD(3.4028E+38+1,2) ------------------- -1 On Thu, Jul 3, 2008 at 3:44 PM, Jared Still <jkstill@xxxxxxxxx> wrote: 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 -- Charles Schultz