mpz_init_set_si(**gmpnumber, Z_LVAL_PP(val));
}
break;
+ case IS_UNICODE:
+ convert_to_string_ex(val);
+ /* Fallthrough */
case IS_STRING:
{
char *numstr = Z_STRVAL_PP(val);
base = 2;
skip_lead = 1;
}
+ /* Note: tests/004.phpt and tests/005.phpt suggest that we should be
+ * interpreting a leading zero as octal (when not followed by x or b)
+ * Yet the docs, and the existing code (above), suggest otherwise.
+ *
+ * Possibly fix this by putting an: else base = 8; here */
}
}
ret = mpz_init_set_str(**gmpnumber, (skip_lead ? &numstr[2] : numstr), base);
}
/* }}} */
-/* {{{ proto resource gmp_init(mixed number [, int base])
+/* {{{ proto resource gmp_init(mixed number [, int base]) U
Initializes GMP number */
ZEND_FUNCTION(gmp_init)
{
}
/* }}} */
-/* {{{ proto int gmp_intval(resource gmpnumber)
+/* {{{ proto int gmp_intval(resource gmpnumber) U
Gets signed long value of GMP number */
ZEND_FUNCTION(gmp_intval)
{
}
/* }}} */
-/* {{{ proto string gmp_strval(resource gmpnumber [, int base])
+/* {{{ proto string gmp_strval(resource gmpnumber [, int base]) U
Gets string representation of GMP number */
ZEND_FUNCTION(gmp_strval)
{
} else {
out_string[num_len] = '\0';
}
- RETVAL_STRINGL(out_string, num_len, 0);
+ RETVAL_RT_STRINGL(out_string, num_len, ZSTR_AUTOFREE);
}
/* }}} */
-/* {{{ proto resource gmp_add(resource a, resource b)
+/* {{{ proto resource gmp_add(resource a, resource b) U
Add a and b */
ZEND_FUNCTION(gmp_add)
{
}
/* }}} */
-/* {{{ proto resource gmp_sub(resource a, resource b)
+/* {{{ proto resource gmp_sub(resource a, resource b) U
Subtract b from a */
ZEND_FUNCTION(gmp_sub)
{
}
/* }}} */
-/* {{{ proto resource gmp_mul(resource a, resource b)
+/* {{{ proto resource gmp_mul(resource a, resource b) U
Multiply a and b */
ZEND_FUNCTION(gmp_mul)
{
}
/* }}} */
-/* {{{ proto array gmp_div_qr(resource a, resource b [, int round])
+/* {{{ proto array gmp_div_qr(resource a, resource b [, int round]) U
Divide a by b, returns quotient and reminder */
ZEND_FUNCTION(gmp_div_qr)
{
}
/* }}} */
-/* {{{ proto resource gmp_div_r(resource a, resource b [, int round])
+/* {{{ proto resource gmp_div_r(resource a, resource b [, int round]) U
Divide a by b, returns reminder only */
ZEND_FUNCTION(gmp_div_r)
{
}
/* }}} */
-/* {{{ proto resource gmp_div_q(resource a, resource b [, int round])
+/* {{{ proto resource gmp_div_q(resource a, resource b [, int round]) U
Divide a by b, returns quotient only */
ZEND_FUNCTION(gmp_div_q)
{
}
/* }}} */
-/* {{{ proto resource gmp_mod(resource a, resource b)
+/* {{{ proto resource gmp_mod(resource a, resource b) U
Computes a modulo b */
ZEND_FUNCTION(gmp_mod)
{
}
/* }}} */
-/* {{{ proto resource gmp_divexact(resource a, resource b)
+/* {{{ proto resource gmp_divexact(resource a, resource b) U
Divide a by b using exact division algorithm */
ZEND_FUNCTION(gmp_divexact)
{
}
/* }}} */
-/* {{{ proto resource gmp_neg(resource a)
+/* {{{ proto resource gmp_neg(resource a) U
Negates a number */
ZEND_FUNCTION(gmp_neg)
{
}
/* }}} */
-/* {{{ proto resource gmp_abs(resource a)
+/* {{{ proto resource gmp_abs(resource a) U
Calculates absolute value */
ZEND_FUNCTION(gmp_abs)
{
}
/* }}} */
-/* {{{ proto resource gmp_fact(int a)
+/* {{{ proto resource gmp_fact(int a) U
Calculates factorial function */
ZEND_FUNCTION(gmp_fact)
{
}
/* }}} */
-/* {{{ proto resource gmp_pow(resource base, int exp)
+/* {{{ proto resource gmp_pow(resource base, int exp) U
Raise base to power exp */
ZEND_FUNCTION(gmp_pow)
{
}
/* }}} */
-/* {{{ proto resource gmp_powm(resource base, resource exp, resource mod)
+/* {{{ proto resource gmp_powm(resource base, resource exp, resource mod) U
Raise base to power exp and take result modulo mod */
ZEND_FUNCTION(gmp_powm)
{
}
/* }}} */
-/* {{{ proto resource gmp_sqrt(resource a)
+/* {{{ proto resource gmp_sqrt(resource a) U
Takes integer part of square root of a */
ZEND_FUNCTION(gmp_sqrt)
{
}
/* }}} */
-/* {{{ proto array gmp_sqrtrem(resource a)
+/* {{{ proto array gmp_sqrtrem(resource a) U
Square root with remainder */
ZEND_FUNCTION(gmp_sqrtrem)
{
}
/* }}} */
-/* {{{ proto bool gmp_perfect_square(resource a)
+/* {{{ proto bool gmp_perfect_square(resource a) U
Checks if a is an exact square */
ZEND_FUNCTION(gmp_perfect_square)
{
}
/* }}} */
-/* {{{ proto int gmp_prob_prime(resource a[, int reps])
+/* {{{ proto int gmp_prob_prime(resource a[, int reps]) U
Checks if a is "probably prime" */
ZEND_FUNCTION(gmp_prob_prime)
{
}
/* }}} */
-/* {{{ proto resource gmp_gcd(resource a, resource b)
+/* {{{ proto resource gmp_gcd(resource a, resource b) U
Computes greatest common denominator (gcd) of a and b */
ZEND_FUNCTION(gmp_gcd)
{
}
/* }}} */
-/* {{{ proto array gmp_gcdext(resource a, resource b)
+/* {{{ proto array gmp_gcdext(resource a, resource b) U
Computes G, S, and T, such that AS + BT = G = `gcd' (A, B) */
ZEND_FUNCTION(gmp_gcdext)
{
}
/* }}} */
-/* {{{ proto resource gmp_invert(resource a, resource b)
+/* {{{ proto resource gmp_invert(resource a, resource b) U
Computes the inverse of a modulo b */
ZEND_FUNCTION(gmp_invert)
{
}
/* }}} */
-/* {{{ proto int gmp_jacobi(resource a, resource b)
+/* {{{ proto int gmp_jacobi(resource a, resource b) U
Computes Jacobi symbol */
ZEND_FUNCTION(gmp_jacobi)
{
}
/* }}} */
-/* {{{ proto int gmp_legendre(resource a, resource b)
+/* {{{ proto int gmp_legendre(resource a, resource b) U
Computes Legendre symbol */
ZEND_FUNCTION(gmp_legendre)
{
}
/* }}} */
-/* {{{ proto int gmp_cmp(resource a, resource b)
+/* {{{ proto int gmp_cmp(resource a, resource b) U
Compares two numbers */
ZEND_FUNCTION(gmp_cmp)
{
}
/* }}} */
-/* {{{ proto int gmp_sign(resource a)
+/* {{{ proto int gmp_sign(resource a) U
Gets the sign of the number */
ZEND_FUNCTION(gmp_sign)
{
}
/* }}} */
-/* {{{ proto resource gmp_random([int limiter])
+/* {{{ proto resource gmp_random([int limiter]) U
Gets random number */
ZEND_FUNCTION(gmp_random)
{
}
/* }}} */
-/* {{{ proto resource gmp_and(resource a, resource b)
+/* {{{ proto resource gmp_and(resource a, resource b) U
Calculates logical AND of a and b */
ZEND_FUNCTION(gmp_and)
{
}
/* }}} */
-/* {{{ proto resource gmp_or(resource a, resource b)
+/* {{{ proto resource gmp_or(resource a, resource b) U
Calculates logical OR of a and b */
ZEND_FUNCTION(gmp_or)
{
}
/* }}} */
-/* {{{ proto resource gmp_com(resource a)
+/* {{{ proto resource gmp_com(resource a) U
Calculates one's complement of a */
ZEND_FUNCTION(gmp_com)
{
}
/* }}} */
-/* {{{ proto resource gmp_nextprime(resource a)
+/* {{{ proto resource gmp_nextprime(resource a) U
Finds next prime of a */
ZEND_FUNCTION(gmp_nextprime)
{
}
/* }}} */
-/* {{{ proto resource gmp_xor(resource a, resource b)
+/* {{{ proto resource gmp_xor(resource a, resource b) U
Calculates logical exclusive OR of a and b */
ZEND_FUNCTION(gmp_xor)
{
}
/* }}} */
-/* {{{ proto void gmp_setbit(resource &a, int index[, bool set_clear])
+/* {{{ proto void gmp_setbit(resource &a, int index[, bool set_clear]) U
Sets or clear bit in a */
ZEND_FUNCTION(gmp_setbit)
{
}
/* }}} */
-/* {{{ proto void gmp_clrbit(resource &a, int index)
+/* {{{ proto void gmp_clrbit(resource &a, int index) U
Clears bit in a */
ZEND_FUNCTION(gmp_clrbit)
{
}
/* }}} */
-/* {{{ proto int gmp_popcount(resource a)
+/* {{{ proto int gmp_popcount(resource a) U
Calculates the population count of a */
ZEND_FUNCTION(gmp_popcount)
{
}
/* }}} */
-/* {{{ proto int gmp_hamdist(resource a, resource b)
+/* {{{ proto int gmp_hamdist(resource a, resource b) U
Calculates hamming distance between a and b */
ZEND_FUNCTION(gmp_hamdist)
{
}
/* }}} */
-/* {{{ proto int gmp_scan0(resource a, int start)
+/* {{{ proto int gmp_scan0(resource a, int start) U
Finds first zero bit */
ZEND_FUNCTION(gmp_scan0)
{
}
/* }}} */
-/* {{{ proto int gmp_scan1(resource a, int start)
+/* {{{ proto int gmp_scan1(resource a, int start) U
Finds first non-zero bit */
ZEND_FUNCTION(gmp_scan1)
{