Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

decimal places
Hi:
I am trying to let a customer input the number of decimal points to
round to.
How can I code this in working storage so I can calc a subscript based
on input from the customer. I would like to avoid creating 7 different
paragraphs for each option if possible.  I have created a sample program
to test this below, and I just chose to use a sub of 4.  Ref-field turns
up with no decimals.  Anyone have any suggestions on how I can pull
this off.   MicroFocus Netexpress 3.1.

IDENTIFICATION DIVISION.
PROGRAM-ID. testperf.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.

WORKING-STORAGE SECTION.
01  test-fields.
05  filler                 pic s9(12)v99.
05  T2                  pic s9(11)v999.
05  T3                  pic s9(10)v9999.
05  T4                  pic s9(09)v99999.
05  T5                  pic s9(08)v999999.
05  T6                  pic s9(07)v9999999.
05  T7                  pic s9(06)v99999999.
01 tf redefines test-fields.
05  ref-field           pic 9(14) occurs 7 times.
*
*
01  test-out   pic s9(6)v99.
*--------------------------------------
01  Field1      pic 9(5)v9(10) value zero.
01  Field2      pic 9(5)v9(5) value 123.45600.
01  field3      pic 9(5)v9(3) value 435.553.

PROCEDURE DIVISION.
testperform-begin.
compute ref-field (4)  rounded =
field2 * Field3.

Move zeros to test-out.
*  compute test-out = test-out +  tf(4).
P1101-END.
STOP RUN.


Report this thread to moderator Post Follow-up to this message
Old Post
Jerry Huff
05-12-04 11:47 PM


Re: decimal places
The easy way involves the use of a scale factor instead of 7 work fields.

> In article <Xw3nc.9299$2f6.376381@twister.tampabay.rr.com>,
>  Jerry Huff <jhuff@terrasoftsystems.com> wrote:
> 

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Zitzelberger
05-12-04 11:47 PM


Re: decimal places
Jerry Huff wrote:

> Hi:
> I am trying to let a customer input the number of decimal points to
> round to.
> How can I code this in working storage so I can calc a subscript based
> on input from the customer. I would like to avoid creating 7 different
> paragraphs for each option if possible.  I have created a sample
> program to test this below, and I just chose to use a sub of 4.
> Ref-field turns  up with no decimals.  Anyone have any suggestions on
> how I can pull this off.   MicroFocus Netexpress 3.1.
>
>        IDENTIFICATION DIVISION.
>        PROGRAM-ID. testperf.
>        ENVIRONMENT DIVISION.
>        CONFIGURATION SECTION.
>        INPUT-OUTPUT SECTION.
>        FILE-CONTROL.
>        DATA DIVISION.
>        FILE SECTION.
>
>        WORKING-STORAGE SECTION.
>        01  test-fields.
>          05  filler                 pic s9(12)v99.
>          05  T2                  pic s9(11)v999.
>          05  T3                  pic s9(10)v9999.
>          05  T4                  pic s9(09)v99999.
>          05  T5                  pic s9(08)v999999.
>          05  T6                  pic s9(07)v9999999.
>          05  T7                  pic s9(06)v99999999.
>        01 tf redefines test-fields.
>          05  ref-field           pic 9(14) occurs 7 times.
>       *
>       *
>        01  test-out   pic s9(6)v99.
>       *--------------------------------------
>        01  Field1      pic 9(5)v9(10) value zero.
>        01  Field2      pic 9(5)v9(5) value 123.45600.
>        01  field3      pic 9(5)v9(3) value 435.553.
>
>        PROCEDURE DIVISION.
>        testperform-begin.
>          compute ref-field (4)  rounded =
>            field2 * Field3.
>
>         Move zeros to test-out.
>       *  compute test-out = test-out +  tf(4).
>        P1101-END.
>            STOP RUN.
>
First, which one of the following are you using :-

1) Screen Section
2) Dialog Editor and GUI classes
3) Dialog System

Now would you care to expand on your statement, " I am trying to let a
customer input the number of decimal points to round to.". Is this :-

- on the fly,
- do you have a Condition (Level 88) set as to what is currently
acceptable as the input length, or,
-  are there specific lengths to specific input fields, (per
Screen/Dialog) or,
-  does the user set a Default length before application start-up  or,
- etc......... ?

Knowing what the 'design intent'  is will make it easier to suggest an
answer rather than follow up on your code above, which  doesn't indicate
how the input is triggered.

Jimmy, Calgary AB

Report this thread to moderator Post Follow-up to this message
Old Post
James J. Gavan
05-12-04 11:47 PM


Re: decimal places
On  8-May-2004, Jerry Huff <jhuff@terrasoftsystems.com> wrote:

> Hi:
> I am trying to let a customer input the number of decimal points to
> round to.

I would consider rounding by hand.

COMPUTE MY-RESULT = MY-RESULT + 5 / 10 ** DIGITS

Then move the string using reference modification to another alpha string.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
05-12-04 11:47 PM


Re: decimal places
"Howard Brazee" <howard@brazee.net> wrote:

>On  8-May-2004, Jerry Huff <jhuff@terrasoftsystems.com> wrote:
> 
>
>I would consider rounding by hand.
>
>COMPUTE MY-RESULT = MY-RESULT + 5 / 10 ** DIGITS
>
>Then move the string using reference modification to another alpha string.

Close. It should be .5 rather than 5, and doesn't work for negative numbers.

05  edited-number     pic  z(9).9(6).
05  edited-number-variable-length redefines edited-number.
10                      pic  x(10).
10    occurs 1 to 6 depending on digits pic x.


compute edited-number =
my-result + (function sign (my-result) * .5 / (10 ** digits))
move edited-number-variable-length to ...


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Wagner
05-12-04 11:47 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:59 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.