What is >>> 0 in javascript?

I am using the corresponding Emscripten port of the LibTIFF C code called tiff.js from seikichi on github. In my code, I need to get some TIFF tags. In tiff.js, you can call tiff.getField (tag value). I want a specific ROWSPERSTRIP tag since 278, so I call the following to get that tag:

var rps = tiff.getField(278); //return rows per strip tiff tag

      

It seems that this is ok for some smaller values โ€‹โ€‹from 1 to 176 (not quite accurate yet?), But I have several files that AsTiffTagViewer reports as 224 lines per lane, and one file with 746 rows per lane. However, tiff.js receives messages of both of these values โ€‹โ€‹incorrectly as 6 and 1 respectively. I went through the debugger in tiff.js and noticed that it comes up with the following code:

do{if(b>>>0<=65535){d=e[j+24>>1]|0;if((1<<(d&31)&c[a+40+(d>>>5<<2)>>2)]|0)==0){k=0}else{break}i=f;return k|0}}while(0);

      

This is ugly, I suspect, because its the best Emscripten can do with C code. Now I know that "โ†’" and "<but I can't find anything about" โ†’> ". I don't know yet if this is a section of code in tiff.js that calls tiff.getField (278) to not return some larger strings in string values โ€‹โ€‹are wrong (all I know it looks like smaller strings in string values โ€‹โ€‹are returned correctly when larger values โ€‹โ€‹are returned incorrectly.

So my main question is what "โ†’>" is, and my second question is if anyone has any ideas as to why tiff.getField (278) might not work correctly for large values. NOTE. Most of the other basic TIFF tags return correct values โ€‹โ€‹like tiff.getField (PHOTOMETRIC) and tiff.getField (SAMPLESPERPIXLE) ... etc.

Thanks in advance for the ideas

+3


source to share


2 answers


This is a bitwise zero shift to the right, from MDN

This operator shifts the first operand the specified number of bits to the right. Excess bits shifted to the right are discarded. Zero bits are shifted to the left. The bit sign becomes 0, so the result is always non-negative.

For non-negative numbers, zero shift to the right and sign to the right shift gives the same result. For example, 9 โ†’> 2 gives 2, the same as 9 โ†’ 2:



As for why tiff.js doesn't work when you call tiff.getField(278)

, I have no idea, I think it should and there don't seem to be any known issues on the Github pages, but you can try adding the problem and see know whether the developers.

+6


source


-3 >>> 0

is an unsigned 0 bit right shift. That is, the number is converted into an integer unsigned 32 bits , unlike -3 | 0

that converts the number into a 32-bit integer with a sign.

-3 >>> 0 === 4294967293
-3 | 0 === -3

      



11.7.3 Unsigned Shift Operator (โ†’>)

Performs a bitwise offset zero padding operation on the left operand by the amount specified by the right operand.

The work ShiftExpression : ShiftExpression >>> AdditiveExpression

is evaluated as follows:

  • Let it lref

    be the result of the evaluation ShiftExpression

    .

  • Let lval

    be GetValue(lref)

    .

  • Let it rref

    be the result of the evaluation AdditiveExpression

    .

  • Let rval

    be GetValue(rref)

    .

  • Let lnum

    be ToUint32(lval

    ).

  • Let rnum

    be ToUint32(rval)

    .

  • Let it shiftCount

    be the result of masking all but the least significant 5 bits rnum

    , that is, computation rnum & 0x1F

    .

  • Returns the result of performing zero-padding of a zero- lnum

    bit shift shiftCount

    . Leaked bits are filled with zero. The result is an unsigned 32-bit integer.

+2


source







All Articles