<html>
<head>
<title>round() ֐</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">round() ֐</td>
<td valign="top" class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">
p[^ɍł߂lԂ܂B</td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>  2 ̐lp[^ɓ悤ɋ߂ꍇ (Ƃ΁A<span class="LITERAL">1</span>  <span class="LITERAL">2</span> ͓悤 <span class="LITERAL">1.5</span> ɋ߂)A̖ɍł߂lԂ܂B܂܂ȃp[^l͎̂悤ɏ܂B</p>
<ul>
<dd>p[^ <span class="LITERAL">NaN</span> (lłȂl) ̏ꍇA<span class="LITERAL">round()</span> ֐ <span class="LITERAL">NaN</span> Ԃ܂B </p>
        </li>
<dd>p[^̖̏ꍇA̖傪Ԃ܂B </p>
        </li>
<dd>p[^̖̏ꍇA̖傪Ԃ܂B </p>
        </li>
<dd>p[^ 0 ̏ꍇA 0 Ԃ܂B </p>
        </li>
<dd>p[^ 0 ̏ꍇA 0 Ԃ܂B </p>
        </li>
<dd>p[^ 0 ` -0.5 ̏ꍇA 0 Ԃ܂B </p>
        </li>
      </ul>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>lBp[^lłȂꍇ́A<span class="LITERAL">number()</span> ֐ɓnꂽ̂悤ɐlɕϊ܂B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">o</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>p[^ɍł߂lBʂȏꍇɂẮA̐߂ŐĂ悤ɏ܂B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">`</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XPath 4.4 ߁uNumber Functionsv</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>̃X^CV[gł́A܂܂Ȓlɑ΂ <span class="LITERAL">round()</span> ֐Ăяoʂ܂B XML hLg͂ƂĎgp܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;report&gt;
  &lt;title&gt;Miles Flown in 2001&lt;/title&gt;
  &lt;month sequence="01"&gt;
    &lt;miles-flown&gt;12379&lt;/miles-flown&gt;
    &lt;miles-earned&gt;35215&lt;/miles-earned&gt;
  &lt;/month&gt;
  &lt;month sequence="02"&gt;
    &lt;miles-flown&gt;32857&lt;/miles-flown&gt;
    &lt;miles-earned&gt;92731&lt;/miles-earned&gt;
  &lt;/month&gt;
  &lt;month sequence="03"&gt;
    &lt;miles-flown&gt;19920&lt;/miles-flown&gt;
    &lt;miles-earned&gt;76725&lt;/miles-earned&gt;
  &lt;/month&gt;
  &lt;month sequence="04"&gt;
    &lt;miles-flown&gt;18903&lt;/miles-flown&gt;
    &lt;miles-earned&gt;31781&lt;/miles-earned&gt;
  &lt;/month&gt;
&lt;/report&gt;</pre></span>
<p><span class="LITERAL">round()</span> ֐gpX^CV[gɎ܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:months="Lookup table for month names"&gt;

  &lt;months:name sequence="01"&gt;January&lt;/months:name&gt;
  &lt;months:name sequence="02"&gt;February&lt;/months:name&gt;
  &lt;months:name sequence="03"&gt;March&lt;/months:name&gt;
  &lt;months:name sequence="04"&gt;April&lt;/months:name&gt;
  &lt;months:name sequence="05"&gt;May&lt;/months:name&gt;
  &lt;months:name sequence="06"&gt;June&lt;/months:name&gt;
  &lt;months:name sequence="07"&gt;July&lt;/months:name&gt;
  &lt;months:name sequence="08"&gt;August&lt;/months:name&gt;
  &lt;months:name sequence="09"&gt;September&lt;/months:name&gt;
  &lt;months:name sequence="10"&gt;October&lt;/months:name&gt;
  &lt;months:name sequence="11"&gt;November&lt;/months:name&gt;
  &lt;months:name sequence="12"&gt;December&lt;/months:name&gt;

  &lt;xsl:output method="text"/&gt;

  &lt;xsl:variable name="newline"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;Tests of the round() function:&lt;/xsl:text&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round('7.983')" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round('7.983')"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round('7.5')" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round('7.5')"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round('-7.893')" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round('-7.893')"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round('-7.5')" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round('-7.5')"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round(/report/month[@sequence='01']/miles-flown)" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round(/report/month[@sequence='01']/miles-flown)"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   "round(document('')/*/months:name[@sequence='02'])" = &lt;/xsl:text&gt;
    &lt;xsl:value-of select="round(document('')/*/months:name[@sequence='02'])"/&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
<!--<?troff .Nd 10?>-->
    &lt;xsl:for-each select="/report/month"&gt;
      &lt;xsl:text&gt;   &lt;/xsl:text&gt;
      &lt;xsl:value-of 
        select="document('')/*/months:name[@sequence=current()/@sequence]"/&gt;
      &lt;xsl:text&gt; - &lt;/xsl:text&gt;
      &lt;xsl:value-of select="format-number(miles-flown, '##,###')"/&gt;
      &lt;xsl:text&gt; miles flown, &lt;/xsl:text&gt;
      &lt;xsl:value-of select="format-number(miles-earned, '##,###')"/&gt;
      &lt;xsl:text&gt; miles earned.&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$newline"/&gt;
      &lt;xsl:text&gt;      (Averaged &lt;/xsl:text&gt;
      &lt;xsl:value-of select="round(miles-earned div miles-flown)"/&gt;
      &lt;xsl:text&gt; miles earned for each mile flown.)&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$newline"/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>̃X^CV[ggp XML hLgʂ͎̂ƂłB</p>
<span class="PROGRAMLISTING"><pre>

Tests of the round() function:

   "round('7.983')" = 8
   "round('7.5')" = 8
   "round('-7.893')" = -8
   "round('-7.5')" = -7
   "round(/report/month[@sequence='01']/miles-flown)" = 12379
   "round(document('')/*/months:name[@sequence='02'])" = NaN

   January - 12,379 miles flown, 35,215 miles earned.
      (Averaged 3 miles earned for each mile flown.)

   February - 32,857 miles flown, 92,731 miles earned.
      (Averaged 3 miles earned for each mile flown.)

   March - 19,920 miles flown, 76,725 miles earned.
      (Averaged 4 miles earned for each mile flown.)

   April - 18,903 miles flown, 31,781 miles earned.
      (Averaged 2 miles earned for each mile flown.)
</pre></span>
<p>̌ʂA<span class="LITERAL">ceiling()</span> ֐ <span class="LITERAL">floor()</span> ֐̌ʂƔrł܂B </p>
</td>
</tr>
</table>
</div>
</body>
</html>
