Errors, bugs, questions - page 1125

 

Probably a calculation error (MT\930\32)

void OnStart()
{
        int j = 1;
        for ( ulong i = 0; i < ULONG_MAX; i++ )
                j = -j;
        Print( "j=", j ); //результат j=1, а должен быть j=-1
}

I have not calculated it myself, but with even i -> j = -1, and the last i=18446744073709551615/*ULONG_MAX */-1-> even

 
A100:

Probably a calculation error (MT\930\32)

I did not calculate it myself, but with even i -> j = -1, and the last i=18446744073709551615/*ULONG_MAX */-1-> even

Tried your script.

The unsetting happens in a moment from joining the graph. It feels like no control is passed to the loop at all.

 
Fleder:

It feels as if no control is being transferred to the loop at all.

It really does, but it's fast :)
 
void OnStart()
{
        int j = 1;
        for ( int i = 0; i < INT_MAX; i++ )
                j = -j;
        Print( "j=", j );
}
It's a lot slower...
 
A100:
It really is, but it's fast :)

If I remember correctly, previous versions of the compiler complained when I tried to set

too many iterations in the loop (LONG_MAX and ULONG_MAX) and now the compiler keeps silent...

I have version 910 32 bit.

 

It's silent and "quick to count" even so:

void OnStart()
{
        int j = 1;
        for ( int i = 0; i < ULONG_MAX; i++ )
                j = -j;
        Print( "j=", j );
Although, supposedly, it should fall into an infinite loop.
 

He swears where there is no need to swear, and where there is a need to swear, he keeps quiet.

Their manners!

 
Fleder:

If I remember correctly, previous versions of the compiler complained when I tried to set

too many iterations in the loop (LONG_MAX and ULONG_MAX), but the compiler won't say a word now...

In general, the compiler cannot know the number of iterations.

int f( ulong max )
{
        int j = 1;
        for ( ulong i = 0; i < max; i += ULONG_MAX )
                j = 0;
        return ( j );
}
void OnStart()
{
        ulong max = ULONG_MAX;
        Print( "j=", f( max )); //результат j=1, а должно быть j=0
}
 
A100:

In general, the compiler cannot know the number of iterations

What is true is true. So it's a runtime error.
 
Maybe the for statement doesn't like 8-byte numbers in a tested expression?