RE: Slightly OT: Rounding Negative Numbers
Why are you including -0.870?? In that case you should also include -.880. I think theoretically there is nothing right or wrong about rounding thing. You have to decide upon one way and follow that universally. Naveen -Original Message- Sent: Thursday, August 29, 2002 10:19 PM To: Multiple recipients of list ORACLE-L I have to jump in at this point since the arguments for rounding -0.875 to -0.87 just don't seem quite right (I guess I might be Gaussian about this thing). Let me use a different approach to this argument: Value Rounded -0.870 -0.87 -0.871 -0.87 -0.872 -0.87 -0.873 -0.87 -0.874 -0.87 -0.875 ? -0.876 -0.88 -0.877 -0.88 -0.878 -0.88 -0.879 -0.88 Let's look at the distribution. If -0.875 rounds to -0.87 then 60% of the values round to -0.87 and 40% round to -0.88. But, if -0.875 rounds to -0.88 then 50% of the values round each way. A 50/50 split is much more pleasing to my mind than a 60/40 split. In my opinion, the Java example gave the wrong answer. I have to wonder if the expression (a*100) got cast into an integer before being handed to the round class. The alternative of questioning the validity of the class is less appealing. Kevin Kennedy First Point Energy Corporation If you take RAC out of Oracle you get OLE! What can this mean? -Original Message- Sent: Thursday, August 29, 2002 7:18 AM To: Multiple recipients of list ORACLE-L After an intense ask-your-local-mathematician-session, here you go: It depends ;) (That's typical math-guys, isn't it ?). If you define round according to the Gauss function, then it should calculate it using absolute values, that would be -0.88. On the other hand, round is usually defined to go for the higher value from 5 on, so, since -0.87 is higher than -0.875, -0.87 would be correct. You actually don't know wether the function is implemented one or the other way. You can just try. And if you are not content with the results, you have to cook your own. Regards, Stefan Jahnke Consultant BOV Aktiengesellschaft Voice: +49 201 - 4513-298 Fax: +49 201 - 4513-149 mailto:[EMAIL PROTECTED] visit our website: http://www.bov.de subscribe to our newsletter: http://www.bov.de/presse/newsletter.asp Behalten Sie den Ueberblick - mit dem neuen BasicOverView, unserer Seminaruebersicht fuer das 2. Halbjahr 2002. Sie haben noch kein Exemplar? Schreiben Sie eine E-Mail an mailto:[EMAIL PROTECTED] oder rufen Sie uns an unter 0 18 03 / 73 64 62 73! Wie Sie wissen, koennen ueber das Internet versandte E-Mails leicht unter fremden Namen erstellt oder manipuliert werden. Aus diesem Grunde bitten wir um Verstaendnis dafuer, dass wir zu Ihrem und unserem Schutz die rechtliche Verbindlichkeit der vorstehenden Erklaerungen und Aeusserungen ausschliessen. As you are probably aware, e-mails sent via the Internet can easily be copied or manipulated by third parties. For this reason we would ask for your understanding that, for your own protection and ours, we must decline all legal responsibility for the validity of the statements and comments given above. -Ursprüngliche Nachricht- Von: Bill Buchan [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 29. August 2002 12:43 An: Multiple recipients of list ORACLE-L Betreff: Re: Slightly OT: Rounding Negative Numbers I know the rule round up, but does up mean the highest value (-0.87) or the highest absolute magnitude (-0.88)? :) - Bill. At 09:53 28/08/2002 -0800, you wrote: I would think -0.875 would round up therefore -0.87 is my guess. Rick -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stefan Jahnke INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: kkennedy INET: [EMAIL PROTECTED] Fat City Network Services
RE: Slightly OT: Rounding Negative Numbers
Hi if you include -0.870, you should also include -0.880 in which case the split will go 6:5 either way you choose. Jack kkennedy kkennedy@firstpoTo: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] int.com cc: (bcc: Jack van Zanen/nlzanen1/External/MEY/NL) Sent by: Subject: RE: Slightly OT: Rounding Negative Numbers [EMAIL PROTECTED] 29-08-2002 18:48 Please respond to ORACLE-L I have to jump in at this point since the arguments for rounding -0.875 to -0.87 just don't seem quite right (I guess I might be Gaussian about this thing). Let me use a different approach to this argument: Value Rounded -0.870 -0.87 -0.871 -0.87 -0.872 -0.87 -0.873 -0.87 -0.874 -0.87 -0.875 ? -0.876 -0.88 -0.877 -0.88 -0.878 -0.88 -0.879 -0.88 Let's look at the distribution. If -0.875 rounds to -0.87 then 60% of the values round to -0.87 and 40% round to -0.88. But, if -0.875 rounds to -0.88 then 50% of the values round each way. A 50/50 split is much more pleasing to my mind than a 60/40 split. In my opinion, the Java example gave the wrong answer. I have to wonder if the expression (a*100) got cast into an integer before being handed to the round class. The alternative of questioning the validity of the class is less appealing. Kevin Kennedy First Point Energy Corporation If you take RAC out of Oracle you get OLE! What can this mean? -Original Message- Sent: Thursday, August 29, 2002 7:18 AM To: Multiple recipients of list ORACLE-L After an intense ask-your-local-mathematician-session, here you go: It depends ;) (That's typical math-guys, isn't it ?). If you define round according to the Gauss function, then it should calculate it using absolute values, that would be -0.88. On the other hand, round is usually defined to go for the higher value from 5 on, so, since -0.87 is higher than -0.875, -0.87 would be correct. You actually don't know wether the function is implemented one or the other way. You can just try. And if you are not content with the results, you have to cook your own. Regards, Stefan Jahnke Consultant BOV Aktiengesellschaft Voice: +49 201 - 4513-298 Fax: +49 201 - 4513-149 mailto:[EMAIL PROTECTED] visit our website: http://www.bov.de subscribe to our newsletter: http://www.bov.de/presse/newsletter.asp Behalten Sie den Ueberblick - mit dem neuen BasicOverView, unserer Seminaruebersicht fuer das 2. Halbjahr 2002. Sie haben noch kein Exemplar? Schreiben Sie eine E-Mail an mailto:[EMAIL PROTECTED] oder rufen Sie uns an unter 0 18 03 / 73 64 62 73! Wie Sie wissen, koennen ueber das Internet versandte E-Mails leicht unter fremden Namen erstellt oder manipuliert werden. Aus diesem Grunde bitten wir um Verstaendnis dafuer, dass wir zu Ihrem und unserem Schutz die rechtliche Verbindlichkeit der vorstehenden Erklaerungen und Aeusserungen ausschliessen. As you are probably aware, e-mails sent via the Internet can easily be copied or manipulated by third parties. For this reason we would ask for your understanding that, for your own protection and ours, we must decline all legal responsibility for the validity of the statements and comments given above. -Ursprüngliche Nachricht- Von: Bill Buchan [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 29. August 2002 12:43 An: Multiple recipients of list ORACLE-L Betreff: Re: Slightly OT: Rounding Negative Numbers I know the rule round up, but does up mean the highest value (-0.87) or the highest absolute magnitude (-0.88
RE: Slightly OT: Rounding Negative Numbers
Aren't you looking at only half the picture? -0.875 in Oracle is rounded down to -0.88. +0.875 is rounded up to +0.88. I don't think of changing 0.870 to 0.87 as rounding. It is expressing the +exact same value using only the significant digits. Ian MacGregor Stanford Linear Accelerator Center [EMAIL PROTECTED] -Original Message- From: kkennedy [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 29, 2002 9:49 AM To: Multiple recipients of list ORACLE-L I have to jump in at this point since the arguments for rounding -0.875 to -0.87 just don't seem quite right (I guess I might be Gaussian about this thing). Let me use a different approach to this argument: Value Rounded -0.870 -0.87 -0.871 -0.87 -0.872 -0.87 -0.873 -0.87 -0.874 -0.87 -0.875 ? -0.876 -0.88 -0.877 -0.88 -0.878 -0.88 -0.879 -0.88 Let's look at the distribution. If -0.875 rounds to -0.87 then 60% of the values round to -0.87 and 40% round to -0.88. But, if -0.875 rounds to -0.88 then 50% of the values round each way. A 50/50 split is much more pleasing to my mind than a 60/40 split. In my opinion, the Java example gave the wrong answer. I have to wonder if the expression (a*100) got cast into an integer before being handed to the round class. The alternative of questioning the validity of the class is less appealing. Kevin Kennedy First Point Energy Corporation If you take RAC out of Oracle you get OLE! What can this mean? -Original Message- Sent: Thursday, August 29, 2002 7:18 AM To: Multiple recipients of list ORACLE-L After an intense ask-your-local-mathematician-session, here you go: It depends ;) (That's typical math-guys, isn't it ?). If you define round according to the Gauss function, then it should calculate it using absolute values, that would be -0.88. On the other hand, round is usually defined to go for the higher value from 5 on, so, since -0.87 is higher than -0.875, -0.87 would be correct. You actually don't know wether the function is implemented one or the other way. You can just try. And if you are not content with the results, you have to cook your own. Regards, Stefan Jahnke Consultant BOV Aktiengesellschaft Voice: +49 201 - 4513-298 Fax: +49 201 - 4513-149 mailto:[EMAIL PROTECTED] visit our website: http://www.bov.de subscribe to our newsletter: http://www.bov.de/presse/newsletter.asp Behalten Sie den Ueberblick - mit dem neuen BasicOverView, unserer Seminaruebersicht fuer das 2. Halbjahr 2002. Sie haben noch kein Exemplar? Schreiben Sie eine E-Mail an mailto:[EMAIL PROTECTED] oder rufen Sie uns an unter 0 18 03 / 73 64 62 73! Wie Sie wissen, koennen ueber das Internet versandte E-Mails leicht unter fremden Namen erstellt oder manipuliert werden. Aus diesem Grunde bitten wir um Verstaendnis dafuer, dass wir zu Ihrem und unserem Schutz die rechtliche Verbindlichkeit der vorstehenden Erklaerungen und Aeusserungen ausschliessen. As you are probably aware, e-mails sent via the Internet can easily be copied or manipulated by third parties. For this reason we would ask for your understanding that, for your own protection and ours, we must decline all legal responsibility for the validity of the statements and comments given above. -Ursprüngliche Nachricht- Von: Bill Buchan [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 29. August 2002 12:43 An: Multiple recipients of list ORACLE-L Betreff: Re: Slightly OT: Rounding Negative Numbers I know the rule round up, but does up mean the highest value (-0.87) or the highest absolute magnitude (-0.88)? :) - Bill. At 09:53 28/08/2002 -0800, you wrote: I would think -0.875 would round up therefore -0.87 is my guess. Rick -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stefan Jahnke INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing
Re: Slightly OT: Rounding Negative Numbers
I know the rule round up, but does up mean the highest value (-0.87) or the highest absolute magnitude (-0.88)? :) - Bill. At 09:53 28/08/2002 -0800, you wrote: I would think -0.875 would round up therefore -0.87 is my guess. Rick -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: Slightly OT: Rounding Negative Numbers
I have to jump in at this point since the arguments for rounding -0.875 to -0.87 just don't seem quite right (I guess I might be Gaussian about this thing). Let me use a different approach to this argument: Value Rounded -0.870 -0.87 -0.871 -0.87 -0.872 -0.87 -0.873 -0.87 -0.874 -0.87 -0.875 ? -0.876 -0.88 -0.877 -0.88 -0.878 -0.88 -0.879 -0.88 Let's look at the distribution. If -0.875 rounds to -0.87 then 60% of the values round to -0.87 and 40% round to -0.88. But, if -0.875 rounds to -0.88 then 50% of the values round each way. A 50/50 split is much more pleasing to my mind than a 60/40 split. In my opinion, the Java example gave the wrong answer. I have to wonder if the expression (a*100) got cast into an integer before being handed to the round class. The alternative of questioning the validity of the class is less appealing. Kevin Kennedy First Point Energy Corporation If you take RAC out of Oracle you get OLE! What can this mean? -Original Message- Sent: Thursday, August 29, 2002 7:18 AM To: Multiple recipients of list ORACLE-L After an intense ask-your-local-mathematician-session, here you go: It depends ;) (That's typical math-guys, isn't it ?). If you define round according to the Gauss function, then it should calculate it using absolute values, that would be -0.88. On the other hand, round is usually defined to go for the higher value from 5 on, so, since -0.87 is higher than -0.875, -0.87 would be correct. You actually don't know wether the function is implemented one or the other way. You can just try. And if you are not content with the results, you have to cook your own. Regards, Stefan Jahnke Consultant BOV Aktiengesellschaft Voice: +49 201 - 4513-298 Fax: +49 201 - 4513-149 mailto:[EMAIL PROTECTED] visit our website: http://www.bov.de subscribe to our newsletter: http://www.bov.de/presse/newsletter.asp Behalten Sie den Ueberblick - mit dem neuen BasicOverView, unserer Seminaruebersicht fuer das 2. Halbjahr 2002. Sie haben noch kein Exemplar? Schreiben Sie eine E-Mail an mailto:[EMAIL PROTECTED] oder rufen Sie uns an unter 0 18 03 / 73 64 62 73! Wie Sie wissen, koennen ueber das Internet versandte E-Mails leicht unter fremden Namen erstellt oder manipuliert werden. Aus diesem Grunde bitten wir um Verstaendnis dafuer, dass wir zu Ihrem und unserem Schutz die rechtliche Verbindlichkeit der vorstehenden Erklaerungen und Aeusserungen ausschliessen. As you are probably aware, e-mails sent via the Internet can easily be copied or manipulated by third parties. For this reason we would ask for your understanding that, for your own protection and ours, we must decline all legal responsibility for the validity of the statements and comments given above. -Ursprüngliche Nachricht- Von: Bill Buchan [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 29. August 2002 12:43 An: Multiple recipients of list ORACLE-L Betreff: Re: Slightly OT: Rounding Negative Numbers I know the rule round up, but does up mean the highest value (-0.87) or the highest absolute magnitude (-0.88)? :) - Bill. At 09:53 28/08/2002 -0800, you wrote: I would think -0.875 would round up therefore -0.87 is my guess. Rick -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stefan Jahnke INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: kkennedy INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY
Re: Slightly OT: Rounding Negative Numbers
I would think -0.875 would round up therefore -0.87 is my guess. Rick Bill Buchan [EMAIL PROTECTED] To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] tasys.com cc: Sent by: Subject: Slightly OT: Rounding Negative Numbers [EMAIL PROTECTED] om 08/28/2002 11:58 AM Please respond to ORACLE-L I'm trying to consolidate some numbers generated by a PL/SQL report vs. a Java based report and these seem to be out due to rounding errors on negative numbers. In PL/SQL if I for example, round to 2 decimal places: SQL select round(-0.875,2) from dual; ROUND(-0.875,2) --- -.88 In Java: import java.*; public class Round { public static void main(String[] args) { double a = -0.875; int i = (int)java.lang.Math.round(a*100); double z = i; z = z / 100; System.out.println(z); } } java Round -0.87 which is 0.01 different (1 pence in this case). If I use positive numbers (+0.875) when the answer is 0.88 for both PL/SQL and Java. PL/SQL's answer looks morecorrect to me for the negative value - but what is the mathematically correct rounding of -0.875?! Thanks! - Bill. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: Slightly OT: Rounding Negative Numbers
Bill, I haven't tried it with negative numbers but I found round to create error where commission dollars are concerned. I use the trunc function to give the results in two decimal places where the extra half cent makes a difference over the period of time. total = trunc(sum * %,2) Select trunc(-.872,2) from dual; 87 Ron ROR mª¿ªm [EMAIL PROTECTED] 08/28/02 11:58AM I'm trying to consolidate some numbers generated by a PL/SQL report vs. a Java based report and these seem to be out due to rounding errors on negative numbers. In PL/SQL if I for example, round to 2 decimal places: SQL select round(-0.875,2) from dual; ROUND(-0.875,2) --- -.88 In Java: import java.*; public class Round { public static void main(String[] args) { double a = -0.875; int i = (int)java.lang.Math.round(a*100); double z = i; z = z / 100; System.out.println(z); } } java Round -0.87 which is 0.01 different (1 pence in this case). If I use positive numbers (+0.875) when the answer is 0.88 for both PL/SQL and Java. PL/SQL's answer looks morecorrect to me for the negative value - but what is the mathematically correct rounding of -0.875?! Thanks! - Bill. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Ron Rogers INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: Slightly OT: Rounding Negative Numbers
My guess would be that neither is wrong, but just using different rounding methods. If you are concerned about both returning different results, you could add (or subtract, based on sign) .0001 before doing the ROUND. SELECT ROUND(mynum + SIGN(mynum)*0.0001) FROM DUAL; Of course, this may not work %100 if you store more than three decimal places, e.g. -.8749. Just a thought. HTH! GL! :) Rich Jesse System/Database Administrator [EMAIL PROTECTED] Quad/Tech International, Sussex, WI USA -Original Message- From: Bill Buchan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 28, 2002 10:59 AM To: Multiple recipients of list ORACLE-L Subject: Slightly OT: Rounding Negative Numbers I'm trying to consolidate some numbers generated by a PL/SQL report vs. a Java based report and these seem to be out due to rounding errors on negative numbers. In PL/SQL if I for example, round to 2 decimal places: SQL select round(-0.875,2) from dual; ROUND(-0.875,2) --- -.88 In Java: import java.*; public class Round { public static void main(String[] args) { double a = -0.875; int i = (int)java.lang.Math.round(a*100); double z = i; z = z / 100; System.out.println(z); } } java Round -0.87 which is 0.01 different (1 pence in this case). If I use positive numbers (+0.875) when the answer is 0.88 for both PL/SQL and Java. PL/SQL's answer looks morecorrect to me for the negative value - but what is the mathematically correct rounding of -0.875?! Thanks! - Bill. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jesse, Rich INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: Slightly OT: Rounding Negative Numbers
The way Java calculates round is (int)Math.floor(a + 0.5f) So you could enforce your rounding algorithm this way: import java.*; public class Round { public static void main(String[] args) { double a = 0.875; int i_rounded; if (a = 0) i_rounded = (int)java.lang.Math.round(a*100); elsei_rounded = (int)java.lang.Math.floor(a*100 - 0.5); double z = i_rounded; z = z / 100; System.out.println(z); } } Regards, Waleed -Original Message- Sent: Wednesday, August 28, 2002 11:59 AM To: Multiple recipients of list ORACLE-L I'm trying to consolidate some numbers generated by a PL/SQL report vs. a Java based report and these seem to be out due to rounding errors on negative numbers. In PL/SQL if I for example, round to 2 decimal places: SQL select round(-0.875,2) from dual; ROUND(-0.875,2) --- -.88 In Java: import java.*; public class Round { public static void main(String[] args) { double a = -0.875; int i = (int)java.lang.Math.round(a*100); double z = i; z = z / 100; System.out.println(z); } } java Round -0.87 which is 0.01 different (1 pence in this case). If I use positive numbers (+0.875) when the answer is 0.88 for both PL/SQL and Java. PL/SQL's answer looks morecorrect to me for the negative value - but what is the mathematically correct rounding of -0.875?! Thanks! - Bill. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Bill Buchan INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Khedr, Waleed INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).