sec fixes
This commit is contained in:
28
Matrices.cs
28
Matrices.cs
@@ -79,8 +79,32 @@ namespace Lab
|
||||
{
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
double num = (double)dt.Rows[row][col];
|
||||
num = double.IsInfinity(num) || double.IsNaN(num) ? 0 : num;
|
||||
object cell = dt.Rows[row][col];
|
||||
|
||||
double num = 0;
|
||||
|
||||
if (cell is null || cell == DBNull.Value)
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
else if (cell is double d)
|
||||
{
|
||||
num = d;
|
||||
}
|
||||
else if (cell is int i)
|
||||
{
|
||||
num = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Parsers.TryParseDouble(cell.ToString(), out num)) num = 0;
|
||||
}
|
||||
|
||||
if (double.IsNaN(num) || double.IsInfinity(num)) num = 0;
|
||||
|
||||
if (num > int.MaxValue) num = int.MaxValue;
|
||||
if (num < int.MinValue) num = int.MinValue;
|
||||
|
||||
array[row, col] = Convert.ToInt32(num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,15 @@ namespace Lab
|
||||
get { return first + second; }
|
||||
set
|
||||
{
|
||||
first = Math.Truncate(value);
|
||||
second = Math.Abs(value - first);
|
||||
if (double.IsNaN(value) || double.IsInfinity(value))
|
||||
{
|
||||
first = 0;
|
||||
second = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
first = Math.Floor(value);
|
||||
second = value - first;
|
||||
|
||||
second = Math.Round(second, 10);
|
||||
|
||||
@@ -31,7 +38,14 @@ namespace Lab
|
||||
|
||||
public void Multiply(double m)
|
||||
{
|
||||
Value = Value * m;
|
||||
double res = Value * m;
|
||||
if (double.IsNaN(res) || double.IsInfinity(res))
|
||||
{
|
||||
first = 0;
|
||||
second = 0;
|
||||
return;
|
||||
}
|
||||
Value = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user