Thursday, March 22, 2012

Simple division wont work

I have the following line of code that does a simple divide:(I have alost tried this as data types: long, int) the variable " i " always returns the value 0. Does anyone know why this is?

double i;

i = 42 / 73;

James

C# performs integer division by default, while VB.NET performs floating point division.. Try it like this instead:

i = 42.0/73.0;

Worked!

Thanks alot,

James

0 comments:

Post a Comment