@@ -3,20 +3,43 @@ Module: f32
33
44Floating point operations and constants for `f32`
55*/
6+
67// PORT
78
89import cmath:: c_float:: * ;
910
1011type t = f32 ;
1112
13+
14+ // These are not defined inside consts:: for consistency with
15+ // the integer types
16+
17+ // PORT check per architecture
18+
19+ const radix: uint = 2 u;
20+
21+ const mantissa_digits: uint = 24 u;
22+ const digits: uint = 6 u;
23+
24+ const epsilon: f32 = 1.19209290e-07_f32 ;
25+
26+ const min_value: f32 = 1.17549435e-38_f32 ;
27+ const max_value: f32 = 3.40282347e+38_f32 ;
28+
29+ const min_exp: int = -125 ;
30+ const max_exp: int = 128 ;
31+
32+ const min_10_exp: int = -37 ;
33+ const max_10_exp: int = 38 ;
34+
1235/* Const: NaN */
13- const NaN : f32 = 0.0f32 /0.0f32 ;
36+ const NaN : f32 = 0.0_f32 /0.0_f32 ;
1437
1538/* Const: infinity */
16- const infinity: f32 = 1.0f32 /0.0f32 ;
39+ const infinity: f32 = 1.0_f32 /0.0_f32 ;
1740
1841/* Const: neg_infinity */
19- const neg_infinity: f32 = -1.0f32 /0.0f32 ;
42+ const neg_infinity: f32 = -1.0_f32 /0.0_f32 ;
2043
2144/* Predicate: isNaN */
2245pure fn isNaN ( f : f32 ) -> bool { f != f }
@@ -98,114 +121,93 @@ mod consts {
98121
99122 Archimedes' constant
100123 */
101- const pi: f32 = 3.14159265358979323846264338327950288f32 ;
124+ const pi: f32 = 3.14159265358979323846264338327950288_f32 ;
102125
103126 /*
104127 Const: frac_pi_2
105128
106129 pi/2.0
107130 */
108- const frac_pi_2: f32 = 1.57079632679489661923132169163975144f32 ;
131+ const frac_pi_2: f32 = 1.57079632679489661923132169163975144_f32 ;
109132
110133 /*
111134 Const: frac_pi_4
112135
113136 pi/4.0
114137 */
115- const frac_pi_4: f32 = 0.785398163397448309615660845819875721f32 ;
138+ const frac_pi_4: f32 = 0.785398163397448309615660845819875721_f32 ;
116139
117140 /*
118141 Const: frac_1_pi
119142
120143 1.0/pi
121144 */
122- const frac_1_pi: f32 = 0.318309886183790671537767526745028724f32 ;
145+ const frac_1_pi: f32 = 0.318309886183790671537767526745028724_f32 ;
123146
124147 /*
125148 Const: frac_2_pi
126149
127150 2.0/pi
128151 */
129- const frac_2_pi: f32 = 0.636619772367581343075535053490057448f32 ;
152+ const frac_2_pi: f32 = 0.636619772367581343075535053490057448_f32 ;
130153
131154 /*
132155 Const: frac_2_sqrtpi
133156
134157 2.0/sqrt(pi)
135158 */
136- const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517f32 ;
159+ const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517_f32 ;
137160
138161 /*
139162 Const: sqrt2
140163
141164 sqrt(2.0)
142165 */
143- const sqrt2: f32 = 1.41421356237309504880168872420969808f32 ;
166+ const sqrt2: f32 = 1.41421356237309504880168872420969808_f32 ;
144167
145168 /*
146169 Const: frac_1_sqrt2
147170
148171 1.0/sqrt(2.0)
149172 */
150- const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039f32 ;
173+ const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039_f32 ;
151174
152175 /*
153176 Const: e
154177
155178 Euler's number
156179 */
157- const e: f32 = 2.71828182845904523536028747135266250f32 ;
180+ const e: f32 = 2.71828182845904523536028747135266250_f32 ;
158181
159182 /*
160183 Const: log2_e
161184
162185 log2(e)
163186 */
164- const log2_e: f32 = 1.44269504088896340735992468100189214f32 ;
187+ const log2_e: f32 = 1.44269504088896340735992468100189214_f32 ;
165188
166189 /*
167190 Const: log10_e
168191
169192 log10(e)
170193 */
171- const log10_e: f32 = 0.434294481903251827651128918916605082f32 ;
194+ const log10_e: f32 = 0.434294481903251827651128918916605082_f32 ;
172195
173196 /*
174197 Const: ln_2
175198
176199 ln(2.0)
177200 */
178- const ln_2: f32 = 0.693147180559945309417232121458176568f32 ;
201+ const ln_2: f32 = 0.693147180559945309417232121458176568_f32 ;
179202
180203 /*
181204 Const: ln_10
182205
183206 ln(10.0)
184207 */
185- const ln_10: f32 = 2.30258509299404568401799145468436421f32 ;
208+ const ln_10: f32 = 2.30258509299404568401799145468436421_f32 ;
186209}
187210
188- // These are not defined inside consts:: for consistency with
189- // the integer types
190-
191- // PORT check per architecture
192-
193- const radix: uint = 2 u;
194-
195- const mantissa_digits: uint = 24 u;
196- const digits: uint = 6 u;
197-
198- const epsilon: f32 = 1.19209290e-07f32 ;
199-
200- const min_value: f32 = 1.17549435e-38f32 ;
201- const max_value: f32 = 3.40282347e+38f32 ;
202-
203- const min_exp: int = -125 ;
204- const max_exp: int = 128 ;
205-
206- const min_10_exp: int = -37 ;
207- const max_10_exp: int = 38 ;
208-
209211//
210212// Local Variables:
211213// mode: rust
0 commit comments