52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Lab
|
|
{
|
|
internal class SplitNumber
|
|
{
|
|
public double first { get; private set; }
|
|
public double second { get; private set; }
|
|
|
|
public double Value
|
|
{
|
|
get { return first + second; }
|
|
set
|
|
{
|
|
if (double.IsNaN(value) || double.IsInfinity(value))
|
|
{
|
|
first = 0;
|
|
second = 0;
|
|
return;
|
|
}
|
|
|
|
first = Math.Floor(value);
|
|
second = value - first;
|
|
|
|
second = Math.Round(second, 10);
|
|
|
|
if (second >= 1)
|
|
{
|
|
first += 1;
|
|
second = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Multiply(double m)
|
|
{
|
|
double res = Value * m;
|
|
if (double.IsNaN(res) || double.IsInfinity(res))
|
|
{
|
|
first = 0;
|
|
second = 0;
|
|
return;
|
|
}
|
|
Value = res;
|
|
}
|
|
}
|
|
}
|