|
Nelson, do you mean you have an alpha field with a value like "3.5E7" or "12.345"? If so, try the 'atof' function (A). If you mean that you have 8 bytes containing an actual floating point value, use a based 8F variable, and set its basing pointer to the address of the char field (B). ----------------------------- A ----------------------------- H bnddir('QC2LE') D float s 8f D atof pr 8f extproc('atof') D alpha * value options(*string) D charfld s 10a inz('.31416E1') C eval float = atof('123.45') C eval float = atof('4.5E72') C eval float = atof('73') C eval float = atof(%trim(charfld)) C seton Debug session output after each eval: > EVAL float FLOAT = 1.234500000000E+002 > EVAL float FLOAT = 4.500000000000E+072 > EVAL float FLOAT = 7.300000000000E+001 > EVAL float FLOAT = 3.141600000000E+000 ----------------------------- B ----------------------------- If you mean that you have 8 bytes containing an actual floating point value, use a based 8F variable, and set its basing pointer to the address of the char field. D floatVal s 8f D basedFloat s 8f based(pFloat) D rec s 1000a * Get the floating point value at offset "off" in field "rec" * into the float field "floatVal" C eval pFloat = %addr(rec) + off C eval floatVal = basedFloat C seton I'm guessing the second case is correct. If so, I'd use this technique for all the types, using a based data structure with a subfield starting at position 1 for each possible type. Set your basing pointer to the address of the record + the offset, then just assign from one of the based subfields. Barbara Morris >Date: Wed, 11 Aug 1999 21:01:57 -0400 >From: "Nelson C. Smith" <ncsmith@gate.net> >Subject: Re: Floating Point Question > >I have a procedure that substrings bytes out of file records based on = >field types, sizes, location, etc defined in the system catalog. The = >target of the substring is a char field, of course. With other fields, = >I can do a movel into the proper data type, but Floating point is not = >allowed on the movel opcode. How can I get the data in the alpha field = >into a floating point field? Is there any way to "cast" the subst = >results into something other than an alpha field? +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.