Hello everyone,
I have verified that the result of 100/0 will not occur any exception, and it will be infinite.
Does it mean there is no exceptions like divide by zero in C#?
thanks in advance,
George
Hello everyone,
I have verified that the result of 100/0 will not occur any exception, and it will be infinite.
Does it mean there is no exceptions like divide by zero in C#?
thanks in advance,
George
Seems like it.
It may be something you can define yourself tho'.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
100 / 0 throws a DivideByZero exception
100.0 / 0.0 does not throw an exception and the result will be Inf
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Thats what happens when Microsoft invents a language. Though jabbing ms aside, they probably did that to lower instances of run-time errors. Though, that is one you'd want to know about, as the developer.
Yeah I do agree with you. I just couldn't imagine how a company that develops software would consider that a useful characteristic for other developers. Who knows. Good find though. I don't use C# as often as C/C++/VB, but I will keep that in mind. Though now I am going to have to do some tests with VB, chances are it does the same.
Wow, you're constantly posting the same questions on many boards (Cprogramming.com, MSDN forums, Wizard Scripts, CodeGuru.com, Devarticles.com and probably many more). Are you a bot or something? ^^
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
George2 could merely be looking for consistency in the responses received for a given post. Boards systems have come along way with the growing knowledgability of a more informed programming society, but we still have a ways to go. Allot of times you have to, still yet, piece mill a solution together and inevitably debug the holy hell out of it to get it up to snuff, but it is getting better all the time because of members like you all.
The divide by zero appears to be a .Net Framework problem in scope. This scenario involves all .Net languages to include C# and VB.Net to name a short few. The VS .Net executables and .dll's are assembly sets that act as 'assembly instructions' that are parsed and then sent to the .Net JIT compiler for creation.
Basically a .Net assembly acts as a Make and Linker file all in one and it is with this all in one file that the JIT compiles and links your system into bytecode and dynamically stored into memory for operations.
The divide by zero will have to be handled with managed code from within your system's internal code with a specially designed try - catch method as previously stated. The reasoning behind the managed handling was that the .Net Framework has to be a common interface for any language that wants to use it and not all programming languages handle divide by zero equally. This method of handling the divide by zero fault eliminates allot of overiding and system clashes for the time being.
I personally think that a nominal divide by zero try-catch error handling system should be present, if it isn't already and we are merely overlooking it somehow, and to avoid system clashes between languages you must declare the default as being used for DB0 or you must define it yourself with managed code. This would eliminate allot of confusion.
That's because floating-point numbers have special values for Infinity and NaN (Not a Number). It just sets the result to Inf if there is division by zero (though I'd argue from a mathematical point of view, NaN would be more appropriate as the result of such a division is undefined).
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.