OK, I needed to know so I tested incrementally and came up with these limits:
positive: 1,073,741,951
negative: -1,073,741,760
The code I used looked something like this:
int lastGoodVal = 0;
for (int i = -1073000000; i > -1073832999; i -= 1)
{
g.DrawLine(Pens.Blue, new Point(0,0), new Point(0, i));
lastGoodVal = i;
}
The loop above was the final test, stepping by 1, through a range of negative values established by earlier tests. As you can see, lastGoodVal holds the last successful painting iteration and therefore the real limit which I'll use as a constant.
I tried to correlate these numbers to a value in the .NET primitives but couldn't. Each limit is close to the value of 2^30 but is not exactly on it. Any other insight would be much appreciated.
I also only tested with the DrawLine method. It's possible that different limits exist for other functions in the API but I have not had a chance to explore that yet.
Also, after finishing this experiment and then Googling for the value 1073741951 I came across this article which correlates my findings. I also found this in a Mono code archive of some sort which mentions a near, though not exact correlation to float limits.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…