Skip to content

Operations

Binary Operations

Arithmetic operations are fundamental mathematical operations available in any programming language.
Supported Types: integer types / float types / and structs
(for structures see Structures Implementations)

Table of Supported Binary Operations:

OperatorNameDescriptionLimitations
+AddAdds to constants togetherType Size Limits
-MinusSubtracts one number from anotherType Size Limits
*MultiplyMultiplies two numbersType Size Limits
/DivideDivides one number by anotherType Size Limits, Division By Zero
%ModulusReturns the remainder of the divisionType Size Limits, Division By Zero

Example:

deen
fn main() i32 {
  println!("{}", 15 + 7);
  println!("{}", 15 - 7);
  println!("{}", 15 * 7);
  println!("{}", 15 / 7);
  println!("{}", 15 % 7);

  return 0;
}
22
8
105
2
1

Unary Operations

Unary operations involve a single operand.
Supported Types: integer types / float types / structs
(for structures see Structures Implementations)

Table of Supported Unary Operations:

OperatorNameDescriptionLimitations
-NegativeNegates provided expressionType Size Limits
!NotApplies logical NOT to provided expressionType Size Limits
deen
fn main() i32 {
  println!("{}", -15);
  println!("{}", !15);

  return 0;
}
-15
-16

Boolean Operations

Comparison and logical operations return a boolean output.
Supported Types: integer types / float types / char / *char / structs
(for structures see Structures Implementations)

Table of Supported Boolean Operations:

OperatorNameDescription
>Bigger ThanReturns true if LHS is bigger than RHS
<Less ThanReturns true if LHS is less than RHS
==EqualsReturns true if LHS equals RHS
=>, >=Equals Or BiggerReturns true if LHS equals or bigger than RHS
<=, =<Equals Or LessReturns true if LHS equals or less than RHS
!=Not EqualsReturns true if LHS not equals RHS
&&AndReturns true if LHS and RHS is true
||OrReturns true if LHS or RHS is true
deen
fn main() i32 {
  println!("{}" 10 > 5);
  println!("{}" 10 < 5);
  println!("{}" 10 == 5);
  println!("{}" 10 => 5);
  println!("{}" 10 <= 5);
  println!("{}" 10 != 5);
  println!("{}" 10 == 0 && 5 == 0);
  println!("{}" 10 == 0 || 5 == 0);

  return 0;
}
true
false
false
true
false
true
false
false

Bitwise Operations

Bitwise operations manipulate the individual bits of numbers.
Supported Types: integer types

Table Of Supported Bitwise Operations:

OperatorNameDescription
&AndCopies bit to the result if it exists in both operands
|OrCopies bit to the result if it exists in either operand
^XorCopies the bit if it set in one operand but not both
<<Left ShiftShifts bits to left by provided index
>>Right ShiftShifts bits to right by provided index
deen
fn main() i32 {
  println!("{}", 100 & 25);
  println!("{}", 10 & 100);
  println!("{}", 20 ^ 10);
  println!("{}", 1 << 2);
  println!("{}", 10 >> 2);

  return 0;
}
0
0
30
4
2