vipsi - the friendly vip script interpreter

Operators

Bitwise shift left "<<"

<number> = <number> << <number>

Shift left-side Glossary: number, num_valnumber bitwise left right-side Glossary: number, num_valnumber times.

List functions: thisThis may yield a fractional Glossary: number, num_valnumber! Flow control: if … then
Flow control: try … then
The
right-side Glossary: Operator
Glossary: Operand
operand
may be negative but Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
fractional. It will be forced to an integer. List functions: thisThis works for any Glossary: number, num_valnumber of any size, even fractional Data Types: Numbersnumbers. Flow control: if … then
Flow control: try … then
The
effect is that of multiplying Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable by a power of 2, Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
, more techi, incrementing Flow control: if … then
Flow control: try … then
the
Number literals: Floating pointfloating point exponent by Flow control: if … then
Flow control: try … then
the
given Glossary: number, num_valnumber.

Flow control: if … thenIf any of both Vipsi command syntax: Arguments
Glossary: Arguments
arguments
is a Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
, Flow control: if … then
Flow control: try … then
then
it is evaluated as Glossary: number, num_valnumber.

Flow control: if … thenIf any of both is a Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
list
, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
operation is performed on all items. Recursively.

e.g.:

vipsi> Instructions: putput 8<<2  32
vipsi>  

Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
note
:

Flow control: if … then
Flow control: try … then
The
shift Vipsi command syntax: Operators
Operators
Glossary: Operator
operator
multiplies/Operators: Divide with Variable "/="
Operators: Divide "/"
divides
Flow control: if … then
Flow control: try … then
the
Glossary: number, num_valnumber by a power of 2. List functions: thisThis is also true for negative Data Types: Numbersnumbers. Flow control: if … thenIf you expect a negative Glossary: number, num_valnumber to be stored as a -1 Operators: Bitwise Not "~"complement (as is common for Number literals: Integer numbersinteger numbers) you will fail here. Make Flow control: if … then
Flow control: try … then
the
Glossary: number, num_valnumber positive Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
force it into desired range by masking it with Vipsi command syntax: Operators
Operators
Glossary: Operator
operator
&.

vipsi> Instructions: putput -8<<2  -32
vipsi> Instructions: var
How does VScript::Value() work?: Var*&
var
a=-8
vipsi> Instructions: putput (a&$ffff)<<2 262112 vipsi> Instructions: putput Text functions: hexstrhexstr((a&$ffff)<<2,4) FFE0

Valid HTML   Valid CSS