Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] How to make digit "5" to always be round up?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] How to make digit "5" to always be round up?
 Login/Join
 
Gold member
posted
Why when first digit to be dropped is 5, it sometimes get round up and somtimes get round down?

I read data from DB2 table, there 'Rate_A','Rate_B', 'Rate_C' defined as S9(1)V9(4) comp-3, which is one digit at left of the decimal point, 4 digits at right, and it is packed decimal.

First I read it from DB2 table, hold it as a hold file, define a new percentage field in the hold file by multiple it with 100. As:

DEFINE FILE DB2HOLD
Rate_A_Pecent/P7.4 = Rate_A * 100;
Rate_B_Pecent/P7.4 = Rate_B * 100;
Rate_C_Pecent/P7.4 = Rate_C * 100;

Then when I display, I only want to display one digit after decimal:

PRINT
Rate_A_Pecent/P7.1 AS "Rate_A %"
Rate_B_Pecent/P7.1 AS "Rate_B %"
Rate_C_Pecent/P7.1 AS "Rate_C %"

But the result, is not conistent, we found when the 2nd digit to be dropped is 5, it sometimes get round up and somtimes get round down. Any idea of why? or how to make it consistent? thanks,

This message has been edited. Last edited by: Kerry,


WebFOCUS 8.2.01 AppStudio
HTML, PDF, Excel
 
Posts: 61 | Registered: March 12, 2008Report This Post
Gold member
posted Hide Post
I also came across this same issue this week in 7.7.02 when I was using a compute.

Instead of assigning the value to P7.2, try using D7.2 instead. Worked in my situation at least.



Windows: WF 7.6.2: SQL Server 2008 R2
 
Posts: 86 | Location: Chicago | Registered: August 03, 2007Report This Post
Expert
posted Hide Post
PLease list your actual / raw data for these values for better analysis on our part...
Thanks, Doug
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
The original value in DB2 table are :

Rate_A: 0.5175
Rate_B: 0.5035
Rate_C: 0.4685

After multiple with 100 in DEFINE FILE and PRINT with 1 decimal:
'Rate_A %' = 51.8
'Rate_B %' = 50.3
'Rate_C %' = 46.8

I have also tried with D7.4, D7.1, but the result has no difference.
thanks.
Emily - 7.6.11 mainframe


WebFOCUS 8.2.01 AppStudio
HTML, PDF, Excel
 
Posts: 61 | Registered: March 12, 2008Report This Post
Virtuoso
posted Hide Post
Can you also please display the ACTUAL and USAGE definition for those fields in the master file?

Please make sure to enclose that content in [ CODE ] tags for ease of reading. (See the </> button in the message's toolbar).



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Gold member
posted Hide Post
An old trick would be to add a small number to the RATE fields:

  
DEFINE FILE CAR
RATE_A/D7.4 = (0.5175 + .00001) * 100;
RATE_B/D7.4 = (0.5035 + .00001) * 100;
RATE_C/D7.4 = (0.4685 + .00001) * 100;
END
TABLE FILE CAR
PRINT
RATE_A/D7.1
RATE_B/D7.1
RATE_C/D7.1
DEALER_COST
BY COUNTRY
BY CAR
END



This worked in my test.


WF 7.6.10, Windows, PDF, Excel
 
Posts: 75 | Location: Dallas, TX | Registered: February 12, 2004Report This Post
Master
posted Hide Post
You could finesse Mary's technique by adding an IF statement to the effect that if the last digit is a 5 then increment the previous digit by 1.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Master
posted Hide Post
Why this is happening? Here is the answer.

The decimal portion of a floating-point value as it is internally represented in
hexadecimal floating-point notation is repeating (that is, non-terminating), the repeating
hexadecimal number is resolved as a non-repeating slightly lower number, and this lower
number is stored as the field value.

While the original number, 1.15, would have been rounded upward to 1.2 (since the first
extra digit was 5 or greater), the number as stored is slightly less than 1.15 (1.149999)
and, as the first extra digit is now less than 5 (4 in this case), it is rounded down to 1.1.

Refer to "Describing Data With
WebFOCUS Language" --> Chapter - 4 Describing Individual Filed --> USAGE --> Rounding

Hope this helps.

Thanks,
Ram
 
Posts: 542 | Location: Dearborn, MI | Registered: June 03, 2009Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] How to make digit "5" to always be round up?

Copyright © 1996-2020 Information Builders