Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How To Do Calculations On Large Numbers In Oracle?

681369Dec 29 2010 — edited Dec 31 2010
Hi Experts,

I was asked to prove that 2222^5555 + 5555^2222 is divisible by 7 (^ denotes 'to the power of').

I was trying to do the same in Oracle SQL/PL-SQL, but I was getting the error "ORA-01426 Numeric Overflow".

Here's my code:

/*=====================================================*/
DECLARE
--
l_num25 binary_double;
l_num52 binary_double;
l_num binary_double;
--
BEGIN
--
SELECT to_binary_double(POWER(2222,5555)) INTO l_num25 FROM dual;
SELECT to_binary_double(POWER(5555,2222)) INTO l_num52 FROM dual;
l_num := MOD((l_num25 + l_num52), 7);
--
dbms_output.put_line(TO_CHAR(l_num));
--
EXCEPTION
--
WHEN OTHERS THEN
raise_application_error(-20000, SUBSTR((SQLERRM
|| '----------'
|| dbms_utility.format_error_backtrace), 1, 400));
--
END;
--[ORA-01426 :: Numeric Overflow]
/*=====================================================*/

Can you guys show me how to do this in SQL or PL/SQL?

TIA,
Hex.
This post has been answered by Solomon Yakobson on Dec 29 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2011
Added on Dec 29 2010
5 comments
1,285 views