Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 4096

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>round</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Math 数学函数"
HREF="ref.math.html"><LINK
REL="PREVIOUS"
TITLE="rand"
HREF="function.rand.html"><LINK
REL="NEXT"
TITLE="sin"
HREF="function.sin.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.rand.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.sin.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.round"
></A
>round</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN109058"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>round&nbsp;--&nbsp;对浮点数进行四舍五入</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN109061"
></A
><H2
>说明</H2
>float <B
CLASS="methodname"
>round</B
> ( float val [, int precision] )<BR
></BR
><P
>&#13;     返回将 <CODE
CLASS="parameter"
>val</CODE
> 根据指定精度
     <CODE
CLASS="parameter"
>precision</CODE
>(十进制小数点后数字的数目)进行四舍五入的结果。<CODE
CLASS="parameter"
>precision</CODE
>
     也可以是负数或零(默认值)。
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN109077"
></A
><P
><B
>例 1. <B
CLASS="function"
>round()</B
> 例子</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">3.4</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 3<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">3.5</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 4<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">3.6</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 4<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">3.6</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 4<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">1.95583</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">);&nbsp;&nbsp;</font><font color="#FF8000">// 1.96<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">1241757</font><font color="#007700">, -</font><font color="#0000BB">3</font><font color="#007700">); </font><font color="#FF8000">// 1242000<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">5.045</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 5.05<br /></font><font color="#007700">echo </font><font color="#0000BB">round</font><font color="#007700">(</font><font color="#0000BB">5.055</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">);&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// 5.06<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
       PHP 默认不能正确处理类似 <TT
CLASS="literal"
>"12,300.2"</TT
>
       的字符串。见<A
HREF="language.types.string.html#language.types.string.conversion"
>字符串转换为数值</A
>。
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
       <CODE
CLASS="parameter"
>precision</CODE
> 参数是在
       PHP 4 中被引入的。
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     参见 <A
HREF="function.ceil.html"
><B
CLASS="function"
>ceil()</B
></A
>,<A
HREF="function.floor.html"
><B
CLASS="function"
>floor()</B
></A
>
     和 <A
HREF="function.number-format.html"
><B
CLASS="function"
>number_format()</B
></A
>。
    </P
></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.rand.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.sin.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>rand</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.math.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sin</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>