### Author Topic: Operator bitwise right shift  (Read 1514 times)

#### josemym2

• Guest
##### Operator bitwise right shift
« on: 2010-May-02 »
Hello,
Is there a way to implement the bitwise (>>)? I need it because it is running code in c + + and Java, and I wanted to do GLbasic

This is my code:
Code: (glbasic) [Select]
`FUNCTION transform: coord[], offset[],trans_coord[]//'            Transform 3d coordinates into 2d positions based on the size of the screen AND an a y offset//'//'        coord: 3 dimensional coordinate TO be transformed TO an isometric 2d coordinate: list of 3 integers [x,y,z]//'        offset: 2 dimensional offset FOR the isometric coordinate: list of 2 integers [x,y]//'        Returns trans_coord: a 2d isometric coordinate: list of 2 integers [x,y]//'//'        Note: A side effect FOR speed: isometric transform scales x AND y values TO 1.118 times their//'        actual value AND the z scale coordinate stays AS 1: therefore all sprites need TO be drawn with this ratio. //    'transformation coordinates that are returned    DIMDATA trans_coord[],0,0//    'calculate x coordinate    trans_coord[0]=(coord[0]-coord[1])+offset[0]//    'calculates y coordinate    trans_coord[1]=((coord[0]+coord[1])>>1)-coord[2]+offset[1]    //RETURN trans_coord[]ENDFUNCTION`
thanks

#### Quentin

• Prof. Inline
• Posts: 915
##### Re: Operator bitwise right shift
« Reply #1 on: 2010-May-02 »
functions ASL() and ASR()

#### josemym2

• Guest
##### Re: Operator bitwise right shift
« Reply #2 on: 2010-May-02 »
Thanks

#### josemym2

• Guest
##### Re: Operator bitwise right shift
« Reply #3 on: 2010-May-02 »
but where is the best for compatibility with the c++ operator ">>"?

#### Quentin

• Prof. Inline
• Posts: 915
##### Re: Operator bitwise right shift
« Reply #4 on: 2010-May-02 »
you also can use the << operator directly using INLINE

Code: (glbasic) [Select]
`LOCAL a% = 2INLINE a = a << 3;ENDINLINEPRINT "a is now: " + a, 0, 0SHOWSCREENKEYWAIT`

#### Scott_AW

• Mr. Polyvector
• Posts: 214
##### Re: Operator bitwise right shift
« Reply #5 on: 2010-May-03 »
Inline is a wonderful thing.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

#### josemym2

• Guest
##### Re: Operator bitwise right shift
« Reply #6 on: 2010-May-03 »
Thanks a lot.

« Last Edit: 2010-May-03 by josemym2 »