Operators
V supports the following 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
println(3 + 5)
println(2.0 + 5.0)
println('hello' + 'world')
println(9 - 10)
println(7.0 - 5.0)
println(3 * 5)
println(2.0 * 4)
println(23 / 3)
println(25.0 / 5.0)
println(27 % 5)
println(27 % 3)
Output
8
7.0
hello world
-1
2.0
15
8.0
7
5.0
2
0
Note: Unlike other languages, V doesn't allow modulus with float.
>
greater than<
lesser than==
equal to>=
greater than or equal to<=
lesser than or equal to!=
not equal to
&&
and||
or!
not
<<
left bitshift>>
right bitshift&
bitwise and|
bitwise or^
bitwise xor
+=
same asfoo = foo + var
-=
same asfoo = foo - var
*=
same asfoo = foo * var
/=
same asfoo = foo / var
&=
same asfoo = foo & var
|=
same asfoo = foo | var
>>=
same asfoo = foo >> var
<<=
same asfoo = foo << var
in
for membershipnone
for optional
Last modified 3yr ago