Search…
Operators
V supports the following operators:

Basic Operators

  • + (addition) for int, float and string
  • - (subtraction) for int and float
  • * (multiplication) for int and float
  • / (division) for int and float
  • % (modulos) for int
  • = (assignment) for changing values
  • := for initialising values
1
println(3 + 5)
2
println(2.0 + 5.0)
3
println('hello' + 'world')
4
5
println(9 - 10)
6
println(7.0 - 5.0)
7
8
println(3 * 5)
9
println(2.0 * 4)
10
11
println(23 / 3)
12
println(25.0 / 5.0)
13
14
println(27 % 5)
15
println(27 % 3)
Copied!
Output
1
8
2
7.0
3
hello world
4
5
-1
6
2.0
7
8
15
9
8.0
10
11
7
12
5.0
13
14
2
15
0
Copied!
Note: Unlike other languages, V doesn't allow modulus with float.

Comparison Operators

  • > greater than
  • < lesser than
  • == equal to
  • >= greater than or equal to
  • <= lesser than or equal to
  • != not equal to

Boolean Operators

  • && and
  • || or
  • ! not

Bitwise Operators

  • << left bitshift
  • >> right bitshift
  • & bitwise and
  • | bitwise or
  • ^ bitwise xor

Assignments Operators

  • += same as foo = foo + var
  • -= same as foo = foo - var
  • *= same as foo = foo * var
  • /= same as foo = foo / var
  • &= same as foo = foo & var
  • |= same as foo = foo | var
  • >>= same as foo = foo >> var
  • <<= same as foo = foo << var

Special Operators

  • in for membership
  • none for optional