Return-Path: Delivered-To: apmail-xml-general-archive@xml.apache.org Received: (qmail 72492 invoked by uid 500); 9 Apr 2001 15:41:24 -0000 Mailing-List: contact general-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: general@xml.apache.org Delivered-To: mailing list general@xml.apache.org Received: (qmail 72479 invoked from network); 9 Apr 2001 15:41:23 -0000 Message-ID: <295199A7B119D31197F80008C7731C9DB8BDD9@exchange.crebit.ee> From: "Maksim Sakki" To: "'general@xml.apache.org'" Subject: RE: Strange XSLT behaviour Date: Mon, 9 Apr 2001 17:42:08 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Hi, The given behaviour is exactly what you get when writing "format-number(9.5,'00')". If you want to format numbers keeping 2 decimal places, you should write "format-number(9.5,'0.00')". Maksim Sakki -----Original Message----- From: Samson, Lyndon [IT] [mailto:lyndon.samson@ssmb.com] Sent: 09. aprill 2001. a. 17:34 To: general@xml.apache.org Subject: Strange XSLT behaviour Using xalan-j_2_0_0 I've noticed some funny behaviour in xalan. When given this; + + + It returns something like this; 10 + 10 + 12 + 12 That is all the odd numbers are rounded up and even numbers are rounded down. The W3c spec refers to the java.text.DecimalFormat class This test code; public void pNum(double num) { java.text.FieldPosition fp = new java.text.FieldPosition(java.text.NumberFormat.FRACTION_FIELD); StringBuffer sb = new StringBuffer(); java.text.DecimalFormat df = new java.text.DecimalFormat("00"); sb = df.format(num, sb, fp); System.out.println("SB:"+sb.toString()); } pNum(9.5); pNum(10.5); pNum(11.5); pNum(12.5); produces; SB:10 SB:10 SB:12 SB:12 The same situation! The only question is this a bug or a feature? Maybe my mathematical memory is faulty and this is the standard way of rounding to integers? --------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: general-unsubscribe@xml.apache.org For additional commands, e-mail: general-help@xml.apache.org --------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: general-unsubscribe@xml.apache.org For additional commands, e-mail: general-help@xml.apache.org