c# - Why does Decimal.Divide(int, int) work, but not (int / int)? -


How two split 32 bit int numbers (int / int) gives me 0 , But if I use decimals Dive () I get the right answer? I'm not the AC # man in any way.

int is an integer type; Splitting of two ints causes an integer partition, i.e. partial part is deducted because it can not be stored in the result type (also int !) By contrast, decimals , a partial piece is found. By introducing decimals. Divided , your int arguments is converted into a decimal s.

You can apply a non-integer

  int a = 42; For the floating point type, explicitly casting at least one argument, the partition on the  int  argument. Int b = 23; Double result = (double) A / B;  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -