• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 15871875705

25 Jun 2025 08:53AM UTC coverage: 75.377% (-0.3%) from 75.67%
15871875705

push

github

web-flow
Merge pull request #663 from DomCR/dimension-text

Dimension Text

5830 of 8531 branches covered (68.34%)

Branch coverage included in aggregate %.

259 of 419 new or added lines in 9 files covered. (61.81%)

26 existing lines in 2 files now uncovered.

23237 of 30031 relevant lines covered (77.38%)

82092.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

49.05
/src/ACadSharp/Types/Units/UnitStyleFormat.cs
1
using ACadSharp.Tables;
2
using CSMath;
3
using System;
4
using System.Globalization;
5
using System.Text;
6

7
namespace ACadSharp.Types.Units
8
{
9
        /// <summary>
10
        /// Represents the parameters to convert linear and angular units to its string representation.
11
        /// </summary>
12
        public class UnitStyleFormat
13
        {
14
                /// <summary>
15
                /// Gets or sets the number of decimal places for angular units.
16
                /// </summary>
17
                public short AngularDecimalPlaces
18
                {
19
                        get { return this._angularDecimalPlaces; }
3✔
20
                        set
21
                        {
9✔
22
                                if (value < 0)
9!
NEW
23
                                {
×
NEW
24
                                        throw new ArgumentOutOfRangeException(nameof(value), value, "The number of decimal places must be equals or greater than zero.");
×
25
                                }
26
                                this._angularDecimalPlaces = value;
9✔
27
                        }
9✔
28
                }
29

30
                /// <summary>
31
                /// Gets or sets the suppression of zeros in the angular values.
32
                /// </summary>
33
                public ZeroHandling AngularZeroHandling { get; set; } = ZeroHandling.SuppressDecimalTrailingZeroes;
22✔
34

35
                /// <summary>
36
                /// Gets or set the decimal separator.
37
                /// </summary>
38
                public string DecimalSeparator { get; set; }
31✔
39

40
                /// <summary>
41
                /// Gets or set the angle degrees symbol.
42
                /// </summary>
43
                public string DegreesSymbol { get; set; }
11✔
44

45
                /// <summary>
46
                /// Gets or sets the separator between feet and inches.
47
                /// </summary>
48
                public string FeetInchesSeparator { get; set; }
11✔
49

50
                /// <summary>
51
                /// Gets or set the feet symbol.
52
                /// </summary>
53
                public string FeetSymbol { get; set; }
11✔
54

55
                /// <summary>
56
                /// Gets or sets the scale of fractions relative to dimension text height.
57
                /// </summary>
58
                public double FractionHeightScale
59
                {
60
                        get { return this._fractionHeightScale; }
3✔
61
                        set
62
                        {
9✔
63
                                if (value <= 0)
9!
NEW
64
                                {
×
NEW
65
                                        throw new ArgumentOutOfRangeException(nameof(value), value, "The fraction height scale must be greater than zero.");
×
66
                                }
67
                                this._fractionHeightScale = value;
9✔
68
                        }
9✔
69
                }
70

71
                /// <summary>
72
                /// Gets or sets the fraction format for architectural or fractional units.
73
                /// </summary>
74
                /// <remarks>
75
                /// Horizontal stacking<br/>
76
                /// Diagonal stacking<br/>
77
                /// Not stacked (for example, 1/2)
78
                /// </remarks>
79
                public FractionFormat FractionType { get; set; }
22✔
80

81
                /// <summary>
82
                /// Gets or set the angle gradians symbol.
83
                /// </summary>
84
                public string GradiansSymbol { get; set; }
11✔
85

86
                /// <summary>
87
                /// Gets or set the inches symbol.
88
                /// </summary>
89
                public string InchesSymbol { get; set; }
11✔
90

91
                /// <summary>
92
                /// Gets or sets the number of decimal places for linear units.
93
                /// </summary>
94
                /// <remarks>
95
                /// For architectural and fractional the precision used for the minimum fraction is 1/2^LinearDecimalPlaces.
96
                /// </remarks>
97
                public short LinearDecimalPlaces
98
                {
99
                        get { return this._linearDecimalPlaces; }
36✔
100
                        set
101
                        {
13✔
102
                                if (value < 0)
13!
NEW
103
                                {
×
NEW
104
                                        throw new ArgumentOutOfRangeException(nameof(value), value, "The number of decimal places must be equals or greater than zero.");
×
105
                                }
106
                                this._linearDecimalPlaces = value;
13✔
107
                        }
13✔
108
                }
109

110
                /// <summary>
111
                /// Gets or sets the suppression of zeros in the linear values.
112
                /// </summary>
113
                public ZeroHandling LinearZeroHandling { get; set; } = ZeroHandling.SuppressDecimalTrailingZeroes;
31✔
114

115
                /// <summary>
116
                /// Gets or set the angle minutes symbol.
117
                /// </summary>
118
                public string MinutesSymbol { get; set; }
10✔
119

120
                /// <summary>
121
                /// Gets or set the angle radians symbol.
122
                /// </summary>
123
                public string RadiansSymbol { get; set; }
11✔
124

125
                /// <summary>
126
                /// Gets or set the angle seconds symbol.
127
                /// </summary>
128
                public string SecondsSymbol { get; set; }
10✔
129

130
                /// <summary>
131
                /// Suppresses leading zeros in angular decimal dimensions (for example, 0.5000 becomes .5000).
132
                /// </summary>
133
                public bool SuppressAngularLeadingZeros
134
                {
135
                        get
NEW
136
                        {
×
NEW
137
                                return this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingZeroes
×
NEW
138
                                        || this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes;
×
NEW
139
                        }
×
140
                }
141

142
                /// <summary>
143
                /// Suppresses trailing zeros in angular decimal dimensions (for example, 12.5000 becomes 12.5).
144
                /// </summary>
145
                public bool SuppressAngularTrailingZeros
146
                {
147
                        get
NEW
148
                        {
×
NEW
149
                                return this.LinearZeroHandling == ZeroHandling.SuppressDecimalTrailingZeroes
×
NEW
150
                                        || this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes;
×
NEW
151
                        }
×
152
                }
153

154
                /// <summary>
155
                /// Suppresses leading zeros in linear decimal dimensions (for example, 0.5000 becomes .5000).
156
                /// </summary>
157
                public bool SuppressLinearLeadingZeros
158
                {
159
                        get
NEW
160
                        {
×
NEW
161
                                return this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingZeroes
×
NEW
162
                                        || this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes;
×
NEW
163
                        }
×
164
                }
165

166
                /// <summary>
167
                /// Suppresses trailing zeros in linear decimal dimensions (for example, 12.5000 becomes 12.5).
168
                /// </summary>
169
                public bool SuppressLinearTrailingZeros
170
                {
171
                        get
NEW
172
                        {
×
NEW
173
                                return this.LinearZeroHandling == ZeroHandling.SuppressDecimalTrailingZeroes
×
NEW
174
                                        || this.LinearZeroHandling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes;
×
NEW
175
                        }
×
176
                }
177

178
                /// <summary>
179
                /// Suppresses zero feet in architectural dimensions.
180
                /// </summary>
181
                public bool SuppressZeroFeet
182
                {
183
                        get
184
                        {
1✔
185
                                return this.LinearZeroHandling == ZeroHandling.SuppressZeroFeetAndInches
1!
186
                                        || this.LinearZeroHandling == ZeroHandling.SuppressZeroFeetShowZeroInches;
1✔
187
                        }
1✔
188
                }
189

190
                /// <summary>
191
                /// Suppresses zero inches in architectural dimensions.
192
                /// </summary>
193
                public bool SuppressZeroInches
194
                {
195
                        get
NEW
196
                        {
×
NEW
197
                                return this.LinearZeroHandling == ZeroHandling.SuppressZeroFeetAndInches
×
NEW
198
                                        || this.LinearZeroHandling == ZeroHandling.ShowZeroFeetSuppressZeroInches;
×
NEW
199
                        }
×
200
                }
201

202
                private short _angularDecimalPlaces;
203

204
                private double _fractionHeightScale;
205

206
                private short _linearDecimalPlaces;
207

208
                /// <summary>
209
                /// Initializes a new instance of the <c>UnitStyleFormat</c> class.
210
                /// </summary>
211
                public UnitStyleFormat()
10✔
212
                {
10✔
213
                        this._linearDecimalPlaces = 2;
10✔
214
                        this._angularDecimalPlaces = 0;
10✔
215
                        this.DecimalSeparator = ".";
10✔
216
                        this.FeetInchesSeparator = "-";
10✔
217
                        this.DegreesSymbol = "°";
10✔
218
                        this.MinutesSymbol = "\'";
10✔
219
                        this.SecondsSymbol = "\"";
10✔
220
                        this.RadiansSymbol = "r";
10✔
221
                        this.GradiansSymbol = "g";
10✔
222
                        this.FeetSymbol = "\'";
10✔
223
                        this.InchesSymbol = "\"";
10✔
224
                        this._fractionHeightScale = 1.0;
10✔
225
                        this.FractionType = FractionFormat.Horizontal;
10✔
226
                }
10✔
227

228
                /// <summary>
229
                /// Get the string format based on the zero handling of the style.
230
                /// </summary>
231
                /// <param name="isAngular"></param>
232
                /// <returns></returns>
233
                public string GetZeroHandlingFormat(bool isAngular = false)
234
                {
9✔
235
                        short decimalPlaces = this.LinearDecimalPlaces;
9✔
236
                        ZeroHandling handling;
237

238
                        if (isAngular)
9✔
239
                        {
3✔
240
                                handling = this.AngularZeroHandling;
3✔
241
                        }
3✔
242
                        else
243
                        {
6✔
244
                                handling = this.LinearZeroHandling;
6✔
245
                        }
6✔
246

247
                        char leading = handling == ZeroHandling.SuppressDecimalLeadingZeroes
9✔
248
                                   || handling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes ?
9✔
249
                                   '#' : '0';
9✔
250

251
                        char trailing = handling == ZeroHandling.SuppressDecimalTrailingZeroes
9✔
252
                           || handling == ZeroHandling.SuppressDecimalLeadingAndTrailingZeroes ?
9✔
253
                           '#' : '0';
9✔
254

255
                        StringBuilder zeroes = new();
9✔
256

257
                        zeroes.Append(leading);
9✔
258
                        zeroes.Append(this.DecimalSeparator);
9✔
259

260
                        for (int i = 0; i < decimalPlaces; i++)
56✔
261
                        {
19✔
262
                                zeroes.Append(trailing);
19✔
263
                        }
19✔
264

265
                        return zeroes.ToString();
9✔
266
                }
9✔
267

268
                /// <summary>
269
                /// Converts a value into its feet and fractional inches string representation.
270
                /// </summary>
271
                /// <param name="value"></param>
272
                /// <returns>A string that represents the value in feet and fractional inches.</returns>
273
                public string ToArchitectural(double value)
274
                {
1✔
275
                        int feet = (int)(value / 12);
1✔
276
                        double inchesDec = value - 12 * feet;
1✔
277
                        int inches = (int)inchesDec;
1✔
278

279
                        if (MathHelper.IsZero(inchesDec))
1!
NEW
280
                        {
×
NEW
281
                                if (feet == 0)
×
NEW
282
                                {
×
NEW
283
                                        if (this.SuppressZeroFeet)
×
NEW
284
                                        {
×
NEW
285
                                                return string.Format("0{0}", this.InchesSymbol);
×
286
                                        }
287

NEW
288
                                        if (this.SuppressZeroInches)
×
NEW
289
                                        {
×
NEW
290
                                                return string.Format("0{0}", this.FeetSymbol);
×
291
                                        }
292

NEW
293
                                        return string.Format("0{0}{1}0{2}", this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
294
                                }
295

NEW
296
                                if (this.SuppressZeroInches)
×
NEW
297
                                {
×
NEW
298
                                        return string.Format("{0}{1}", feet, this.FeetSymbol);
×
299
                                }
300

NEW
301
                                return string.Format("{0}{1}{2}0{3}", feet, this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
302
                        }
303

304
                        getFraction(inchesDec, (short)Math.Pow(2, this.LinearDecimalPlaces), out int numerator, out int denominator);
1✔
305

306
                        if (numerator == 0)
1!
NEW
307
                        {
×
NEW
308
                                if (inches == 0)
×
NEW
309
                                {
×
NEW
310
                                        if (feet == 0)
×
NEW
311
                                        {
×
NEW
312
                                                if (this.SuppressZeroFeet)
×
NEW
313
                                                {
×
NEW
314
                                                        return string.Format("0{0}", this.InchesSymbol);
×
315
                                                }
316

NEW
317
                                                if (this.SuppressZeroInches)
×
NEW
318
                                                {
×
NEW
319
                                                        return string.Format("0{0}", this.FeetSymbol);
×
320
                                                }
321

NEW
322
                                                return string.Format("0{0}{1}0{2}", this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
323
                                        }
324

NEW
325
                                        if (this.SuppressZeroInches)
×
NEW
326
                                        {
×
NEW
327
                                                return string.Format("{0}{1}", feet, this.FeetSymbol);
×
328
                                        }
329

NEW
330
                                        return string.Format("{0}{1}{2}0{3}", feet, this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
331
                                }
NEW
332
                                if (feet == 0)
×
NEW
333
                                {
×
NEW
334
                                        if (this.SuppressZeroFeet)
×
NEW
335
                                        {
×
NEW
336
                                                return string.Format("{0}{1}", inches, this.InchesSymbol);
×
337
                                        }
338

NEW
339
                                        return string.Format("0{0}{1}{2}{3}", this.FeetSymbol, this.FeetInchesSeparator, inches, this.InchesSymbol);
×
340
                                }
341

NEW
342
                                return string.Format("{0}{1}{2}{3}{4}", feet, this.FeetSymbol, this.FeetInchesSeparator, inches, this.InchesSymbol);
×
343
                        }
344

345
                        string text = string.Empty;
1✔
346
                        string feetStr;
347
                        if (this.SuppressZeroFeet && feet == 0)
1!
NEW
348
                        {
×
NEW
349
                                feetStr = string.Empty;
×
NEW
350
                        }
×
351
                        else
352
                        {
1✔
353
                                feetStr = feet + this.FeetSymbol + this.FeetInchesSeparator;
1✔
354
                        }
1✔
355

356
                        switch (this.FractionType)
1!
357
                        {
358
                                case FractionFormat.Diagonal:
NEW
359
                                        text = $"\\A1;{feetStr}{inches}{{\\H{this.FractionHeightScale}x;\\S{numerator}#{denominator};}}{this.InchesSymbol}";
×
NEW
360
                                        break;
×
361

362
                                case FractionFormat.Horizontal:
363
                                        text = $"\\A1;{feetStr}{inches}{{\\H{this.FractionHeightScale}x;\\S{numerator}/{denominator};}}{this.InchesSymbol}";
1✔
364
                                        break;
1✔
365

366
                                case FractionFormat.None:
NEW
367
                                        text = $"{feetStr}{inches} {numerator}/{denominator}{this.InchesSymbol}";
×
NEW
368
                                        break;
×
369
                        }
370
                        return text;
1✔
371
                }
1✔
372

373
                /// <summary>
374
                /// Converts a value into its decimal string representation.
375
                /// </summary>
376
                /// <param name="value"></param>
377
                /// <param name="isAngular"></param>
378
                /// <returns>A string that represents the value in decimal units.</returns>
379
                public string ToDecimal(double value, bool isAngular = false)
380
                {
2✔
381
                        return value.ToString(this.GetZeroHandlingFormat(isAngular));
2✔
382
                }
2✔
383

384
                /// <summary>
385
                /// Converts an angle value in degrees into its degrees, minutes and seconds string representation.
386
                /// </summary>
387
                /// <param name="angle">Angle value in radians.</param>
388
                /// <returns></returns>
389
                /// <exception cref="ArgumentNullException"></exception>
390
                public string ToDegreesMinutesSeconds(double angle)
391
                {
1✔
392
                        double degrees = MathHelper.RadToDeg(angle);
1✔
393
                        double minutes = (degrees - (int)degrees) * 60;
1✔
394
                        double seconds = (minutes - (int)minutes) * 60;
1✔
395

396
                        NumberFormatInfo numberFormat = new NumberFormatInfo
1✔
397
                        {
1✔
398
                                NumberDecimalSeparator = this.DecimalSeparator
1✔
399
                        };
1✔
400

401
                        if (this.AngularDecimalPlaces == 0)
1!
402
                        {
1✔
403
                                return string.Format(numberFormat, "{0}" + this.DegreesSymbol, (int)Math.Round(degrees, 0));
1✔
404
                        }
405

NEW
406
                        if (this.AngularDecimalPlaces == 1 || this.AngularDecimalPlaces == 2)
×
NEW
407
                        {
×
NEW
408
                                return string.Format(numberFormat, "{0}" + this.DegreesSymbol + "{1}" + this.MinutesSymbol, (int)degrees, (int)Math.Round(minutes, 0));
×
409
                        }
410

NEW
411
                        if (this.AngularDecimalPlaces == 3 || this.AngularDecimalPlaces == 4)
×
NEW
412
                        {
×
NEW
413
                                return string.Format(numberFormat, "{0}" + this.DegreesSymbol + "{1}" + this.MinutesSymbol + "{2}" + this.SecondsSymbol, (int)degrees, (int)minutes, (int)Math.Round(seconds, 0));
×
414
                        }
415

416
                        // the suppression of leading or trailing zeros is not applicable to DegreesMinutesSeconds angles format
NEW
417
                        string f = "0." + new string('0', this.AngularDecimalPlaces - 4);
×
NEW
418
                        return string.Format(numberFormat, "{0}" + this.DegreesSymbol + "{1}" + this.MinutesSymbol + "{2}" + this.SecondsSymbol, (int)degrees, (int)minutes, seconds.ToString(f, numberFormat));
×
419
                }
1✔
420

421
                /// <summary>
422
                /// Converts a value into its feet and decimal inches string representation.
423
                /// </summary>
424
                /// <param name="value">Must be in inches.</param>
425
                /// <returns>A string that represents the value in feet and decimal inches.</returns>
426
                public string ToEngineering(double value)
NEW
427
                {
×
NEW
428
                        NumberFormatInfo numberFormat = new NumberFormatInfo
×
NEW
429
                        {
×
NEW
430
                                NumberDecimalSeparator = this.DecimalSeparator
×
NEW
431
                        };
×
NEW
432
                        int feet = (int)(value / 12);
×
NEW
433
                        double inches = value - 12 * feet;
×
434

NEW
435
                        if (MathHelper.IsZero(inches))
×
NEW
436
                        {
×
NEW
437
                                if (feet == 0)
×
NEW
438
                                {
×
NEW
439
                                        if (this.SuppressZeroFeet)
×
NEW
440
                                        {
×
NEW
441
                                                return string.Format("0{0}", this.InchesSymbol);
×
442
                                        }
443

NEW
444
                                        if (this.SuppressZeroInches)
×
NEW
445
                                        {
×
NEW
446
                                                return string.Format("0{0}", this.FeetSymbol);
×
447
                                        }
NEW
448
                                        return string.Format("0{0}{1}0{2}", this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
449
                                }
450

NEW
451
                                if (this.SuppressZeroInches)
×
NEW
452
                                {
×
NEW
453
                                        return string.Format("{0}{1}", feet, this.FeetSymbol);
×
454
                                }
455

NEW
456
                                return string.Format("{0}{1}{2}0{3}", feet, this.FeetSymbol, this.FeetInchesSeparator, this.InchesSymbol);
×
457
                        }
458

NEW
459
                        string inchesDec = inches.ToString(this.GetZeroHandlingFormat(), numberFormat);
×
NEW
460
                        if (feet == 0)
×
NEW
461
                        {
×
NEW
462
                                if (this.SuppressZeroFeet)
×
NEW
463
                                {
×
NEW
464
                                        return string.Format("{0}{1}", inches, this.InchesSymbol);
×
465
                                }
466

NEW
467
                                return string.Format("0{0}{1}{2}{3}", this.FeetSymbol, this.FeetInchesSeparator, inchesDec, this.InchesSymbol);
×
468
                        }
NEW
469
                        return string.Format("{0}{1}{2}{3}{4}", feet, this.FeetSymbol, this.FeetInchesSeparator, inchesDec, this.InchesSymbol);
×
NEW
470
                }
×
471

472
                /// <summary>
473
                /// Converts a value into its fractional string representation.
474
                /// </summary>
475
                /// <param name="value"></param>
476
                /// <returns>A string that represents the value in fractional units.</returns>
477
                public string ToFractional(double value)
478
                {
2✔
479
                        int num = (int)value;
2✔
480
                        getFraction(value, (short)Math.Pow(2, this.LinearDecimalPlaces), out int numerator, out int denominator);
2✔
481
                        if (numerator == 0)
2!
NEW
482
                        {
×
NEW
483
                                return string.Format("{0}", (int)value);
×
484
                        }
485

486
                        string text = string.Empty;
2✔
487
                        switch (this.FractionType)
2!
488
                        {
489
                                case FractionFormat.Diagonal:
NEW
490
                                        text = $"\\A1;{num}{{\\H{this.FractionHeightScale}x;\\S{numerator}#{denominator};}}";
×
NEW
491
                                        break;
×
492

493
                                case FractionFormat.Horizontal:
NEW
494
                                        text = $"\\A1;{num}{{\\H{this.FractionHeightScale}x;\\S{numerator}/{denominator};}}";
×
NEW
495
                                        break;
×
496

497
                                case FractionFormat.None:
498
                                        string prefix = num == 0 ? string.Empty : $"{num.ToString()} ";
2✔
499
                                        text = $"{prefix}{numerator}/{denominator}";
2✔
500
                                        break;
2✔
501
                        }
502
                        return text;
2✔
503
                }
2✔
504

505
                /// <summary>
506
                /// Converts an angle value in radians into its gradians string representation.
507
                /// </summary>
508
                /// <param name="angle">The angle value in radians.</param>
509
                /// <returns>A string that represents the angle in gradians.</returns>
510
                public string ToGradians(double angle)
511
                {
1✔
512
                        NumberFormatInfo numberFormat = new NumberFormatInfo
1✔
513
                        {
1✔
514
                                NumberDecimalSeparator = this.DecimalSeparator
1✔
515
                        };
1✔
516

517
                        return (MathHelper.RadToGrad(angle)).ToString(GetZeroHandlingFormat(true), numberFormat) + this.GradiansSymbol;
1✔
518
                }
1✔
519

520
                /// <summary>
521
                /// Converts an angle value in radians into its string representation.
522
                /// </summary>
523
                /// <param name="angle">The angle value in radians.</param>
524
                /// <returns>A string that represents the angle in radians.</returns>
525
                public string ToRadians(double angle)
526
                {
1✔
527
                        NumberFormatInfo numberFormat = new NumberFormatInfo
1✔
528
                        {
1✔
529
                                NumberDecimalSeparator = this.DecimalSeparator
1✔
530
                        };
1✔
531
                        return angle.ToString(GetZeroHandlingFormat(true), numberFormat) + this.RadiansSymbol;
1✔
532
                }
1✔
533

534
                /// <summary>
535
                /// Converts a value into its scientific string representation.
536
                /// </summary>
537
                /// <param name="value">The length value.</param>
538
                /// <returns>A string that represents the length in scientific units.</returns>
539
                public string ToScientific(double value)
540
                {
1✔
541
                        return value.ToString($"{this.GetZeroHandlingFormat()}E+00");
1✔
542
                }
1✔
543

544
                private static void getFraction(double number, int precision, out int numerator, out int denominator)
545
                {
3✔
546
                        numerator = Convert.ToInt32((number - (int)number) * precision);
3✔
547
                        int commonFactor = getGCD(numerator, precision);
3✔
548
                        if (commonFactor <= 0)
3!
NEW
549
                        {
×
NEW
550
                                commonFactor = 1;
×
NEW
551
                        }
×
552
                        numerator = numerator / commonFactor;
3✔
553
                        denominator = precision / commonFactor;
3✔
554
                }
3✔
555

556
                private static int getGCD(int number1, int number2)
557
                {
3✔
558
                        int a = number1;
3✔
559
                        int b = number2;
3✔
560
                        while (b != 0)
9✔
561
                        {
6✔
562
                                int count = a % b;
6✔
563
                                a = b;
6✔
564
                                b = count;
6✔
565
                        }
6✔
566
                        return a;
3✔
567
                }
3✔
568
        }
569
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc