@@ -19,10 +19,9 @@ public partial struct Length
19
19
/// <returns>The inverse of this unit as <see cref="ReciprocalLength"/>.</returns>
20
20
public ReciprocalLength Inverse ( )
21
21
{
22
- if ( Meters == 0.0 )
23
- return new ReciprocalLength ( 0.0 , ReciprocalLengthUnit . InverseMeter ) ;
24
-
25
- return new ReciprocalLength ( 1 / Meters , ReciprocalLengthUnit . InverseMeter ) ;
22
+ return Meters == 0.0
23
+ ? new ReciprocalLength ( 0.0 , ReciprocalLengthUnit . InverseMeter )
24
+ : new ReciprocalLength ( 1 / Meters , ReciprocalLengthUnit . InverseMeter ) ;
26
25
}
27
26
28
27
/// <summary>
@@ -262,8 +261,8 @@ public string ToArchitecturalString(int fractionDenominator)
262
261
throw new ArgumentOutOfRangeException ( nameof ( fractionDenominator ) , "Denominator for fractional inch must be greater than zero." ) ;
263
262
}
264
263
265
- var inchTrunc = ( int ) Math . Truncate ( this . Inches ) ;
266
- var numerator = ( int ) Math . Round ( ( this . Inches - inchTrunc ) * fractionDenominator ) ;
264
+ var inchTrunc = ( int ) Math . Truncate ( Inches ) ;
265
+ var numerator = ( int ) Math . Round ( ( Inches - inchTrunc ) * fractionDenominator ) ;
267
266
268
267
if ( numerator == fractionDenominator )
269
268
{
@@ -280,7 +279,7 @@ public string ToArchitecturalString(int fractionDenominator)
280
279
281
280
if ( numerator > 0 )
282
281
{
283
- int greatestCommonDivisor ( int a , int b )
282
+ int GreatestCommonDivisor ( int a , int b )
284
283
{
285
284
while ( a != 0 && b != 0 )
286
285
{
@@ -293,7 +292,7 @@ int greatestCommonDivisor(int a, int b)
293
292
return a | b ;
294
293
}
295
294
296
- int gcd = greatestCommonDivisor ( ( int ) Math . Abs ( numerator ) , fractionDenominator ) ;
295
+ int gcd = GreatestCommonDivisor ( numerator , fractionDenominator ) ;
297
296
298
297
if ( inchPart . Length > 0 )
299
298
{
@@ -305,12 +304,12 @@ int greatestCommonDivisor(int a, int b)
305
304
306
305
inchPart . Append ( '"' ) ;
307
306
308
- if ( this . Feet == 0 )
307
+ if ( Feet == 0 )
309
308
{
310
309
return inchPart . ToString ( ) ;
311
310
}
312
311
313
- return $ "{ this . Feet } ' - { inchPart } ";
312
+ return $ "{ Feet } ' - { inchPart } ";
314
313
}
315
314
}
316
315
}
0 commit comments