From e6fe2e6a021ab6ba76027b26e2cf066821d263e6 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 23 Apr 2024 18:12:21 +0100 Subject: [PATCH 1/4] Fix GH-3336: String arguments that are converted have misleading explanation --- language-snippets.ent | 7 +- reference/gmp/functions/gmp-init.xml | 96 +++++++++++++++++++--------- reference/gmp/gmp/construct.xml | 62 ++---------------- 3 files changed, 75 insertions(+), 90 deletions(-) diff --git a/language-snippets.ent b/language-snippets.ent index fcf2afe88160..a81dc34d286b 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -2182,7 +2182,12 @@ or an explicit call to chr should be made. GMP object.'> -A GMP object, an &integer; or a numeric &string;.'> + + A GMP object, an &integer;, + or a &string; that can be interpreted as a number following the same logic + as if the string was used in gmp_init with a + base equal to 0. +'> diff --git a/reference/gmp/functions/gmp-init.xml b/reference/gmp/functions/gmp-init.xml index 85e8042113cc..c1d76a5ce915 100644 --- a/reference/gmp/functions/gmp-init.xml +++ b/reference/gmp/functions/gmp-init.xml @@ -20,37 +20,46 @@ &reftitle.parameters; - - - - num - - - An integer or a string. The string representation can be decimal, - hexadecimal or octal. - - - - - base - - - The base. - - - The base may vary from 2 to 62. If base is 0 (default value), the - actual base is determined from the leading characters: if the first - two characters are 0x or 0X, - hexadecimal is assumed, if the first two characters are 0b or 0B, - binary is assumed, otherwise if the first character is 0, - octal is assumed, otherwise decimal is assumed. - For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. - For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61. - - - - - + + + num + + + An integer or a string. + + + + + base + + + The base to use for converting a string representation. + + + An explicit base can be between 2 and 62. + For bases up to 36, case is ignored; + upper-case and lower-case letters have the same value. + For bases 37 to 62, + upper-case letter represent the values 10 to + 35 and lower-case letter represent the values + 36 to 61. + + + If base is 0 then the actual + base is determined from the leading characters of num. + If the first two characters are 0x or 0X, + the string is interpreted as a hexadecimal integer. + If the first two characters are 0b or 0B, + the string is interpreted as a binary integer. + If the first two characters are 0o or 0o, + the string is interpreted as an octal integer. + Moreover, if the first character is 0 the string + is also interpreted as an octal integer. + In all other cases, the string is interpreted as a decimal integer. + + + + @@ -60,6 +69,31 @@ + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 8.1.0 + + Support for explicit octal prefixes 0o and + 0o has been added for num strings. + Interpretation of such prefixes when base is + 0 has also been added. + + + + + + + &reftitle.examples; diff --git a/reference/gmp/gmp/construct.xml b/reference/gmp/gmp/construct.xml index 9939b7a61470..df2e9e089335 100644 --- a/reference/gmp/gmp/construct.xml +++ b/reference/gmp/gmp/construct.xml @@ -1,5 +1,5 @@ - + GMP::__construct Create GMP number @@ -18,64 +18,10 @@ - &reftitle.parameters; - - - - num - - - An integer or a string. The string representation can be decimal, - hexadecimal or octal. - - - - - base - - - The base. - - - The base may vary from 2 to 62. If base is 0 (default value), the - actual base is determined from the leading characters: if the first - two characters are 0x or 0X, - hexadecimal is assumed, if the first two characters are 0b or 0B, - binary is assumed, otherwise if the first character is 0, - octal is assumed, otherwise decimal is assumed. - For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. - For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61. - - - - - - - - &reftitle.seealso; From 560835ec2d2a55b8f0f65915f4d0e4b1a47e1d0a Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 27 Nov 2024 19:22:44 +0000 Subject: [PATCH 2/4] Readd sentence --- reference/gmp/functions/gmp-init.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reference/gmp/functions/gmp-init.xml b/reference/gmp/functions/gmp-init.xml index c1d76a5ce915..5ea80da3a1a6 100644 --- a/reference/gmp/functions/gmp-init.xml +++ b/reference/gmp/functions/gmp-init.xml @@ -25,7 +25,8 @@ num - An integer or a string. + An integer or a string. The string representation can be decimal, + hexadecimal or octal. From 067f90d3aa3f34f9c198b59c9a7b1b34a9b99e90 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 27 Nov 2024 19:23:14 +0000 Subject: [PATCH 3/4] Specify binary --- reference/gmp/functions/gmp-init.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/gmp/functions/gmp-init.xml b/reference/gmp/functions/gmp-init.xml index 5ea80da3a1a6..7cc09df5f983 100644 --- a/reference/gmp/functions/gmp-init.xml +++ b/reference/gmp/functions/gmp-init.xml @@ -26,7 +26,7 @@ An integer or a string. The string representation can be decimal, - hexadecimal or octal. + hexadecimal, octal, or binary. From 0f7864c2b8f15d79c0589bfbe792ff3f43e1e564 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 27 Nov 2024 19:24:26 +0000 Subject: [PATCH 4/4] GMP Param wording --- language-snippets.ent | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language-snippets.ent b/language-snippets.ent index a81dc34d286b..599e2ec9fc2a 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -2185,8 +2185,8 @@ or an explicit call to chr should be made. A GMP object, an &integer;, or a &string; that can be interpreted as a number following the same logic - as if the string was used in gmp_init with a - base equal to 0. + as if the string was used in gmp_init with automatic + base detection (i.e. when base is equal to 0). '>