<p>I need to compare the integer part of two doubles for inequality and I'm currently doing this:</p>

<pre><code>int iA = (int)dA;
int iB = (int)dB;

if( iA != iB )
{
    ...
}
</code></pre>

<p>but I wonder if there's a better approach than this.</p>

<p>Thanks.</p>

<p>If I used Math.Truncate() instead of a cast to int, would it still be accurate to compare the two resulting double values for equality?</p>

<p>About the hungarian notation comments:</p>

<p>I never use HN myself, not at least in the way most of people do. But this is one of these rare cases where the semantic of a variable directly relates to its type. I could have chosen another syntax like  A_As_Integer and B_As_NonInteger but what would have been the difference then?</p>

Yes, that is best approach.
Assuming from your wording in you question you arent worried about rounding... just the integerr part itself.
ie. (int)4.1  will give the same result as (int)4.9
As Ovid stated, if you only need the variables for the comparison, then you will only need to cast the doubles in the comparison statement. I was looking only at the theory.