Subtracting a negative value

Reply

Join Date: Apr 2007
Posts: 37
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

 
0
  #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.)
  1. DECLARE
  2. number1 NUMBER;
  3. number2 NUMBER;
  4. number3 NUMBER;
  5. BEGIN
  6. number1 := 5;
  7. number2 := -2;
  8. number3 := number1 - number2;
  9. END;
  10. /

How do I get number3 to be 7, like math is supposed to work (5 - (-2) = 7)? I keep getting 3. Anyone?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,068
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 123
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Subtracting a negative value

 
0
  #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;
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 37
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

 
0
  #3
Nov 13th, 2008
That was my question. Why am I getting 3?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,068
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 123
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Subtracting a negative value

 
0
  #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 Quick reply to this message  
Join Date: Dec 2008
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

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

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC