Reputation: 12833
This is the declaration for PositiveInfinity in Double.
/// <summary>
/// Represents positive infinity. This field is constant.
/// </summary>
/// <filterpriority>1</filterpriority>
public const double PositiveInfinity = double.PositiveInfinity;
This looks like a cycle that wouldn't pass the compiler... why is it declared this way & how does this work?
Upvotes: 2
Views: 214
Reputation: 659994
This is the declaration for
PositiveInfinity
inDouble
.
No, it is not.
This is a portion of the decompilation of the
Double
struct provided by Resharper.
That's better.
This looks like a cycle that wouldn't pass the compiler.
That's because it is a cycle that would not pass the compiler.
Why does Resharper's decompiler produce code that doesn't compile?
My guess is that it's a bug. You'll have to ask the Resharper team for a definitive answer.
Likely they have a heuristic that says to put Double.PositiveInfinity
in anywhere that a positive infinity constant appears; this is perhaps the one place where that's wrong. So that's an easy bug to write.
What does the real declaration look like?
I haven't got reference sources on my home computer, but my guess is that the real declaration is:
public const double PositiveInfinity = 1.0 / 0.0;
Where can I get the reference sources, so I don't have to rely on an unreliable decompiler?
http://referencesource.microsoft.com
Upvotes: 14