@@ -18,22 +18,19 @@ namespace IronPython.Runtime.Operations {
1818 // generated by function: gen_float from: generate_alltypes.py
1919
2020 public static partial class SingleOps {
21- // Unary Operations
21+
22+ #region Unary Operations
23+
2224 [ SpecialName ]
23- public static Single Plus ( Single x ) {
24- return x ;
25- }
25+ public static Single Plus ( Single x ) => x ;
26+
2627 [ SpecialName ]
27- public static Single Negate ( Single x ) {
28- return ( Single ) ( - ( x ) ) ;
29- }
28+ public static Single Negate ( Single x ) => ( Single ) ( - ( x ) ) ;
29+
3030 [ SpecialName ]
31- public static Single Abs ( Single x ) {
32- return ( Single ) ( Math . Abs ( x ) ) ;
33- }
34- public static bool __bool__ ( Single x ) {
35- return ( x != 0 ) ;
36- }
31+ public static Single Abs ( Single x ) => ( Single ) ( Math . Abs ( x ) ) ;
32+
33+ public static bool __bool__ ( Single x ) => ( x != 0 ) ;
3734
3835 public static object __trunc__ ( Single x ) {
3936 if ( x >= int . MaxValue || x <= int . MinValue ) {
@@ -43,123 +40,137 @@ public static object __trunc__(Single x) {
4340 }
4441 }
4542
46- // Binary Operations - Arithmetic
43+ #endregion
44+
45+ #region Binary Operations - Arithmetic
46+
4747 [ SpecialName ]
4848 public static Single Add ( Single x , Single y ) {
4949 return x + y ;
5050 }
51+
5152 [ SpecialName ]
5253 public static Single Subtract ( Single x , Single y ) {
5354 return x - y ;
5455 }
56+
5557 [ SpecialName ]
5658 public static Single Multiply ( Single x , Single y ) {
5759 return x * y ;
5860 }
61+
5962 [ SpecialName ]
6063 public static Single TrueDivide ( Single x , Single y ) {
6164 if ( y == 0 ) throw PythonOps . ZeroDivisionError ( ) ;
6265 return x / y ;
6366 }
67+
6468 [ SpecialName ]
6569 public static Single FloorDivide ( Single x , Single y ) {
6670 if ( y == 0 ) throw PythonOps . ZeroDivisionError ( ) ;
6771 return ( Single ) Math . Floor ( x / y ) ;
6872 }
6973
70- // Conversion operators
74+ #endregion
75+
76+ #region Conversion operators
77+
7178 [ SpecialName , ExplicitConversionMethod ]
7279 public static SByte ConvertToSByte ( Single x ) {
7380 if ( SByte . MinValue <= x && x <= SByte . MaxValue ) {
7481 return ( SByte ) x ;
7582 }
7683 throw Converter . CannotConvertOverflow ( "SByte" , x ) ;
7784 }
85+
7886 [ SpecialName , ExplicitConversionMethod ]
7987 public static Byte ConvertToByte ( Single x ) {
8088 if ( Byte . MinValue <= x && x <= Byte . MaxValue ) {
8189 return ( Byte ) x ;
8290 }
8391 throw Converter . CannotConvertOverflow ( "Byte" , x ) ;
8492 }
93+
8594 [ SpecialName , ExplicitConversionMethod ]
8695 public static Int16 ConvertToInt16 ( Single x ) {
8796 if ( Int16 . MinValue <= x && x <= Int16 . MaxValue ) {
8897 return ( Int16 ) x ;
8998 }
9099 throw Converter . CannotConvertOverflow ( "Int16" , x ) ;
91100 }
101+
92102 [ SpecialName , ExplicitConversionMethod ]
93103 public static UInt16 ConvertToUInt16 ( Single x ) {
94104 if ( UInt16 . MinValue <= x && x <= UInt16 . MaxValue ) {
95105 return ( UInt16 ) x ;
96106 }
97107 throw Converter . CannotConvertOverflow ( "UInt16" , x ) ;
98108 }
109+
99110 [ SpecialName , ExplicitConversionMethod ]
100111 public static Int32 ConvertToInt32 ( Single x ) {
101112 if ( Int32 . MinValue <= x && x <= Int32 . MaxValue ) {
102113 return ( Int32 ) x ;
103114 }
104115 throw Converter . CannotConvertOverflow ( "Int32" , x ) ;
105116 }
117+
106118 [ SpecialName , ExplicitConversionMethod ]
107119 public static UInt32 ConvertToUInt32 ( Single x ) {
108120 if ( UInt32 . MinValue <= x && x <= UInt32 . MaxValue ) {
109121 return ( UInt32 ) x ;
110122 }
111123 throw Converter . CannotConvertOverflow ( "UInt32" , x ) ;
112124 }
125+
113126 [ SpecialName , ExplicitConversionMethod ]
114127 public static Int64 ConvertToInt64 ( Single x ) {
115128 if ( Int64 . MinValue <= x && x <= Int64 . MaxValue ) {
116129 return ( Int64 ) x ;
117130 }
118131 throw Converter . CannotConvertOverflow ( "Int64" , x ) ;
119132 }
133+
120134 [ SpecialName , ExplicitConversionMethod ]
121135 public static UInt64 ConvertToUInt64 ( Single x ) {
122136 if ( UInt64 . MinValue <= x && x <= UInt64 . MaxValue ) {
123137 return ( UInt64 ) x ;
124138 }
125139 throw Converter . CannotConvertOverflow ( "UInt64" , x ) ;
126140 }
141+
127142 [ SpecialName , ImplicitConversionMethod ]
128- public static Double ConvertToDouble ( Single x ) {
129- return ( Double ) x ;
130- }
143+ public static Double ConvertToDouble ( Single x ) => ( Double ) x ;
144+
145+ #endregion
146+
147+ #region Public API - Numerics
131148
132- // Public API - Numerics
133149 [ PropertyMethod , SpecialName ]
134- public static Single Getreal ( Single x ) {
135- return x ;
136- }
150+ public static Single Getreal ( Single x ) => x ;
151+
137152 [ PropertyMethod , SpecialName ]
138- public static Single Getimag ( Single x ) {
139- return ( Single ) 0 ;
140- }
141- public static Single conjugate ( Single x ) {
142- return x ;
143- }
153+ public static Single Getimag ( Single x ) => ( Single ) 0 ;
154+
155+ public static Single conjugate ( Single x ) => x ;
156+
157+ #endregion
144158 }
145159
146160 public static partial class DoubleOps {
147- // Unary Operations
161+
162+ #region Unary Operations
163+
148164 [ SpecialName ]
149- public static Double Plus ( Double x ) {
150- return x ;
151- }
165+ public static Double Plus ( Double x ) => x ;
166+
152167 [ SpecialName ]
153- public static Double Negate ( Double x ) {
154- return ( Double ) ( - ( x ) ) ;
155- }
168+ public static Double Negate ( Double x ) => ( Double ) ( - ( x ) ) ;
169+
156170 [ SpecialName ]
157- public static Double Abs ( Double x ) {
158- return ( Double ) ( Math . Abs ( x ) ) ;
159- }
160- public static bool __bool__ ( Double x ) {
161- return ( x != 0 ) ;
162- }
171+ public static Double Abs ( Double x ) => ( Double ) ( Math . Abs ( x ) ) ;
172+
173+ public static bool __bool__ ( Double x ) => ( x != 0 ) ;
163174
164175 public static object __trunc__ ( Double x ) {
165176 if ( x >= int . MaxValue || x <= int . MinValue ) {
@@ -169,104 +180,121 @@ public static object __trunc__(Double x) {
169180 }
170181 }
171182
172- // Binary Operations - Arithmetic
183+ #endregion
184+
185+ #region Binary Operations - Arithmetic
186+
173187 [ SpecialName ]
174188 public static Double Add ( Double x , Double y ) {
175189 return x + y ;
176190 }
191+
177192 [ SpecialName ]
178193 public static Double Subtract ( Double x , Double y ) {
179194 return x - y ;
180195 }
196+
181197 [ SpecialName ]
182198 public static Double Multiply ( Double x , Double y ) {
183199 return x * y ;
184200 }
201+
185202 [ SpecialName ]
186203 public static Double TrueDivide ( Double x , Double y ) {
187204 if ( y == 0 ) throw PythonOps . ZeroDivisionError ( ) ;
188205 return x / y ;
189206 }
207+
190208 [ SpecialName ]
191209 public static Double FloorDivide ( Double x , Double y ) {
192210 if ( y == 0 ) throw PythonOps . ZeroDivisionError ( ) ;
193211 return ( Double ) Math . Floor ( x / y ) ;
194212 }
195213
196- // Conversion operators
214+ #endregion
215+
216+ #region Conversion operators
217+
197218 [ SpecialName , ExplicitConversionMethod ]
198219 public static SByte ConvertToSByte ( Double x ) {
199220 if ( SByte . MinValue <= x && x <= SByte . MaxValue ) {
200221 return ( SByte ) x ;
201222 }
202223 throw Converter . CannotConvertOverflow ( "SByte" , x ) ;
203224 }
225+
204226 [ SpecialName , ExplicitConversionMethod ]
205227 public static Byte ConvertToByte ( Double x ) {
206228 if ( Byte . MinValue <= x && x <= Byte . MaxValue ) {
207229 return ( Byte ) x ;
208230 }
209231 throw Converter . CannotConvertOverflow ( "Byte" , x ) ;
210232 }
233+
211234 [ SpecialName , ExplicitConversionMethod ]
212235 public static Int16 ConvertToInt16 ( Double x ) {
213236 if ( Int16 . MinValue <= x && x <= Int16 . MaxValue ) {
214237 return ( Int16 ) x ;
215238 }
216239 throw Converter . CannotConvertOverflow ( "Int16" , x ) ;
217240 }
241+
218242 [ SpecialName , ExplicitConversionMethod ]
219243 public static UInt16 ConvertToUInt16 ( Double x ) {
220244 if ( UInt16 . MinValue <= x && x <= UInt16 . MaxValue ) {
221245 return ( UInt16 ) x ;
222246 }
223247 throw Converter . CannotConvertOverflow ( "UInt16" , x ) ;
224248 }
249+
225250 [ SpecialName , ExplicitConversionMethod ]
226251 public static Int32 ConvertToInt32 ( Double x ) {
227252 if ( Int32 . MinValue <= x && x <= Int32 . MaxValue ) {
228253 return ( Int32 ) x ;
229254 }
230255 throw Converter . CannotConvertOverflow ( "Int32" , x ) ;
231256 }
257+
232258 [ SpecialName , ExplicitConversionMethod ]
233259 public static UInt32 ConvertToUInt32 ( Double x ) {
234260 if ( UInt32 . MinValue <= x && x <= UInt32 . MaxValue ) {
235261 return ( UInt32 ) x ;
236262 }
237263 throw Converter . CannotConvertOverflow ( "UInt32" , x ) ;
238264 }
265+
239266 [ SpecialName , ExplicitConversionMethod ]
240267 public static Int64 ConvertToInt64 ( Double x ) {
241268 if ( Int64 . MinValue <= x && x <= Int64 . MaxValue ) {
242269 return ( Int64 ) x ;
243270 }
244271 throw Converter . CannotConvertOverflow ( "Int64" , x ) ;
245272 }
273+
246274 [ SpecialName , ExplicitConversionMethod ]
247275 public static UInt64 ConvertToUInt64 ( Double x ) {
248276 if ( UInt64 . MinValue <= x && x <= UInt64 . MaxValue ) {
249277 return ( UInt64 ) x ;
250278 }
251279 throw Converter . CannotConvertOverflow ( "UInt64" , x ) ;
252280 }
281+
253282 [ SpecialName , ImplicitConversionMethod ]
254- public static Single ConvertToSingle ( Double x ) {
255- return ( Single ) x ;
256- }
283+ public static Single ConvertToSingle ( Double x ) => ( Single ) x ;
284+
285+ #endregion
286+
287+ #region Public API - Numerics
257288
258- // Public API - Numerics
259289 [ PropertyMethod , SpecialName ]
260- public static Double Getreal ( Double x ) {
261- return x ;
262- }
290+ public static Double Getreal ( Double x ) => x ;
291+
263292 [ PropertyMethod , SpecialName ]
264- public static Double Getimag ( Double x ) {
265- return ( Double ) 0 ;
266- }
267- public static Double conjugate ( Double x ) {
268- return x ;
269- }
293+ public static Double Getimag ( Double x ) => ( Double ) 0 ;
294+
295+ public static Double conjugate ( Double x ) => x ;
296+
297+ #endregion
270298 }
271299
272300
0 commit comments