<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=KOTLIN%3A_Operator</id>
	<title>KOTLIN: Operator - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=KOTLIN%3A_Operator"/>
	<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;action=history"/>
	<updated>2026-04-08T18:32:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.4</generator>
	<entry>
		<id>https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65946&amp;oldid=prev</id>
		<title>Onnowpurbo at 02:44, 29 July 2022</title>
		<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65946&amp;oldid=prev"/>
		<updated>2022-07-29T02:44:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;amp;diff=65946&amp;amp;oldid=65884&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65884&amp;oldid=prev</id>
		<title>Onnowpurbo at 03:45, 22 July 2022</title>
		<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65884&amp;oldid=prev"/>
		<updated>2022-07-22T03:45:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;amp;diff=65884&amp;amp;oldid=65789&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65789&amp;oldid=prev</id>
		<title>Onnowpurbo: Created page with &quot;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_operators.htm    An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations...&quot;</title>
		<link rel="alternate" type="text/html" href="https://onnocenter.or.id/wiki/index.php?title=KOTLIN:_Operator&amp;diff=65789&amp;oldid=prev"/>
		<updated>2022-07-18T01:16:49Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_operators.htm    An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_operators.htm&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Kotlin is rich in built-in operators and provide the following types of operators:&lt;br /&gt;
&lt;br /&gt;
Arithmetic Operators&lt;br /&gt;
&lt;br /&gt;
Relational Operators&lt;br /&gt;
&lt;br /&gt;
Assignment Operators&lt;br /&gt;
&lt;br /&gt;
Unary Operators&lt;br /&gt;
&lt;br /&gt;
Logical Operators&lt;br /&gt;
&lt;br /&gt;
Bitwise Operations&lt;br /&gt;
&lt;br /&gt;
Now let's look into these Kotlin Operators one by one.&lt;br /&gt;
&lt;br /&gt;
(a) Kotlin Arithmetic Operators&lt;br /&gt;
Kotlin arithmetic operators are used to perform basic mathematical operations such as addition, subtraction, multiplication and division etc.&lt;br /&gt;
&lt;br /&gt;
Operator	Name	Description	Example&lt;br /&gt;
+	Addition	Adds together two values	x + y&lt;br /&gt;
-	Subtraction	Subtracts one value from another	x - y&lt;br /&gt;
*	Multiplication	Multiplies two values	x * y&lt;br /&gt;
/	Division	Divides one value by another	x / y&lt;br /&gt;
%	Modulus	Returns the division remainder	x % y&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin Arithmetic Operators:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val x: Int = 40&lt;br /&gt;
   val y: Int = 20&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;x + y = &amp;quot; +  (x + y))&lt;br /&gt;
   println(&amp;quot;x - y = &amp;quot; +  (x - y))&lt;br /&gt;
   println(&amp;quot;x / y = &amp;quot; +  (x / y))&lt;br /&gt;
   println(&amp;quot;x * y = &amp;quot; +  (x * y))&lt;br /&gt;
   println(&amp;quot;x % y = &amp;quot; +  (x % y))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x + y = 60&lt;br /&gt;
x - y = 20&lt;br /&gt;
x / y = 2&lt;br /&gt;
x * y = 800&lt;br /&gt;
x % y = 0&lt;br /&gt;
(b) Kotlin Relational Operators&lt;br /&gt;
Kotlin relational (comparison) operators are used to compare two values, and returns a Boolean value: either true or false.&lt;br /&gt;
&lt;br /&gt;
Operator	Name	Example&lt;br /&gt;
&amp;gt;	greater than	x &amp;gt; y&lt;br /&gt;
&amp;lt;	less than	x &amp;lt; y&lt;br /&gt;
&amp;gt;=	greater than or equal to	x &amp;gt;= y&lt;br /&gt;
&amp;lt;=	less than or equal to	x &amp;lt;= y&lt;br /&gt;
==	is equal to	x == y&lt;br /&gt;
!=	not equal to	x != y&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin Relational Operators:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val x: Int = 40&lt;br /&gt;
   val y: Int = 20&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;x &amp;gt; y = &amp;quot; +  (x &amp;gt; y))&lt;br /&gt;
   println(&amp;quot;x &amp;lt; y = &amp;quot; +  (x &amp;lt; y))&lt;br /&gt;
   println(&amp;quot;x &amp;gt;= y = &amp;quot; +  (x &amp;gt;= y))&lt;br /&gt;
   println(&amp;quot;x &amp;lt;= y = &amp;quot; +  (x &amp;lt;= y))&lt;br /&gt;
   println(&amp;quot;x == y = &amp;quot; +  (x == y))&lt;br /&gt;
   println(&amp;quot;x != y = &amp;quot; +  (x != y))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x &amp;gt; y = true&lt;br /&gt;
x &amp;lt; y = false&lt;br /&gt;
x &amp;gt;= y = true&lt;br /&gt;
x &amp;lt;= y = false&lt;br /&gt;
x == y = false&lt;br /&gt;
x != y = true&lt;br /&gt;
(c) Kotlin Assignment Operators&lt;br /&gt;
Kotlin assignment operators are used to assign values to variables.&lt;br /&gt;
&lt;br /&gt;
Following is an example where we used assignment operator = to assign a values into two variables:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val x: Int = 40&lt;br /&gt;
   val y: Int = 20&lt;br /&gt;
   &lt;br /&gt;
   println(&amp;quot;x = &amp;quot; +  x)&lt;br /&gt;
   println(&amp;quot;y = &amp;quot; +  y)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x = 40&lt;br /&gt;
y = 20&lt;br /&gt;
Following is one more example where we used assignment operator += to add the value of self variable and assign it back into the same variable:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Int = 40&lt;br /&gt;
&lt;br /&gt;
   x += 10&lt;br /&gt;
      &lt;br /&gt;
   println(&amp;quot;x = &amp;quot; +  x)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x = 50&lt;br /&gt;
Following is a list of all assignment operators:&lt;br /&gt;
&lt;br /&gt;
Operator	Example	Expanded Form&lt;br /&gt;
=	x = 10	x = 10&lt;br /&gt;
+=	x += 10	x = x - 10&lt;br /&gt;
-=	x -= 10	x = x - 10&lt;br /&gt;
*=	x *= 10	x = x * 10&lt;br /&gt;
/=	x /= 10	x = x / 10&lt;br /&gt;
%=	x %= 10	x = x % 10&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin Assignment Operators:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Int = 40&lt;br /&gt;
&lt;br /&gt;
   x += 5&lt;br /&gt;
   println(&amp;quot;x += 5 = &amp;quot; + x )&lt;br /&gt;
   &lt;br /&gt;
   x = 40;&lt;br /&gt;
   x -= 5&lt;br /&gt;
   println(&amp;quot;x -= 5 = &amp;quot; +  x)&lt;br /&gt;
   &lt;br /&gt;
   x = 40&lt;br /&gt;
   x *= 5&lt;br /&gt;
   println(&amp;quot;x *= 5 = &amp;quot; +  x)&lt;br /&gt;
   &lt;br /&gt;
   x = 40&lt;br /&gt;
   x /= 5&lt;br /&gt;
   println(&amp;quot;x /= 5 = &amp;quot; +  x)&lt;br /&gt;
   &lt;br /&gt;
   x = 43&lt;br /&gt;
   x %= 5&lt;br /&gt;
   println(&amp;quot;x %= 5 = &amp;quot; + x)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x += 5 = 45&lt;br /&gt;
x -= 5 = 35&lt;br /&gt;
x *= 5 = 200&lt;br /&gt;
x /= 5 = 8&lt;br /&gt;
x %= 5 = 3&lt;br /&gt;
(d) Kotlin Unary Operators&lt;br /&gt;
The unary operators require only one operand; they perform various operations such as incrementing/decrementing a value by one, negating an expression, or inverting the value of a boolean.&lt;br /&gt;
&lt;br /&gt;
Following is the list of Kotlin Unary Operators:&lt;br /&gt;
&lt;br /&gt;
Operator	Name	Example&lt;br /&gt;
+	unary plus	+x&lt;br /&gt;
-	unary minus	-x&lt;br /&gt;
++	increment by 1	++x&lt;br /&gt;
--	decrement by 1	--x&lt;br /&gt;
!	inverts the value of a boolean	!x&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin Unary Operators:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Int = 40&lt;br /&gt;
   var b:Boolean = true&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;+x = &amp;quot; +  (+x))&lt;br /&gt;
   println(&amp;quot;-x = &amp;quot; +  (-x))&lt;br /&gt;
   println(&amp;quot;++x = &amp;quot; +  (++x))&lt;br /&gt;
   println(&amp;quot;--x = &amp;quot; +  (--x))&lt;br /&gt;
   println(&amp;quot;!b = &amp;quot; +  (!b))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
+x = 40&lt;br /&gt;
-x = -40&lt;br /&gt;
++x = 41&lt;br /&gt;
--x = 40&lt;br /&gt;
!b = false&lt;br /&gt;
Here increment (++) and decrement (--) operators can be used as prefix as ++x or --x as well as suffix as x++ or x--. The only difference between the two forms is that in case we use them as prefix then operator will apply before expression is executed, but if use them as suffix then operator will apply after the expression is executed.&lt;br /&gt;
&lt;br /&gt;
(e) Kotlin Logical Operators&lt;br /&gt;
Kotlin logical operators are used to determine the logic between two variables or values:&lt;br /&gt;
&lt;br /&gt;
Following is the list of Kotlin Logical Operators:&lt;br /&gt;
&lt;br /&gt;
Operator	Name	Description	Example&lt;br /&gt;
&amp;amp;&amp;amp;	Logical and	Returns true if both operands are true	x &amp;amp;&amp;amp; y&lt;br /&gt;
||	Logical or	Returns true if either of the operands is true	x || y&lt;br /&gt;
!	Logical not	Reverse the result, returns false if the operand is true	!x&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin Logical Operators:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Boolean = true&lt;br /&gt;
   var y:Boolean = false&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;x &amp;amp;&amp;amp; y = &amp;quot; +  (x &amp;amp;&amp;amp; y))&lt;br /&gt;
   println(&amp;quot;x || y = &amp;quot; +  (x || y))&lt;br /&gt;
   println(&amp;quot;!y = &amp;quot; +  (!y))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x &amp;amp;&amp;amp; y = false&lt;br /&gt;
x || y = true&lt;br /&gt;
!y = true&lt;br /&gt;
(e) Kotlin Bitwise Operations&lt;br /&gt;
Kotlin does not have any bitwise operators but Kotlin provides a list of helper functions to perform bitwise operations.&lt;br /&gt;
&lt;br /&gt;
Following is the list of Kotlin Bitwise Functions:&lt;br /&gt;
&lt;br /&gt;
Function	Description	Example&lt;br /&gt;
shl (bits)	signed shift left	x.shl(y)&lt;br /&gt;
shr (bits)	signed shift right	x.shr(y)&lt;br /&gt;
ushr (bits)	unsigned shift right	x.ushr(y)&lt;br /&gt;
and (bits)	bitwise and	x.and(y)&lt;br /&gt;
or (bits)	bitwise or	x.or(y)&lt;br /&gt;
xor (bits)	bitwise xor	x.xor(y)&lt;br /&gt;
inv()	bitwise inverse	x.inv()&lt;br /&gt;
Example&lt;br /&gt;
Following example shows different calculations using Kotlin bitwise functions:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x:Int = 60	  // 60 = 0011 1100  &lt;br /&gt;
   var y:Int = 13	  // 13 = 0000 1101&lt;br /&gt;
   var z:Int&lt;br /&gt;
&lt;br /&gt;
   z = x.shl(2)       // 240 = 1111 0000&lt;br /&gt;
   println(&amp;quot;x.shl(2) = &amp;quot; +  z)&lt;br /&gt;
   &lt;br /&gt;
   z = x.shr(2)       // 15 = 0000 1111&lt;br /&gt;
   println(&amp;quot;x.shr(2) = &amp;quot; +  z)&lt;br /&gt;
   &lt;br /&gt;
   z = x.and(y)       // 12 = 0000 1100&lt;br /&gt;
   println(&amp;quot;x.and(y)  = &amp;quot; +  z)&lt;br /&gt;
   &lt;br /&gt;
   z = x.or(y)        // 61 = 0011 1101&lt;br /&gt;
   println(&amp;quot;x.or(y)  = &amp;quot; +  z)&lt;br /&gt;
   &lt;br /&gt;
   z = x.xor(y)       // 49 = 0011 0001&lt;br /&gt;
   println(&amp;quot;x.xor(y)  = &amp;quot; +  z)&lt;br /&gt;
   &lt;br /&gt;
   z = x.inv()        // -61 = 1100 0011&lt;br /&gt;
   println(&amp;quot;x.inv()  = &amp;quot; +  z)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
x.shl(2) = 240&lt;br /&gt;
x.shr(2) = 15&lt;br /&gt;
x.and(y) = 12&lt;br /&gt;
x.or(y) = 61&lt;br /&gt;
x.xor(y) = 49&lt;br /&gt;
x.inv() = -61&lt;br /&gt;
Quiz Time (Interview &amp;amp; Exams Preparation)&lt;br /&gt;
Q 1 - What does the Kotlin operator % do?&lt;br /&gt;
&lt;br /&gt;
A - It is used to divide a number by another number.&lt;br /&gt;
&lt;br /&gt;
B - Kotlin does not support any such operator&lt;br /&gt;
&lt;br /&gt;
C - This is bitwise XOR operator&lt;br /&gt;
&lt;br /&gt;
D - This is called modulus operator and returns the division remainder.&lt;br /&gt;
&lt;br /&gt;
Q 2 - Kotlin supports a good number of bitwise operators&lt;br /&gt;
&lt;br /&gt;
A - Correct&lt;br /&gt;
&lt;br /&gt;
B - Incorrect&lt;br /&gt;
&lt;br /&gt;
Q 3 - What does Kotlin operator ++ do?&lt;br /&gt;
&lt;br /&gt;
A - It is used to add two values&lt;br /&gt;
&lt;br /&gt;
B - There is no any such operators like ++ in Kotlin&lt;br /&gt;
&lt;br /&gt;
C - This is called unary increment operator&lt;br /&gt;
&lt;br /&gt;
D - None of the above&lt;br /&gt;
&lt;br /&gt;
Q 4 - Which of the following function will do bitwise right shift operation?&lt;br /&gt;
&lt;br /&gt;
A - x.ushr(y)&lt;br /&gt;
&lt;br /&gt;
B - x.shr(y)&lt;br /&gt;
&lt;br /&gt;
C - x.shl(y)&lt;br /&gt;
&lt;br /&gt;
D - None of the above&lt;br /&gt;
&lt;br /&gt;
Q 5 - Which of the following is a logical inverse operator:&lt;br /&gt;
&lt;br /&gt;
A - inv()&lt;br /&gt;
&lt;br /&gt;
B - !&lt;br /&gt;
&lt;br /&gt;
C - &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
D - ||&lt;br /&gt;
&lt;br /&gt;
Q 6 - What will be the output of the following Kotlin code:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Int = 40&lt;br /&gt;
&lt;br /&gt;
   x += 10&lt;br /&gt;
&lt;br /&gt;
   println(x)&lt;br /&gt;
}&lt;br /&gt;
A - 40&lt;br /&gt;
&lt;br /&gt;
B - Syntax Error&lt;br /&gt;
&lt;br /&gt;
C - 50&lt;br /&gt;
&lt;br /&gt;
D None of the above&lt;br /&gt;
&lt;br /&gt;
Q 7 - What will be the output of the following Kotlin code:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var x: Int = 60&lt;br /&gt;
&lt;br /&gt;
   println(x.shr(2))&lt;br /&gt;
}&lt;br /&gt;
A - 15&lt;br /&gt;
&lt;br /&gt;
B - Syntax Error&lt;br /&gt;
&lt;br /&gt;
C - 50&lt;br /&gt;
&lt;br /&gt;
D None of the above&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* https://www.tutorialspoint.com/kotlin/kotlin_operators.htm&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>