The value is 2.986232. I need it to display as 2.98 2.99 seems to be all I can get because I don't know how to suppress the rounding.
I've tried converting to alpha but still can't get it.
Any help would be greatly appreciated.
SteveThis message has been edited. Last edited by: Kerry,
Dev Studio /7.6.11/7.7.02M MVS/USS AIX/SOLARIS Windows WF Client 7.6.8/7.6.11
March 05, 2009, 02:23 PM
j.gross
Use INT to truncate:
DEFINE FILE CAR
TGPA_GPA/D20.2=2.986232;
TGPA_GPA2/D12.2=INT(TGPA_GPA*100)/100;
END
TABLE FILE CAR
PRINT TGPA_GPA TGPA_GPA2
BY COUNTRY
END
March 05, 2009, 02:31 PM
Darin Lee
I was just about to post when my browser refreshed and I saw the EXACT code I was posting in j.gross's post. So I won't repeat. Any format/precision conversion you do is going to automatically round and I don't think there is any way around it except truncating the number as suggested.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
March 05, 2009, 03:33 PM
FrankDutch
An other solution could be
DEFINE FILE CAR
TGPA_GPA/D20.2=2.986232;
TGPA_GPA2/D12.2=TGPA_GPA-0.00499;
END
TABLE FILE CAR
PRINT TGPA_GPA
TGPA_GPA2
BY COUNTRY
END
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
March 05, 2009, 05:01 PM
FrankDutch
Tom
2.983232 minus 0.004999 is 2.978233 presented as D12.2 is 2.98....
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
March 05, 2009, 06:02 PM
susannah
I use Frank's way .. works just dandy for me. Citibank keeps all the extra mils that way.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
March 11, 2009, 10:23 AM
SRC
Thanks to all who replied. True, 2.985232 will properly round to 2.99 but my customer specifically requested two decimal places and no rounding. So, both J.Gross and FrankDutch provided simple one-line working solutions. I actually came up with some code that worked but I'd be embarrassed to post it here! Of course I've only been writing FOCUS at the code level for twenty years so I'm a little new at this. Thanks again.
Steve
Dev Studio /7.6.11/7.7.02M MVS/USS AIX/SOLARIS Windows WF Client 7.6.8/7.6.11
March 12, 2009, 12:01 PM
ira
Steve, as Susannah said, I would so use Frank's method - that has worked well for me over the years, but if you want 2 decimal places and no rounding here goes:
quote:
DEFINE FILE CAR ORIG_VALUE/D20.2=2.986232; FLD0/D20.2 = ORIG_VALUE * 100 ; IVAL/I4 = IMOD(FLD0, 1000, IVAL); AVAL/A6=EDIT(IVAL,'$9.99'); DVAL/D20.2=ATODBL(AVAL, '6', DVAL); END
TABLE FILE CAR PRINT ORIG_VALUE FLD0 IVAL AVAL DVAL BY COUNTRY END -EXIT
This message has been edited. Last edited by: ira,