(This article also published in my public number "dotnet daily Essence article", Welcome to the right QR code to pay attention to. )
Yesterday at home something, the Internet is not convenient, there is no push article. Today is very tired, also not lengthy. A brief introduction to a small hole recently encountered.
We know that there are several numeric types in C #: int, long, decimal, float, and double. For the first three kinds, if except 0, you will be prompted for an expression error (write a number directly) or a DivideByZeroException exception (using a variable), for the next two, except 0 will be positive and negative infinity, unless you are 0.0/0.0 then get Nan (not a number). This is what most of the references tell you. such as "read the original" This easy-to-understand article.
Recently, the previous code has a bug, always appear infinity, and then troubleshoot all division expressions, the problem will not be resolved. After tracing the value of the variable before the infinity, and discovering the multiplication of "1E+300 * 1E+10", the code logic is carefully studied, and some variables (double types) are repeatedly multiplied and become infinitely large. Realize that not only will there be infinity in addition to 0, but the multiplication of large numbers will also occur infinitely large. Everyone be careful later.
Original address: http://blog.csdn.net/seattle1215/article/details/6660138
Infinity in C # has a little pit.