diff --git a/numeric.c b/numeric.c index ea855912dcf1..b2656cf5c33e 100644 --- a/numeric.c +++ b/numeric.c @@ -217,9 +217,13 @@ Perl_cast_uv(NV f) } /* -=for apidoc grok_bin +=for apidoc grok_bin +=for apidoc_item grok_hex +=for apidoc_item grok_oct -converts a string representing a binary number to numeric form. +These each convert a string representing a number to numeric form. The +number is binary in C, octal in C, and hexadecimal in +C. On entry C and C<*len_p> give the string to scan, C<*flags> gives conversion flags, and C should be C or a pointer to an NV. The @@ -229,18 +233,50 @@ encountering an invalid character (except NUL) will also trigger a warning. On return C<*len_p> is set to the length of the scanned string, and C<*flags> gives output flags. -If the value is <= C it is returned as a UV, the output flags are clear, -and nothing is written to C<*result>. If the value is > C, C -returns C, sets C in the output flags, -and writes an approximation of the correct value into C<*result> (which is an -NV; or the approximation is discarded if C is NULL). +If the value is S= C>, it is returned as a UV, the output flags are +clear, and nothing is written to C<*result>. If the value is S +C>: -The binary number may optionally be prefixed with C<"0b"> or C<"b"> unless -C is set in C<*flags> on entry. +=over + +=item * + +C is returned + +=item * + +C is set in C<*flags>. + +=item * + +If C is not null, an approximation of the correct value is written +into C<*result> (which is an NV). + +=back + +Unless C is set in C<*flags> on entry: + +=over + +=item For C + +the input string may optionally be prefixed with C<"0b"> or plain C<"b"> + +=item For C + +the input string may optionally be prefixed with C<"0x"> or plain C<"x"> +unless + +=item For C + +this flag is ignored; there is no optional prefix. The typical C<0> prefix is +just part of the number. + +=back If C is set in C<*flags> then any or all pairs of -digits may be separated from each other by a single underscore; also a single -leading underscore is accepted. +digits may be separated from each other by a single underscore, and also a +single leading underscore is accepted. =for apidoc Amnh||PERL_SCAN_ALLOW_UNDERSCORES =for apidoc Amnh||PERL_SCAN_DISALLOW_PREFIX @@ -249,9 +285,9 @@ leading underscore is accepted. =cut -Not documented yet because experimental is C and C<*len_p> give the string to scan, C<*flags> gives -conversion flags, and C should be C or a pointer to an NV. The -scan stops at the end of the string, or at just before the first invalid -character. Unless C is set in C<*flags>, -encountering an invalid character (except NUL) will also trigger a warning. On -return C<*len_p> is set to the length of the scanned string, and C<*flags> -gives output flags. - -If the value is <= C it is returned as a UV, the output flags are clear, -and nothing is written to C<*result>. If the value is > C, C -returns C, sets C in the output flags, -and writes an approximation of the correct value into C<*result> (which is an -NV; or the approximation is discarded if C is NULL). - -The hex number may optionally be prefixed with C<"0x"> or C<"x"> unless -C is set in C<*flags> on entry. - -If C is set in C<*flags> then any or all pairs of -digits may be separated from each other by a single underscore; also a single -leading underscore is accepted. - -=cut - -Not documented yet because experimental is C -which suppresses any message for non-portable numbers, but which are valid -on this platform. But, C<*flags> will have the corresponding flag bit set. - */ - UV Perl_grok_hex(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { @@ -303,39 +306,6 @@ Perl_grok_hex(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) return grok_hex(start, len_p, flags, result); } -/* -=for apidoc grok_oct - -converts a string representing an octal number to numeric form. - -On entry C and C<*len_p> give the string to scan, C<*flags> gives -conversion flags, and C should be C or a pointer to an NV. The -scan stops at the end of the string, or at just before the first invalid -character. Unless C is set in C<*flags>, -encountering an invalid character (except NUL) will also trigger a warning. On -return C<*len_p> is set to the length of the scanned string, and C<*flags> -gives output flags. - -If the value is <= C it is returned as a UV, the output flags are clear, -and nothing is written to C<*result>. If the value is > C, C -returns C, sets C in the output flags, -and writes an approximation of the correct value into C<*result> (which is an -NV; or the approximation is discarded if C is NULL). - -If C is set in C<*flags> then any or all pairs of -digits may be separated from each other by a single underscore; also a single -leading underscore is accepted. - -The C flag is always treated as being set for -this function. - -=cut - -Not documented yet because experimental is C -which suppresses any message for non-portable numbers, but which are valid -on this platform. - */ - UV Perl_grok_oct(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) {