/
book.xml
81 lines (75 loc) · 2.52 KB
/
book.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1d61be1ed9edb9b8191206768f2640aa9c7623ae Maintainer: sammywg Status: ready -->
<!-- Reviewed: yes -->
<!-- Rev-Revision: 1.0 Reviewer: samesch -->
<book xml:id="book.bc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<?phpdoc extension-membership="bundled" ?>
<title>BCMath Rechnen mit beliebiger Genauigkeit</title>
<titleabbrev>BC Math</titleabbrev>
<!-- {{{ preface -->
<preface xml:id="intro.bc">
&reftitle.intro;
<para>
Für beliebig genaue mathematische Operationen bietet PHP BCMath, das Zahlen
von beliebiger Länge und Genauigkeit mit bis zu
<literal>2147483647</literal> (oder <literal>0x7FFFFFFF</literal>)
Dezimalstellen unterstützt, falls genügend Speicherplatz vorhanden ist,
dargestellt als String.
</para>
<para>
Gültige (d. h. wohlgeformte) BCMath-Zahlen sind Strings, die auf den
regulären Ausdruck <literal>/^[+-]?[0-9]*(\.[0-9]*)?$/</literal> passen.
</para>
<caution>
<para>
Die Übergabe von Werten vom Typ <type>float</type> an eine BCMath-Funktion,
die einen <type>String</type> als Operanden erwartet, funktioniert
aufgrund der Art, wie PHP <type>float</type>-Werte in <type>String</type>s
konvertiert, möglicherweise nicht wie erwartet, nämlich dass der
<type>String</type> u. U. in exponentieller Notation vorliegt (was von
BCMath nicht unterstützt wird), und dass der Dezimaltrenner vor PHP 8.0.0
von der Locale abhängt (wohingegen BCMath immer einen Dezimalpunkt
erwartet).
</para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$num1 = 0; // (string) 0 => '0'
$num2 = -0.000005; // (string) -0.000005 => '-5.05E-6'
echo bcadd($num1, $num2, 6); // => '0.000000'
setlocale(LC_NUMERIC, 'de_DE'); // verwendet ein Dezimalkomma
$num2 = 1.2; // (string) 1.2 => '1,2'
echo bcsub($num1, $num2, 1); // => '0.0'
?>
]]>
</programlisting>
</informalexample>
</caution>
</preface>
<!-- }}} -->
&reference.bc.setup;
&reference.bc.constants;
&reference.bc.reference;
</book>
<!-- 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
-->