12,403,391 members (72,471 online)
Rate this:
See more:
MS chose to insert a representation of Infinity in Double and Float but not in Decimal and Int64?

You have:
Double.PositiveInfinity & Float.PositiveInfinity (as well as Double.Epsilon & Float.Epsilon) which are missing in Decimal.

Q: Why?

Moreover: I understand the concept of decimal being basically designed more for currency operations and other "real world" calculations.

But being that doesn't really explain my question.
The reason is that even decimal and Int64 has it's limits of course,
these limits
in Int64 if you multiply MaxValue by MaxValue you get 1 !!!!
in Decimal it throws an exception. (which I may live with)

You could easily implement Infinity in both.
Arguably an exception is a desired response, but the Int64 behavior is totally silly in my opinion.
Posted 9-Apr-13 21:59pm
Joezer BH38.7K
Updated 16-May-13 1:02am
v5

Rate this:

## Solution 2

The short answer is 'because that's what the standard says'; IEEE floating point defines infinities and NaNs, whereas the integer standards don't. Decimal, despite having a floating point in the most literal sense of that term, is based on the integer standards (and obviously long is a native integer type). The 'special' bit patterns are typically 'most bits on' and as such would represent small negative numbers in an integer type.

You can alter the overflow behaviour of native types in .Net with the checked{...} or unchecked{...} constructs, with a compiler option setting the default: see MSDN[^].
Edo Tzumer 16-May-13 7:40am

Quote: "because that's what the standard says"

I am inclined to accept this answer, which is probably a typical MS answer: highly descriptive and yet utterly useless.
:laugh:
Rate this:

## Solution 1

Hi,

Have a look here:
http://stackoverflow.com/questions/986268/why-is-nan-not-a-number-only-available-for-doubles[^]
The StackOverflow question is a question about why NaN is only available for doubles, but it also applies to PositiveInfinity.
v2
Edo Tzumer 10-Apr-13 4:18am

See question update

Top Experts
Last 24hrsThis month
 OriginalGriff 353 Karthik Bangalore 230 Richard MacCutchan 177 Suvendu Shekhar Giri 175 RossMW 85
 OriginalGriff 7,346 Karthik Bangalore 3,127 ppolymorphe 3,080 Richard MacCutchan 2,308 F-ES Sitecore 2,222