0

So,

I got example number: 0.00857382942837523 which length is 18, but I would like to remove from the end example 9 numbers. Thing is, that number is different every time, so I can't "predict" numbers what are going to be at the end.

//My question was marked to duplicate, but it can't be solved like that. Mine has 0.00, if I would do math.round it would give up 0...

Jartsu
  • 11
  • 3
  • Thanks, I am sorry I didn't find it. I will see if that's going to help me. – Jartsu Mar 12 '16 at 18:12
  • If you don't want to round, you may want to put your number in a string and cut that string? For a detailed answer you should tell us what the number of required decimals depend on and what you've tried so far. – René Vogt Mar 12 '16 at 20:07

1 Answers1

0

You need Math.Truncate

        decimal d= 0.00857382942837523m;
        d= Math.Truncate(d * 1000000000m) / 1000000000m;
        Console.WriteLine(d); // 0.008573829
Rohit
  • 10,056
  • 7
  • 50
  • 82