× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Wed, 27 Feb 2002, James Rich wrote:
>
>On Wed, 27 Feb 2002, Bob Cozzi (RPGIV) wrote:
>
>> There certainly needs to be:
>>
>> CharToDec()
>
>atoi()
> ...

James, atoi() is ok for a subset of the char-to-dec problems.
atoll() handles a few more (up to about 18 digits).  But there's
no complete solution for values with decimals like '1.23'.
You can call atof(), but that introduces errors through floating
point.  You can write your own procedure with a return type that's
ok for almost everything, say (30,9), but if you have a string
with 10 decimal places, you have to do some more work.

This is the kind of thing where a language built-in function
is necessary: a function that returns a different type based
on the parameters.  %dec() is an example; depending on the
parameters, it can return a value of any length and decimal
positions.

The char-to-dec function performed by MOVE/MOVEL isn't exactly
the same as what atoi does.  If you MOVE '1234N' to a
numeric result, the result gets -12345.  atoi would stop
at the N and return 1234.  To get -12345 from atoi, your string
would have to be '-12345'.

I imagine that any RPG version of char-to-dec would not
duplicate the MOVE behaviour which basically assumes that the
character value is actually a zoned value, but would instead
duplicate the atoi() and atof() behaviour (without the floating
point).

Barbara Morris



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.