@@ -3,20 +3,43 @@ Module: f32
3
3
4
4
Floating point operations and constants for `f32`
5
5
*/
6
+
6
7
// PORT
7
8
8
9
import cmath:: c_float:: * ;
9
10
10
11
type t = f32 ;
11
12
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
+
12
35
/* Const: NaN */
13
- const NaN : f32 = 0.0f32 /0.0f32 ;
36
+ const NaN : f32 = 0.0_f32 /0.0_f32 ;
14
37
15
38
/* Const: infinity */
16
- const infinity: f32 = 1.0f32 /0.0f32 ;
39
+ const infinity: f32 = 1.0_f32 /0.0_f32 ;
17
40
18
41
/* Const: neg_infinity */
19
- const neg_infinity: f32 = -1.0f32 /0.0f32 ;
42
+ const neg_infinity: f32 = -1.0_f32 /0.0_f32 ;
20
43
21
44
/* Predicate: isNaN */
22
45
pure fn isNaN ( f : f32 ) -> bool { f != f }
@@ -98,114 +121,93 @@ mod consts {
98
121
99
122
Archimedes' constant
100
123
*/
101
- const pi: f32 = 3.14159265358979323846264338327950288f32 ;
124
+ const pi: f32 = 3.14159265358979323846264338327950288_f32 ;
102
125
103
126
/*
104
127
Const: frac_pi_2
105
128
106
129
pi/2.0
107
130
*/
108
- const frac_pi_2: f32 = 1.57079632679489661923132169163975144f32 ;
131
+ const frac_pi_2: f32 = 1.57079632679489661923132169163975144_f32 ;
109
132
110
133
/*
111
134
Const: frac_pi_4
112
135
113
136
pi/4.0
114
137
*/
115
- const frac_pi_4: f32 = 0.785398163397448309615660845819875721f32 ;
138
+ const frac_pi_4: f32 = 0.785398163397448309615660845819875721_f32 ;
116
139
117
140
/*
118
141
Const: frac_1_pi
119
142
120
143
1.0/pi
121
144
*/
122
- const frac_1_pi: f32 = 0.318309886183790671537767526745028724f32 ;
145
+ const frac_1_pi: f32 = 0.318309886183790671537767526745028724_f32 ;
123
146
124
147
/*
125
148
Const: frac_2_pi
126
149
127
150
2.0/pi
128
151
*/
129
- const frac_2_pi: f32 = 0.636619772367581343075535053490057448f32 ;
152
+ const frac_2_pi: f32 = 0.636619772367581343075535053490057448_f32 ;
130
153
131
154
/*
132
155
Const: frac_2_sqrtpi
133
156
134
157
2.0/sqrt(pi)
135
158
*/
136
- const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517f32 ;
159
+ const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517_f32 ;
137
160
138
161
/*
139
162
Const: sqrt2
140
163
141
164
sqrt(2.0)
142
165
*/
143
- const sqrt2: f32 = 1.41421356237309504880168872420969808f32 ;
166
+ const sqrt2: f32 = 1.41421356237309504880168872420969808_f32 ;
144
167
145
168
/*
146
169
Const: frac_1_sqrt2
147
170
148
171
1.0/sqrt(2.0)
149
172
*/
150
- const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039f32 ;
173
+ const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039_f32 ;
151
174
152
175
/*
153
176
Const: e
154
177
155
178
Euler's number
156
179
*/
157
- const e: f32 = 2.71828182845904523536028747135266250f32 ;
180
+ const e: f32 = 2.71828182845904523536028747135266250_f32 ;
158
181
159
182
/*
160
183
Const: log2_e
161
184
162
185
log2(e)
163
186
*/
164
- const log2_e: f32 = 1.44269504088896340735992468100189214f32 ;
187
+ const log2_e: f32 = 1.44269504088896340735992468100189214_f32 ;
165
188
166
189
/*
167
190
Const: log10_e
168
191
169
192
log10(e)
170
193
*/
171
- const log10_e: f32 = 0.434294481903251827651128918916605082f32 ;
194
+ const log10_e: f32 = 0.434294481903251827651128918916605082_f32 ;
172
195
173
196
/*
174
197
Const: ln_2
175
198
176
199
ln(2.0)
177
200
*/
178
- const ln_2: f32 = 0.693147180559945309417232121458176568f32 ;
201
+ const ln_2: f32 = 0.693147180559945309417232121458176568_f32 ;
179
202
180
203
/*
181
204
Const: ln_10
182
205
183
206
ln(10.0)
184
207
*/
185
- const ln_10: f32 = 2.30258509299404568401799145468436421f32 ;
208
+ const ln_10: f32 = 2.30258509299404568401799145468436421_f32 ;
186
209
}
187
210
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
-
209
211
//
210
212
// Local Variables:
211
213
// mode: rust
0 commit comments