I'm making a program that divides by 1000. It works fine until it divides by a number higher than itself. For example

double asdf = (1000 / 3000);
            Math.Round(asdf);
            txtSpeed.Text = asdf.ToString();

When it divides by a number higher than 1000 it just gives me 0. Anyone know what's causing this?

Thanks,

SiPex

How about the fact that you are rounding the number!

try specifing the number of rounding digits...

Math.Round(asdf, 2)

would give you 0.00 percision

How about the fact that you are rounding the number!

try specifing the number of rounding digits...

Math.Round(asdf, 2)

would give you 0.00 percision

OK, i tried

double asdf = (1000 / 3000);
            Math.Round(asdf, 2);           
            Console.WriteLine(asdf);
            Console.ReadLine();

Still got 0

Any other suggestions?

Thanks

Developers just don't look at methods documentation!!
Round method returns the rounded number that's your problem, friend!

double d = 1000.0 / 3000.0;
d = Math.Round(d, 2);
Console.WriteLine(d);
Comments
Thanks.

Developers just don't look at methods documentation!!
Round method returns the rounded number that's your problem, friend!

double d = 1000.0 / 3000.0;
d = Math.Round(d, 2);
Console.WriteLine(d);

Thanks, it worked :)

This question has already been answered. Start a new discussion instead.