Errors, bugs, questions - page 1127

 
Fleder:

What does this rearrangement do? t was lower than ULONG_MAX-1 and remains the same.

I cited this wrong example - it was a comparison with int, while here it is with long

for(int t=0
void OnStart()
{
  long t=0;
 

Theuint and ulongtypes have a higher priority than int and long:

Transformations when merging by binary operation

It would be logical to use conversion to a higher type in the compared expressions.

But this does not seem to apply to the loop expressions being checked.

 
ULONG_MAX has no type per se, compared to int it will be int, compared to long it will be long
 
A100:
ULONG_MAX has no type per se
What type does this number have:18446744073709551615?
 
A100:
ULONG_MAX has no type per se, compared to int it will be int, compared to long it will be long

And compared to ulong?

void OnStart()
{
  ulong n=18446744073709551615;
  Print(ULONG_MAX==n);   //true
}
 
A100:
ULONG_MAX has no type per se, compared to int it will be int, compared to long it will be long

Can it be the other way round?

int and long versus ulong would be ulong?

 
Fleder:

Can it be the other way round?

int and long versus ulong would be ulong?

When comparing signed and unsigned, a warning is given, unless one is explicitly converted to the other, it will probably be a bitwise comparison
 

The cycles do seem to be converting to a signed type:

void OnStart()
{
  ulong n=0;
  for(ulong i=0;i<ULONG_MAX;i++) {n++;}
  Print("n = ",n);          //0
  Print((long)ULONG_MAX);   //-1
}

And no iteration is performed.

 
A100:
When comparing signed and unsigned, a warning is issued, unless one is explicitly converted to the other, there will probably be a bitwise comparison
void OnStart()
{
  long l=13;
  ulong u=13;
  bool compare=(l==u);           //предупреждения нет
  Print("compare = ",compare);   //compare = true
}

 
bool f( int i, uint j )
{
        return ( i < j );
}
but that's how it is.
Reason: