aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods/DoubleExtensions.cs
blob: 8ccab4d44f79328154c2e2db6682ad9b91167f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public static class DoubleExtensions
{
    /// <summary>
    /// Replaces the decimal part of this value and returns a new value.
    /// </summary>
    /// <param name="value">The value.</param>
    /// <param name="fromValue">The value to take the decimal part from.</param>
    /// <returns></returns>
    public static double ReplaceDecimalPart(this double value, double fromValue)
    {
        decimal right = (decimal)fromValue - Math.Truncate((decimal)fromValue);
        double result = (double)(Decimal.Truncate((decimal)value) + right);
        return result;
    }
}