I need to somehow get one number before floating point and value after that floating point. Example:
Before: 212.12345;
After: 2.12345
Any Ideas?
I need to somehow get one number before floating point and value after that floating point. Example:
Before: 212.12345;
After: 2.12345
Any Ideas?
Assuming you have:
decimal x = 212.12345m;
you can use the modulo operator:
decimal result = x % 10;
Note that the number should be represented as a decimal if you care about the accurate value.
See also: Meaning of "%" operation in C# for the numeric type double
my approach was to find the number 210, and substract it....
will work for any number as well as smaller then 10.
double f1 = 233.1234;
double f2 = f1 - (((int)f1 / 10) * 10);
try this
double x = 1;
var y = x/10;
var z = (y % (Math.Floor(y))) * 10;
You can do like this:
public double GetFirst(double a)
{
double b = a / 10.0;
return (b - (int)b) * 10.0;
}
Try this code
string num = "15464612.12345";
string t = num.Split('.')[0];
num = t[t.Length-1].ToString() + "." + num.Split('.')[1];