<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >GMP</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="textdomain" HREF="function.textdomain.html"><LINK REL="NEXT" TITLE="gmp_abs" HREF="function.gmp-abs.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.textdomain.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.gmp-abs.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.gmp" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >L. GMP</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN59960" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.intro" >Introdução</A ></H1 ><P > Estas funções permitem a você trabalhar com inteiros de tamanho arbritário usando a biblioteca GNU <ACRONYM CLASS="acronym" >MP</ACRONYM >. </P ><P > Estas funções foram adicionadas no PHP 4.0.4. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > A maioria das funções GMP aceitam números GMP comoargumentos, definidos como <TT CLASS="literal" >resource</TT > abaixo. Entretanto, a maioria destas funções também aceitam argumentos númericos e strings, dado que é possível converter posteriormente para um número. Também, caso houver uma função mais rápida que possa trabalhar com números inteiros, ela será usada ao invés de uma função mais lenta quando os argumentos forem inteiros. Isto é feito de forma transparente, em resumo, você poderá usar inteiros em qualquer função que espere um número GMP. Veja também a função <A HREF="function.gmp-init.html" ><B CLASS="function" >gmp_init()</B ></A >. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > Se você quiser explicitamente especificar um número inteiro largo, especifique-o como uma string. Se você não fizer isto, o PHP irá interpretar a literal inteira primeiro, possivelmente resultando em perca de precisão, mesmo antes de começar a utilizar o <TT CLASS="literal" >GMP</TT >. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B >Esta extensão não está disponível na plataforma Windows.</P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.requirements" >Dependências</A ></H1 ><P > Você pode copiar a biblioteca <ACRONYM CLASS="acronym" >GMP</ACRONYM > a partir de <A HREF="http://www.swox.com/gmp/" TARGET="_top" >http://www.swox.com/gmp/</A >. Este site também tem o manual <ACRONYM CLASS="acronym" >GMP</ACRONYM > disponível. </P ><P > Você vai precisar do GMP versão 2 ou posterior para usar estas funções. Algumas destas funções podem querer uma versão mais recente da biblioteca GMP. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.installation" >Instalação</A ></H1 ><P > Para ter estas funções disponíveis, você deve compilar o PHP com suporte a <ACRONYM CLASS="acronym" >GMP</ACRONYM > usando a opção de configuração <CODE CLASS="option" >--with-gmp</CODE >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.resources" >Tipos Resource</A ></H1 ><P >Esta extensão não possui nenhum tipo resource.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >GMP_ROUND_ZERO</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >GMP_ROUND_PLUSINF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >GMP_ROUND_MINUSINF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN60019" ></A ><P ><B >Exemplo 1. Função de fatorial usando GMP</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">function </font><font color="#0000BB">fact </font><font color="#007700">(</font><font color="#0000BB">$x</font><font color="#007700">) <br />{<br /> if (</font><font color="#0000BB">$x </font><font color="#007700"><= </font><font color="#0000BB">1</font><font color="#007700">) { <br /> return </font><font color="#0000BB">1</font><font color="#007700">;<br /> } else {<br /> return </font><font color="#0000BB">gmp_mul </font><font color="#007700">(</font><font color="#0000BB">$x</font><font color="#007700">, </font><font color="#0000BB">fact </font><font color="#007700">(</font><font color="#0000BB">$x</font><font color="#007700">-</font><font color="#0000BB">1</font><font color="#007700">));<br /> } <br />}<br /><br />echo </font><font color="#0000BB">gmp_strval</font><font color="#007700">(</font><font color="#0000BB">fact</font><font color="#007700">(</font><font color="#0000BB">1000</font><font color="#007700">)) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > Esta irá calcular o fatorial de 1000 (um número grande) muito rapidamente. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="gmp.seealso" >Veja também</A ></H1 ><P > Mais funções matemáticas podem ser encontradas nas seções <A HREF="ref.bc.html" >BCMath Funções Matemáticas de Precisão Arbitrária</A > and <A HREF="ref.math.html" >Matemática e Trigonometria</A >. </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.gmp-abs.html" >gmp_abs</A > -- Valor absoluto</DT ><DT ><A HREF="function.gmp-add.html" >gmp_add</A > -- Adiciona números</DT ><DT ><A HREF="function.gmp-and.html" >gmp_and</A > -- Lógico AND</DT ><DT ><A HREF="function.gmp-clrbit.html" >gmp_clrbit</A > -- Limpa bit</DT ><DT ><A HREF="function.gmp-cmp.html" >gmp_cmp</A > -- Compara números</DT ><DT ><A HREF="function.gmp-com.html" >gmp_com</A > -- Calcula o complemento</DT ><DT ><A HREF="function.gmp-div-q.html" >gmp_div_q</A > -- Divide números</DT ><DT ><A HREF="function.gmp-div-qr.html" >gmp_div_qr</A > -- Divide números e retorna o quociente e o resto da divisão</DT ><DT ><A HREF="function.gmp-div-r.html" >gmp_div_r</A > -- Resto da divisão de números</DT ><DT ><A HREF="function.gmp-div.html" >gmp_div</A > -- Apelido para <A HREF="function.gmp-div-q.html" ><B CLASS="function" >gmp_div_q()</B ></A ></DT ><DT ><A HREF="function.gmp-divexact.html" >gmp_divexact</A > -- Divisão exata de números</DT ><DT ><A HREF="function.gmp-fact.html" >gmp_fact</A > -- Fatorial</DT ><DT ><A HREF="function.gmp-gcd.html" >gmp_gcd</A > -- Calcula o MDC</DT ><DT ><A HREF="function.gmp-gcdext.html" >gmp_gcdext</A > -- Calculate GCD and multipliers</DT ><DT ><A HREF="function.gmp-hamdist.html" >gmp_hamdist</A > -- Hamming distance</DT ><DT ><A HREF="function.gmp-init.html" >gmp_init</A > -- Cria um número GMP</DT ><DT ><A HREF="function.gmp-intval.html" >gmp_intval</A > -- Converte um número GMP para um inteiro</DT ><DT ><A HREF="function.gmp-invert.html" >gmp_invert</A > -- Inverse by modulo</DT ><DT ><A HREF="function.gmp-jacobi.html" >gmp_jacobi</A > -- Jacobi symbol</DT ><DT ><A HREF="function.gmp-legendre.html" >gmp_legendre</A > -- Legendre symbol</DT ><DT ><A HREF="function.gmp-mod.html" >gmp_mod</A > -- Modulo operation</DT ><DT ><A HREF="function.gmp-mul.html" >gmp_mul</A > -- Multiplica números</DT ><DT ><A HREF="function.gmp-neg.html" >gmp_neg</A > -- Nega o número</DT ><DT ><A HREF="function.gmp-nextprime.html" >gmp_nextprime</A > -- Find next prime number</DT ><DT ><A HREF="function.gmp-or.html" >gmp_or</A > -- Lógico OR</DT ><DT ><A HREF="function.gmp-perfect-square.html" >gmp_perfect_square</A > -- Perfect square check</DT ><DT ><A HREF="function.gmp-popcount.html" >gmp_popcount</A > -- Contagem de população</DT ><DT ><A HREF="function.gmp-pow.html" >gmp_pow</A > -- Potenciação</DT ><DT ><A HREF="function.gmp-powm.html" >gmp_powm</A > -- Raise number into power with modulo</DT ><DT ><A HREF="function.gmp-prob-prime.html" >gmp_prob_prime</A > -- Check if number is "probably prime"</DT ><DT ><A HREF="function.gmp-random.html" >gmp_random</A > -- Número randomico</DT ><DT ><A HREF="function.gmp-scan0.html" >gmp_scan0</A > -- Scan for 0</DT ><DT ><A HREF="function.gmp-scan1.html" >gmp_scan1</A > -- Scan for 1</DT ><DT ><A HREF="function.gmp-setbit.html" >gmp_setbit</A > -- Set bit</DT ><DT ><A HREF="function.gmp-sign.html" >gmp_sign</A > -- Sinal do número</DT ><DT ><A HREF="function.gmp-sqrt.html" >gmp_sqrt</A > -- Raíz quadrada</DT ><DT ><A HREF="function.gmp-sqrtrem.html" >gmp_sqrtrem</A > -- Square root with remainder </DT ><DT ><A HREF="function.gmp-strval.html" >gmp_strval</A > -- Converte um número GMP para uma string</DT ><DT ><A HREF="function.gmp-sub.html" >gmp_sub</A > -- Subtrai números</DT ><DT ><A HREF="function.gmp-xor.html" >gmp_xor</A > -- Lógico XOR</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.textdomain.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.gmp-abs.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >textdomain</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >gmp_abs</TD ></TR ></TABLE ></DIV ></BODY ></HTML >