String conversion anomalies
Kevin Ryde
user42 at zip.com.au
Mon Apr 19 23:31:50 CEST 2004
Jerry James <james at xemacs.org> writes:
>
> I packaged up a bunch of them into one bug report.
It's very hard to address multiple matters in one big jumble. Don't
do that.
> GMP does not convert strings like strtol and strtod do.
True.
> #1-#3: The documentation says that a zero return value means that all
> characters of the string are valid for a number of the indicated type
> and base. It does not indicate what happens when not all characters are
> valid.
It says "Otherwise it returns -1."
> Personally,
> I find the strtol behavior much nicer, because in XEmacs, I often know
> that a string starts with a number, and I want to convert that part of
> the string into a number.
We're contemplating strtol and strtod style variants, but don't have
them presently.
> #5: Same as #2 -- leading plus signs are apparently not allowed,
True.
> although I do not see that mentioned in the documentation anywhere.
If it doesn't say it accepts them then it doesn't :-).
> #6: Notice what happened here. GMP reported that the string was invalid
> ... AFTER changing the numerator!
Yep.
> It should either leave the numerator alone
I don't see any particular need for that, the result is unspecified if
the input is bad.
> #12: This shows that mpf_set_str is willing to ignore trailing junk and
> not report that the result is invalid,
This is a bug, it doesn't validate the exponent properly. There's a
tasks list entry about fixing that.
--
All followups to gmp-bugs at swox.com please.
More information about the gmp-bugs
mailing list