This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 6, 2011, 5:53 AM
18 Posts

@Round Error in Xpages

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role:
  • Tags:
  • Replies: 3
Try this litte Page, it rounds two numbers, the result looks like this: 
 
Wrong: 81.56700000000001
Right: 81.123
 
 <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"><xp:text escape="true" id="computedField1"><xp:this.value><![CDATA[#{javascript:return "Wrong: "+@Round(81.5666527356817,0.001).toString();}]]></xp:this.value></xp:text>

<xp:br></xp:br><xp:text escape="true" id="computedField2"><xp:this.value><![CDATA[#{javascript:return "Right: "+@Round(81.1234567890123,0.001).toString();}]]></xp:this.value></xp:text></xp:view>
 
I used 8.5.2 FP2 on Win64, is this a bug or a feature? 
 
Greetings Michael 
May 6, 2011, 5:55 AM
29 Posts
Re: @Round Error in Xpages
 if you're worried about the end result, I'd suggest using Number.toPrecision() after @Round. it definitely gets you the correct result
May 6, 2011, 6:34 AM
18 Posts
Re: @Round Error in Xpages
 Ruslan,
 
thx for you answer, it works fine with toPrecision, but maybe @Round should get fixed in notes? 
 
Greetings Michael 
May 6, 2011, 7:18 AM
29 Posts
Re: @Round Error in Xpages
 yeah, it probably should, though my knowledge is not so deep as to deduct the real reasons of the issue you've described. 
I am working on databases which are being used in different platforms (Win and MacOS) and sometimes I come across similar issues - functions do not work the way the are intended to (at least as described in manuals) on one platform, but they perform perfectly on another.

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal