RSS Forums RSS

Subtracting a negative value

Please support our Oracle advertiser: Programming Forums
Reply
Posts: 36
Reputation: bondo is an unknown quantity at this point 
Solved Threads: 0
bondo's Avatar
bondo bondo is offline Offline
Light Poster

Subtracting a negative value

  #1  
Nov 13th, 2008
Does anyone know how Oracle's PL/SQL handles subtraction with a negative number? Really what I need to know is, given the following: (NOTE: this is NOT the code I'm working with. It's just an example to give and idea of what I'm trying to do.)
DECLARE
number1 NUMBER;
number2 NUMBER;
number3 NUMBER;
BEGIN
number1 := 5;
number2 := -2;
number3 := number1 - number2;
END;
/

How do I get number3 to be 7, like math is supposed to work (5 - (-2) = 7)? I keep getting 3. Anyone?
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,858
Reputation: debasisdas is on a distinguished road 
Solved Threads: 113
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Posting Virtuoso

Re: Subtracting a negative value

  #2  
Nov 13th, 2008
but i am getting 7, how come you are getting 3 ?

  1. DECLARE
  2. number1 NUMBER;
  3. number2 NUMBER;
  4. number3 NUMBER;
  5. BEGIN
  6. number1 := 5;
  7. number2 := -2;
  8. number3 := number1 - number2;
  9. dbms_output.put_line(number3);
  10. END;
  11.  
Share your Knowledge.
Reply With Quote  
Posts: 36
Reputation: bondo is an unknown quantity at this point 
Solved Threads: 0
bondo's Avatar
bondo bondo is offline Offline
Light Poster

Re: Subtracting a negative value

  #3  
Nov 13th, 2008
That was my question. Why am I getting 3?
Reply With Quote  
Posts: 1,858
Reputation: debasisdas is on a distinguished road 
Solved Threads: 113
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Posting Virtuoso

Re: Subtracting a negative value

  #4  
Nov 15th, 2008
the same block of pl/sql code never gives different output to different people on different machine.
Share your Knowledge.
Reply With Quote  
Posts: 9
Reputation: like_to_learn is an unknown quantity at this point 
Solved Threads: 0
like_to_learn's Avatar
like_to_learn like_to_learn is offline Offline
Newbie Poster

Re: Subtracting a negative value

  #5  
Dec 9th, 2008
Hai Bondo,
you will never get 3 for the above code..please check it once again...........................
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1215 | Replies: 4 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:07 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC