C
curious_one
All,
I have a sample code that does something like this,
unsigned long i = SOME_HUGE_VALUE;
unsigned long j = SOME_HUGE_VALUE;
void decrement_count()
{
if((signed long)j > 0)
j--
else
printf("Empty");
}
void add_count()
{
if((signed long)j < i)
{
j++;
}
else
{
printf("Error");
}
}
Will the casting in add_count truncate the j value while
comparision,as a result j++ will have a value more than i at some
point?
regds
curious
I have a sample code that does something like this,
unsigned long i = SOME_HUGE_VALUE;
unsigned long j = SOME_HUGE_VALUE;
void decrement_count()
{
if((signed long)j > 0)
j--
else
printf("Empty");
}
void add_count()
{
if((signed long)j < i)
{
j++;
}
else
{
printf("Error");
}
}
Will the casting in add_count truncate the j value while
comparision,as a result j++ will have a value more than i at some
point?
regds
curious