1fixed(3) Erlang Module Definition fixed(3)
2
3
4
6 fixed - the corba fixed type
7
9 This module contains functions that gives an interface to the CORBA
10 fixed type.
11
12 The type Fixed used below is defined as:
13
14 -record(fixed, {digits, scale, value}).
15
16
17 where digits is the total amount of digits it consists of and scale is
18 the number of fractional digits. The value field contains the actual
19 Fixed value represented as an integer. The limitations of each field
20 are:
21
22 * Digits - integer(), -1 > Digits < 32
23
24 * Scale - integer(), -1 > Scale =< Digits
25
26 * Value - integer(), range (31 digits):
27 +/-9999999999999999999999999999999
28
29 Since the Value part is represented by an integer, it is vital that the
30 Digits and Scale values are correct. This also means that trailing ze‐
31 ros cannot be left out in some cases:
32
33 * fixed<5,3> eq. 03.140d eq. 3140
34
35 * fixed<3,2> eq. 3.14d eq. 314
36
37 Leading zeros can be left out.
38
39 For your convenience, this module exports functions which handle unary
40 (-) and binary (+-*/) operations legal for the Fixed type. Since a
41 unary + have no effect, this module do not export such a function. Any
42 of the binary operations may cause an overflow (i.e. more than 31 sig‐
43 nificant digits; leading and trailing zeros are not considered signifi‐
44 cant). If this is the case, the Digit and Scale values are adjusted and
45 the Value truncated (no rounding performed). This behavior is compliant
46 with the OMG CORBA specification. Each binary operation have the fol‐
47 lowing upper bounds:
48
49 * Fixed1 + Fixed2 - fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1,
50 max(s1,s2)>
51
52 * Fixed1 - Fixed2 - fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1,
53 max(s1,s2)>
54
55 * Fixed1 * Fixed2 - fixed<d1+d2, s1+s2>
56
57 * Fixed1 / Fixed2 - fixed<(d1-s1+s2) + Sinf ,Sinf >
58
59 A quotient may have an arbitrary number of decimal places, which is de‐
60 noted by a scale of Sinf.
61
63 create(Digits, Scale, Value) -> Result
64
65 Types:
66
67 Result = Fixed Type | {'EXCEPTION', #'BAD_PARAM'{}}
68
69 This function creates a new instance of a Fixed Type. If the
70 limitations is not fulfilled (e.g. overflow) an exception is
71 raised.
72
73 get_typecode(Fixed) -> Result
74
75 Types:
76
77 Result = TypeCode | {'EXCEPTION', #'BAD_PARAM'{}}
78
79 Returns the TypeCode which represents the supplied Fixed type.
80 If the parameter is not of the correct type, an exception is
81 raised.
82
83 add(Fixed1, Fixed2) -> Result
84
85 Types:
86
87 Result = Fixed1 + Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}
88
89 Performs a Fixed type addition. If the parameters are not of the
90 correct type, an exception is raised.
91
92 subtract(Fixed1, Fixed2) -> Result
93
94 Types:
95
96 Result = Fixed1 - Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}
97
98 Performs a Fixed type subtraction. If the parameters are not of
99 the correct type, an exception is raised.
100
101 multiply(Fixed1, Fixed2) -> Result
102
103 Types:
104
105 Result = Fixed1 * Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}
106
107 Performs a Fixed type multiplication. If the parameters are not
108 of the correct type, an exception is raised.
109
110 divide(Fixed1, Fixed2) -> Result
111
112 Types:
113
114 Result = Fixed1 / Fixed2 | {'EXCEPTION', #'BAD_PARAM'{}}
115
116 Performs a Fixed type division. If the parameters are not of the
117 correct type, an exception is raised.
118
119 unary_minus(Fixed) -> Result
120
121 Types:
122
123 Result = -Fixed | {'EXCEPTION', #'BAD_PARAM'{}}
124
125 Negates the supplied Fixed type. If the parameter is not of the
126 correct type, an exception is raised.
127
128
129
130Ericsson AB orber 5.0.1 fixed(3)