秀丸マクロでビットシフト

秀丸マクロになぜかビットシフトがなかったので代替サブルーチンを作ってみました。

    call bitShiftLeft 1, 8;
    message str( ##return );
    endmacro;

bitShiftLeft:
    call pow2 ##2;
    return ##1 * ##return;

bitShiftRight:
    call pow2 ##2;
    if ( ##1 < 0 ) {
        return ( ##1 + 1 ) / ##return - 1;
    }
    return ##1 / ##return;

pow2:
    ##i = ##1;
    ##r = 1;
    while( ##i > 0 ) {
        ##r = ##r * 2;
        ##i = ##i - 1;
    }
    return ##r;

インフォメーション

公開日時
2007年11月21日 午後9時9分7秒
最終更新日時
2007年11月21日 午後9時14分48秒
カテゴリ
秀丸エディタ