We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 41720fc commit 9abaf62Copy full SHA for 9abaf62
src/Tetrifact.Core/Percent.cs
@@ -11,6 +11,10 @@ public class Percent
11
/// <returns></returns>
12
public static int Calc(decimal first, decimal second)
13
{
14
+ // overflow check
15
+ if (second == 0)
16
+ return 0;
17
+
18
decimal p = first / second;
19
return (int)System.Math.Round((decimal)(p * 100), 0);
20
}
@@ -23,6 +27,10 @@ public static int Calc(decimal first, decimal second)
23
27
24
28
public static int Calc(double first, double second)
25
29
30
31
32
33
26
34
double p = first / second;
35
return (int)System.Math.Round((double)(p * 100), 0);
36
0 commit comments