MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Float Decimal data type

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Jan 30, 2008 2:19 am    Post subject: Float Decimal data type Reply with quote

Hai,

Can we have a float decimal data type to be written to an output file in record I/O, if so how many bytes of storage it takes for this variable?

DECIMAL FLOAT(6)
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Jan 30, 2008 4:07 am    Post subject: test data for float decimal field Reply with quote

I have a file defined as below and i want to input data into the file which should be Float Decimal as defined for TEST:
Code:

    DCL 1 INREC,                                           
          2 NAME       CHAR        (04),                   
          2 TEST       FLOAT DECIMAL(6),                   
          2 EMPTY      CHAR        (72);                   

How can i input the data in the dataset of float decimal and how many bytes of storage in the dataset it takes since floating point takes exponential form , i am unable to understand how to proceed.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jan 30, 2008 6:12 am    Post subject: Reply with quote

1) You are defining a record not a file
2) Storage used by FLOAT is in the manual - I know because I looked it up a couple of months ago
3) Input it the same way as any other data
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Jan 30, 2008 6:58 am    Post subject: Reply with quote

Nic,

Thanks for your reply. I have found this:
Code:

A decimal floating-point constant is a mantissa followed by an exponent. The mantissa is a decimal fixed-point constant.  The exponent is the
letter E followed by an optionally signed integer, which specifies a power of ten.  Decimal floating-point constants have a precision (p), where p
is the number of digits of the mantissa.  Examples are:
 
Constant       Precision
15E-23         (2)
15E23          (2)
4E-3           (1)
1.96E+07       (3)
438E0          (3)
3141593E-6     (7)
.003141593E3   (9)
 
The last two examples represent the same value (although with different
precisions).
 
The data attributes for declaring decimal floating-point variables are DECIMAL and FLOAT.  For example:
 
  DECLARE LIGHT_YEARS DECIMAL FLOAT(5);
 
LIGHT_YEARS represents decimal floating-point data items with at least 5
decimal digits.
 
The default precision is (6).  Decimal floating-point data is stored as normalized hexadecimal floating-point, with the hexadecimal point assumed to
the left of the first hexadecimal digit.  If the declared precision is less than or equal to (6), short floating-point form is used.  If the declared
precision is greater than (6) and less than or equal to (16), long floating-point form is used.  If the declared precision is greater than (16),
extended floating-point form is used.
 
Note:  You should avoid coding the internal representation of extended precision floating-point values.  Under some circumstances, these values
do not compare properly with other extended precision floating-point values.  To avoid this problem, use decimal floating-point constants to
specify extended precision floating-point values.

Please help me how to form an input data in my case for the field TEST and how many bytes it takes to store for the field TEST and how will be the output ?

Say if i want to input 60 to the field TEST , how i can input and how to see the output in the record as i am not able to proceed ahead.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jan 30, 2008 11:03 am    Post subject: Reply with quote

Right, I've had to resort to my book (Structured Programming in PL/1& PL/C by Peter Abel). You can enter your float data in any valid numeric format e.g. -123.45 or -1.2345E2.

Code:

DCL VALUEFLT FLOAT DEC(6);
DCL VALUEFXD FIXED DEC(5,2);
/* 1 */
GET LIST (VALUEFLT);     /* Can enter -123.45 or 1.2345E2 */
/* 2 */
GET LIST (VALUEFXD); /* Can enter -123.45 only*/
VALUEFLT = VALUEFXD;
/* or 3 */
GET EDIT (VALUEFLT) (COLUMN(1), E(9,4)); /* can enter -1.2345E2 only*/

_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Jan 30, 2008 12:08 pm    Post subject: Reply with quote

Nic,

Thanks for your reply and i am able to understand when u are using Stream GET LIST , now in my case i am using RECORD I/O , please let me know how i can enter data , i guess it should be entered by putting HEX ON .If possible can u show me an example.Please let me know from you.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Jan 31, 2008 6:00 am    Post subject: Reply with quote

Never having used FLOAT (except maybe in examples) and not having access to a PL/1 compiler or run-time I cannot try this but I think you can enter it as per my example on your input records. Failing that, enter it as FIXED DEC and assign to the FLOAT variable.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Jan 31, 2008 7:28 am    Post subject: Reply with quote

you could always write a quick&dirty to write float type fields in a record and then look at the output file and see what they look like. Then you would know how to create an input file.

I work in Banks/insurance/transportation companies; never had to use float, as the precision sucks.

What industry are you in, that you need to use float type variables?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Mar 11, 2008 4:15 am    Post subject: Reply with quote

Quote:
I work in Banks/insurance/transportation companies; never had to use float, as the precision sucks.


decimal floating point is now here, in hardware, and it absolutely nukes packed decimal, which appears utterly pathetic in comparison. It was invented by Mike Cowlishaw, the IBM fellow who invented REXX. Don't confuse binary or hex floating point with decimal floating point!

http://www.research.ibm.com/journal/rd/511/duale.html
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group