Posted by Joseph on 3/15/2007 1:33 AM | Comments (6)

object value = 1 / 0.0;

Will it throw an exception at run-time? If not what value will value have after this line has run? Kudos to those who didn't need to check.

Comments

Chris on 3/15/2007 11:10 AM Ooh that's interesting - how about -1 / 0.0 ? Smile



Chris
Dave
Dave on 3/16/2007 5:55 AM My wife says it will so there! She also says it will give you a divide by zero error at run time.



To add an opposing view, my cat thinks it wont compile.
Omer van Kloeten on 3/16/2007 6:29 AM If I remember my specs correctly, 'value' will have a boxed NaN value.



I think I recall a PositiveInfinity and NegativeInfinity in Int32, but that's a longshot.
Eddie on 3/16/2007 10:19 AM Dang, I hate these "interview" pop quizes. I'm gonna throw a guess and I say it will compile but will throw an exception at run time.
Omer van Kloeten on 3/17/2007 12:38 AM Forgot to add that if it's an unchecked statement (or unchecked project), an Exception will be thrown, although I'm not sure it would even compile...
tim w
tim w on 4/4/2007 6:34 AM It will not compile since value is a reserved word, right?
Comments are closed