Ticket #1951 (closed enhancement: wontfix)

Opened 7 years ago

Last modified 5 years ago

Simplify

Reported by: pavlinux Owned by:
Priority: major Milestone:
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description (last modified by styx) (diff)

(x + 1) * 2 = ++x << 1

Attachments

inlines.h (584 bytes) - added by pavlinux 7 years ago.

Change History

comment:1 Changed 7 years ago by pavlinux

Code for test

#include <stdio.h>

int main(void) {

        int sp = 0;
        int dp = 0;

       while ( sp < 0xFF /* just limit */ ) {

                sp = (++sp << 1);
                dp = 2 * ( dp + 1 );

                printf("%d = %d\n", sp, dp);
        }
 return 0;
}

comment:2 Changed 7 years ago by pavlinux

Sorry bug. =)

Changed 7 years ago by pavlinux

comment:3 Changed 7 years ago by pavlinux

May be this

#include <stdio.h>
#define LIMIT 0x20
int main() {

int sp = 0;
int dp = 0;
int i = 0;

while ( (2*dp) <= LIMIT ) {

printf("%ld\n", 2*dp);
dp++;

}

while ( sp <= LIMIT ) {

printf("%ld\n", sp);
sp = 2 * ++i;

}

return 0;

}

comment:4 Changed 6 years ago by styx

  • Description modified (diff)

In you code variables are named not well. 'i' is now equal to 'backspaces' an 'backspaces' became to be equal to 2*old_backspaces. Yes, the result is the same, but the logic is changed.

comment:5 Changed 6 years ago by angel_il

  • Milestone changed from 4.7.1 to 4.7

comment:6 Changed 5 years ago by slavazanko

  • Status changed from new to closed
  • Resolution set to wontfix
  • Branch state set to no branch

comment:7 Changed 5 years ago by andrew_b

  • Milestone 4.7 deleted
Note: See TracTickets for help on using tickets.