Hi All,
Can anyone explain the behaviour of the following code?
//ulong test1 = 5555555555555555555 * 1000;
ulong test1 = 5555555555555555555;
test1 = test1 * 1000;
Console.WriteLine(test1);
(refering to the comment out line) If you try to create the variable from a huge number * 1000 the line gets flagged in visual studio saying it will overload (as you'd expect).
But if the variables is created and then multiplyed by 1000 using another statement no errors or warnings occur.
The result is not as expected but it is displayed without errors.
The reason I ask is that I am trying to modify some code that uses the above process as an integral part of its operation. This suggests to me it is probably normal behaviour that I'm not aware of.
Any help much appreciated.
Thanks
BN
Can anyone explain the behaviour of the following code?
//ulong test1 = 5555555555555555555 * 1000;
ulong test1 = 5555555555555555555;
test1 = test1 * 1000;
Console.WriteLine(test1);
(refering to the comment out line) If you try to create the variable from a huge number * 1000 the line gets flagged in visual studio saying it will overload (as you'd expect).
But if the variables is created and then multiplyed by 1000 using another statement no errors or warnings occur.
The result is not as expected but it is displayed without errors.
The reason I ask is that I am trying to modify some code that uses the above process as an integral part of its operation. This suggests to me it is probably normal behaviour that I'm not aware of.
Any help much appreciated.
Thanks
BN