mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 02:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322138 c90b9560-bf6c-de11-be94-00142212c4b1
154 lines
5 KiB
XML
154 lines
5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<phpdoc:classref xmlns:phpdoc="http://php.net/ns/phpdoc" xml:id="class.numberformatter" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<title>The NumberFormatter class</title>
|
|
<titleabbrev>NumberFormatter</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ NumberFormatter intro -->
|
|
<section xml:id="numberformatter.intro">
|
|
&reftitle.intro;
|
|
<simpara>
|
|
Programs store and operate on numbers using a locale-independent binary
|
|
representation. When displaying or printing a number it is converted to a
|
|
locale-specific string. For example, the number 12345.67 is "12,345.67" in
|
|
the US, "12 345,67" in France and "12.345,67" in Germany.
|
|
</simpara>
|
|
<simpara>
|
|
By invoking the methods provided by the NumberFormatter class, you can
|
|
format numbers, currencies, and percentages according to the specified or
|
|
default locale. NumberFormatter is locale-sensitive so you need to create
|
|
a new NumberFormatter for each locale. NumberFormatter methods format
|
|
primitive-type numbers, such as double and output the number as a
|
|
locale-specific string.
|
|
</simpara>
|
|
<para>
|
|
For currencies you can use currency format type to create a formatter that
|
|
returns a string with the formatted number and the appropriate currency
|
|
sign. Of course, the NumberFormatter class is unaware of exchange rates
|
|
so, the number output is the same regardless of the specified currency.
|
|
This means that the same number has different monetary values depending on
|
|
the currency locale. If the number is 9988776.65 the results will be:
|
|
<simplelist>
|
|
<member>9 988 776,65 € in France</member>
|
|
<member>9.988.776,65 € in Germany</member>
|
|
<member>$9,988,776.65 in the United States</member>
|
|
</simplelist>
|
|
</para>
|
|
<simpara>
|
|
In order to format percentages, create a locale-specific formatter with
|
|
percentage format type. With this formatter, a decimal fraction such as
|
|
0.75 is displayed as 75%.
|
|
</simpara>
|
|
<simpara>
|
|
For more complex formatting, like spelled-out numbers, the rule-based
|
|
number formatters are used.
|
|
</simpara>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="numberformatter.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass>
|
|
<classname>NumberFormatter</classname>
|
|
</ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>NumberFormatter</classname>
|
|
</ooclass>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
|
|
<!--
|
|
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
|
|
<fieldsynopsis>
|
|
<modifier>public</modifier>
|
|
<type>string</type>
|
|
<varname linkend="numberformatter.props.name">name</varname>
|
|
</fieldsynopsis>
|
|
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.numberformatter')/db:refentry/db:refsect1[@role='description']/descendant::db:fieldsynopsis[1])" />
|
|
-->
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include
|
|
xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.numberformatter')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[1])" />
|
|
<xi:include
|
|
xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.numberformatter')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
|
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<!-- {{{ NumberFormatter properties
|
|
<section xml:id="numberformatter.props">
|
|
&reftitle.properties;
|
|
<variablelist>
|
|
<varlistentry xml:id="numberformatter.props.name">
|
|
<term><varname>name</varname></term>
|
|
<listitem>
|
|
<para>Prop description</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</section>
|
|
}}} -->
|
|
|
|
&reference.intl.numberformatter-constants;
|
|
|
|
<section xml:id="numberformatter.seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member>
|
|
<link xlink:href="&url.icu.formatparse;">
|
|
ICU formatting documentation
|
|
</link>
|
|
</member>
|
|
<member>
|
|
<link xlink:href="&url.icu.formatnumbers;">ICU number formatters</link>
|
|
</member>
|
|
<member>
|
|
<link xlink:href="&url.icu.decimalformat;">ICU decimal formatters</link>
|
|
</member>
|
|
<member>
|
|
<link xlink:href="&url.icu.ruleformat;">
|
|
ICU rule-based number formatters
|
|
</link>
|
|
</member>
|
|
</simplelist>
|
|
</para>
|
|
</section>
|
|
</partintro>
|
|
|
|
&reference.intl.entities.numberformatter;
|
|
|
|
</phpdoc:classref>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|