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
Printable View
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
100 / 0 throws a DivideByZero exception
100.0 / 0.0 does not throw an exception and the result will be Inf
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? ^^
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).
"Make" is a program that understands which components need to be rebuilt when another component is changed. "linker" is the application that puts together an executable file.
What this means is that the .Net assembly corresponds to both the input of the Make utility (i.e. "Makefile") and Linker (usually on the command line).
--
Mats
The .Net .exe & .dll files are called assemblies that have, in general, three sets of data. There is an assembly manifest, type meta-data (also known as CIL), and a resource file (.rsp) with build/make instructions in it.
The .exe & .dll files in .Net have no relation to their binary executable types like we are accustomed to with binary installers and the like.
When you publish a C# application or .dll all you are really publishing is a shopping list for the .Net Framework to fill via mscoree.dll. mscoree.dll takes your .exe file like a book and reads its manifest, .rsp, and meta-data and prepares it for the JIT (Jitter) in the .Net Framework. The Jitter then accesses the .Net Base Classes library and assembles your application in byte code on the fly. This is the same way Python is handled with Idle the python interpreter.
You don't actually see your C# application until it is built and compiled on the fly by Jitter each time you run your C# app.
Very much like bake and make with a touch of interpreter I think.
You can actually alter how your C# app will be built by editing the .rsp resource file. .rsp is every bit the make file I say it is and it's pretty tight. You should look into it cause I'm sure you will agree. If your familiar with C++ this will be a trip down memory lane for you.
My reference into this subject was the book Pro C#2008 and the .Net 3.5 Platform published by Apress and authored by Andrew Troelsen. This guy knows his stuff. Got mine at Barnes & Noble before I saw it cheaper on Amazon.
Thank you Matsp.
I just learned some more...real familiar with C++ aren't ya'!
Excellent.
Thanks Mats,
Make accepts source filess as input, but .Net assembly is binary file, how do you think it is similar to what is input to make in C++?
Great TheRaven!
Two more comments,
1.
What does your above statements mean? I am confused. Could you say any other words, especially "no relation to their binary executable types" and "accustomed to with binary installers and the like"?
2.
Byte code you mean native code other than IL code, right?
3.
Any referred materials (free online) :-) for .rsp file?
regards,
George