On Wed, 11 Jan 2006, Malcolm J. Currie wrote:
>> Should CHR_CTOI perform a check by re-formatting the returned integer
>> and seeing if the resulting string looks like the supplied string?
>>
>> A bit of a performance hit, I admit. Any other ideas?
>
> SUN/40 does warn that CHR_CTOx is (already) slow.
>
I would suggest either using INTEGER*8 internally and then checking for
overflow before returning the INTEGER*4. Or, rewriting chr_ctoi in C
(there are other routines in CHR that are in C) to use atoi() or strtol().
(strtol gives you error checking but it also will cause you trouble if
your long is 64bit so you will need to range check the result).
I'd probably vote for the C version, converting to a long and then
checking for truncation.
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|