- 1
Divisione by zero
when dividing by zero it doesn't give me an error, but the result is 8, why?
7 Answers
+ 31
Show us your code.
+ 5
That returns an infinity in C# which is basically an arbitrary integer in memory. You need to provide an exception to return the proper description of it. It's still practically impossible to divide by zero.
+ 4
Show the code.
+ 3
{
double x = Convert.ToInt16(Console.ReadLine());
double y = Convert.ToInt16(Console.ReadLine());
double z = x / y;
Console.WriteLine(z);
}
@Igor Makarsky @M Squared
+ 3
oh, ok
+ 3
thanks, I'll remember it
+ 2
So basically you can check a boolean to find the type of infinity here:
https://code.sololearn.com/cBtiDriapHD8/#cs