[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading numeric fields from XML files



Thank you, I'll keep that in mind. Do you know of performance differences in either, or do you think it would be best to always use the atoll() function? Also, since we are on v5r2 and could use the %dec() bif, is there a benefit to using one over the other?

I did notice a couple of caveats to the atoi() function that I didn't have time to add yesterday.
1) It doesn't 'error' out if you pass it invalid numeric data (could be good or bad)
2) It does partial translation if there is an embedded character in your string (example; '5A55' becomes 55)

Even though neither Scott nor I included it in our code samples you should definitely do some sort of test on the string to be sure there is valid data in it.

Glenn Hopwood
Sr Programmer/Analyst
Electric Mobility
856-468-1000 x2545
Inactive hide details for Scott Klement <sk@xxxxxxxxxxxxxxxx>Scott Klement <sk@xxxxxxxxxxxxxxxx>


Scott Klement <sk@xxxxxxxxxxxxxxxx>
Sent by: owner-ftpapi@xxxxxxxxxxxxx

10/31/2005 04:25 PM

Please respond to
ftpapi@xxxxxxxxxxxxx

To

ftpapi@xxxxxxxxxxxxx

cc


Subject

Re: Reading numeric fields from XML files

Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>

Hi Glenn,

> * Prototype of a c-function used to convert alpha to integer
> D atoi            pr            10i 0 extproc('atoi')
> D   str                           *   value options(*string)

The only problem with this is that it's limited to what will fit in a
32-bit binary integer. It'll work great with '55555', but not so well with
'3555555555'.  If her numeric field is defined as 10,0, there's a good
chance that support for numbers that are that large will be required.

If you read my response to the same question, you'll see that I
recommended a different C function called atoll().  This one can handle
larger numbers and therefore won't suffer from the same problem.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------

GIF image

GIF image

GIF image