× 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.


  • Subject: Re: String to Numeric
  • From: boldt@xxxxxxxxxx
  • Date: Tue, 8 Feb 2000 09:15:21 -0500



Jim wrote:
>Thanks, Hans.  This is about the same information that
>someone else gave me, though he showed me the atof function,
>which in this specific case works better, although I have to also
>use %Dec on it to convert it from float to integer.

I don't mean to be pedantic, but strictly speaking, %DEC converts
a number to decimal format, not integer format.

>My invoice
>numbers can, and will, be up to 11 digits long, and it seems there
>is a limit of 10 digits in atol.

As some others have pointed out, atof gives you a floating point
value.  I'd recommend avoiding that since floating point values
are by definition inaccurate.  (They're fine for engineering and
scientific calculations, but should be avoided for discrete
mathematics.)  If your value can possibly be bigger than the
maximum value of a 4-byte unsigned, you're probably better off
copying digits to a zoned numeric subfield.

Alternatively, you could break up the number in say 6 digit chunks
and call atol twice.

>
>Out of curiosity I tried changing it to 11 on the prototype, but no
>dice, as I'm sure you're aware.  So to see what would happen I
>changed it back to 10 and passed it '12345678901' and it came
>back with some screwy number (2147483647) which is overflow
>I guess.

Exactly.  Perhaps eventually we'll see support in the C runtime
library for 8-byte integer/unsigned numeric.

>
>The only modification I had to make was I could not use the header
>switches of dftactgrp and bnddir (didn't exist in V3R7) and right now
>I am compiling by selecting 14 with PDM and prompting with <F4>
>and entering those values.
>
>Okay, do you have a URL for a page on the internet that has the C
>function library calls?  Or even the header file on the web (I understand
>that no one could send me one as that would be an infringement of
>copyright, but I can't use 'em if I don't know what they are).

Someone else already suggested
<http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QBJATN00/CCONTENTS>
as a list of C function calls.  I'm sure a Google search will
uncover lots more sites with similar information, some perhaps
easier to browse through.

For information on how to translate a C prototype into an RPG
prototype, Barbara wrote up some information that can be read at:
<http://www.springfieldtn.net/users/leslier/callc.html>

Cheers!  Hans

Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-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 thread ...


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.