As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
In FOCUS for VMS, I have two P15.4 fields that need to be compared to see if they are equal. What's the best way to round them up to 2 decimal places for this comparison?
For example, if FIELD_A = 200.2149 and FIELD_B = 200.2200, then after the rounding they should be considered equal with both fields having the value of 200.22.
Thank you,
JohnThis message has been edited. Last edited by: JohnB,
WF 7.7.03, Windows 7, HTML, Excel, PDF
Posts: 225 | Location: San Francisco Bay Area, California | Registered: October 26, 2006
I think the best and most certain way to do this is to: 1. add a small number to the field(s), to be sure it rounds to the right number. 2. convert the field(s) to alpha, using FTOA and the format of '(D15.2)'. 3. do the equality check on these converted alpha field(s).
Hope this helps....
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
(Dane's post) Those two tech memos are specifically labeled Focus for Mainframe, and dated 1990, so I'd be wary of relying on them for other platforms.
(GamP's) Even if, on a given platform, a calculated P field were held in memory and stored as D without rounding, the formatting of D fields for display (whether in a report or invoked by FTOA) rounds the value. Adding an epsilon is unnecessary, and could only bring harm. I'd recommend just your steps 2 and 3 to compare rounded character representations (or an eqivalent cast to an I field after scaling and rounding)
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
Rounding in Packed Decimal Format: Format P In packed-decimal format (format type P), each byte contains two digits, except the last byte, which contains a digit and the sign (D for negative numbers, C for positive). Packed fields are comparable to COBOL COMP-3.
Packed field values are rounded to the number of digits specified in the field format before they are stored.
When the number of decimal places input is greater than the number that can be stored, P field values are rounded first, then stored or displayed.
Packed fields are precisely accurate when sufficient decimal places are available to store values. Otherwise, since values are rounded before being stored, accuracy cannot be improved by increasing the number of digits displayed. For example, if 123.78 is input to a packed field with 1 decimal place, 123.8 is stored. If the field's format is then changed to P6.2 using a COMPUTE or DEFINE, 123.80 will be displayed. If the field's format is changed to P6.2 in the Master File, 12.38 is displayed.
For example, if FIELD_A = 200.2149 and FIELD_B = 200.2200, then after the rounding they should be considered equal with both fields having the value of 200.22.
Field_A/P15.2 rounded will equal 200.21, not 200.22. Packed fields round correctly.
Could this conversion from decimal to packed cause any inaccuracies that would affect the rounding?This message has been edited. Last edited by: JohnB,
WF 7.7.03, Windows 7, HTML, Excel, PDF
Posts: 225 | Location: San Francisco Bay Area, California | Registered: October 26, 2006