0
double x = 5/2; vs double y =5.0/2.0; in C#
Hey I noticed this "problem" during making solution for Helloween Candy and i dont understand why even if i declare type double i got rounded result when x = 2 not correct 2.5 Do i use wrong type?
2 ответов
+ 5
From what I know :
- first case : 5 and 2 are integer and are interpreted as integer. Their division produces an integer. So 5 / 2 is 2.
- second case : 5 and 2 are floats. Their division produces a float. So 5.0 / 2.0 is 2.5.
0
Okey i understand, hmm but can i somehow set which side integer operation is round? I found methods only for round double