Divide by Zero(blogs.msdn.com)

submitted by dalzieldalziel(6230) 5 years, 10 months ago

float/double values do not cause a divideByZero exception, they set the result to '+Infinity'. Why is this?

1 comment |category: |Views: 3

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by kaschimerkaschimer(170) 5 years, 10 months ago 0

From MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdoubleclasstopic.asp):

The Double value type represents a double-precision 64-bit number with values ranging from negative 1.79769313486232e308 to positive 1.79769313486232e308, as well as positive or negative zero, PositiveInfinity, NegativeInfinity, and Not-a-Number (NaN).

The floating-point operators, including the assignment operators, do not throw exceptions. Instead, in exceptional situations, the result of a floating-point operation is zero, infinity, or NaN, as described below:

If the result of a floating-point operation is too small for the destination format, the result of the operation is zero.
If the magnitude of the result of a floating-point operation is too large for the destination format, the result of the operation is PositiveInfinity or NegativeInfinity, as appropriate for the sign of the result.
If a floating-point operation is invalid, the result of the operation is NaN.
If one or both operands of a floating-point operation are NaN, the result of the operation is NaN.

Reply

information Login or create an account to comment on this story