This question has already been answered:
- 25/100 = 0, Why? 3 replies
Hello
There is a code
int start = 2; int len = 5; for (int i = 0; i < len; i++) { decimal d = 1 / start; Console.WriteLine(@"1/" + start + " = " + d); start = start * 2; } Logically it should be
1/2 = 0.5 1/4 = 0.25 1/8 = 0.125 ... Why does decimal at division 1/2 print 0?
How to fix it?

double start = 2.0;or 2)d = 1.0 / start;- andy.371for1.0dand it all worked! Thank! - Sharpogay Vasilydis double, if you wantdecimal- putm:decimal d = 1m / start;- Grundy