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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>2002</year>
<year>2016</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
The Initial Developer of the Original Code is Ericsson AB.
</legalnotice>
<title>fixed</title>
<prepared></prepared>
<responsible></responsible>
<docno></docno>
<approved></approved>
<checked></checked>
<date>2002-05-22</date>
<rev>A</rev>
</header>
<module>fixed</module>
<modulesummary>the corba fixed type</modulesummary>
<description>
<p>This module contains functions that gives an interface to the CORBA fixed type.</p>
<p>The type <c>Fixed</c> used below is defined as:</p>
<code type="none">
-record(fixed, {digits, scale, value}).
</code>
<p>where <c>digits</c> is the total amount of digits it consists of and
<c>scale</c> is the number of fractional digits. The <c>value</c> field
contains the actual Fixed value represented as an integer. The limitations
of each field are:</p>
<list type="bulleted">
<item>Digits - integer(), -1 > Digits < 32</item>
<item>Scale - integer(), -1 > Scale =< Digits</item>
<item>Value - integer(), range (31 digits): ±9999999999999999999999999999999</item>
</list>
<p>Since the Value part is represented by an integer, it is vital that the
Digits and Scale values are correct. This also means that trailing zeros
cannot be left out in some cases:</p>
<list type="bulleted">
<item>fixed<5,3> eq. 03.140d eq. 3140</item>
<item>fixed<3,2> eq. 3.14d eq. 314</item>
</list>
<p>Leading zeros can be left out.</p>
<p>For your convenience, this module exports functions which handle
unary (<c>-</c>) and binary (<c>+-*/</c>) operations legal for the Fixed type.
Since a unary <c>+</c> have no effect, this module do not export such a
function. Any of the binary operations may cause an overflow (i.e. more than
31 significant digits; leading and trailing zeros are not considered
significant). If this is the case, the Digit and Scale values are adjusted
and the Value truncated (no rounding performed). This behavior is
compliant with the OMG CORBA specification. Each binary operation have
the following upper bounds:</p>
<list type="bulleted">
<item><em>Fixed1 + Fixed2</em> - <c><![CDATA[fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>]]></c></item>
<item><em>Fixed1 - Fixed2</em> - <c><![CDATA[fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>]]></c></item>
<item><em>Fixed1 * Fixed2</em> - <c><![CDATA[fixed<d1+d2, s1+s2>]]></c></item>
<item><em>Fixed1 / Fixed2</em> - <c><![CDATA[fixed<(d1-s1+s2) + Sinf ,Sinf >]]></c></item>
</list>
<p>A quotient may have an arbitrary number of decimal places, which is
denoted by a scale of Sinf.</p>
</description>
<funcs>
<func>
<name>create(Digits, Scale, Value) -> Result</name>
<fsummary>Create a fixed type</fsummary>
<type>
<v>Result = Fixed Type | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>This function creates a new instance of a <c>Fixed Type</c>. If
the limitations is not fulfilled (e.g. overflow) an exception is
raised.</p>
</desc>
</func>
<func>
<name>get_typecode(Fixed) -> Result</name>
<fsummary>Create TypeCode representing the supplied fixed type</fsummary>
<type>
<v>Result = TypeCode | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Returns the TypeCode which represents the supplied Fixed type.
If the parameter is not of the correct type, an exception is raised.</p>
</desc>
</func>
<func>
<name>add(Fixed1, Fixed2) -> Result</name>
<fsummary>Add the supplied Fixed types</fsummary>
<type>
<v>Result = Fixed1 + Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Performs a Fixed type addition.
If the parameters are not of the correct type, an exception is raised.</p>
</desc>
</func>
<func>
<name>subtract(Fixed1, Fixed2) -> Result</name>
<fsummary>Subtract Fixed2 from Fixed1</fsummary>
<type>
<v>Result = Fixed1 - Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Performs a Fixed type subtraction.
If the parameters are not of the correct type, an exception is raised.</p>
</desc>
</func>
<func>
<name>multiply(Fixed1, Fixed2) -> Result</name>
<fsummary>Multiply Fixed1 with Fixed2</fsummary>
<type>
<v>Result = Fixed1 * Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Performs a Fixed type multiplication.
If the parameters are not of the correct type, an exception is raised.</p>
</desc>
</func>
<func>
<name>divide(Fixed1, Fixed2) -> Result</name>
<fsummary>Divide Fixed1 with Fixed2</fsummary>
<type>
<v>Result = Fixed1 / Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Performs a Fixed type division.
If the parameters are not of the correct type, an exception is raised.</p>
</desc>
</func>
<func>
<name>unary_minus(Fixed) -> Result</name>
<fsummary>Negate the supplied Fixed Type</fsummary>
<type>
<v>Result = -Fixed | {'EXCEPTION', #'BAD_PARAM'{}}</v>
</type>
<desc>
<p>Negates the supplied Fixed type.
If the parameter is not of the correct type, an exception is raised.</p>
</desc>
</func>
</funcs>
</erlref>
|