Skip to main content

Math Operators

C

// Addition
a + b;

// Subtraction
a – b;

// Multiplication
a * b;

// Division & Floor Division
a / b; // If both are Integers, result will be a Integer
a / b * 1.0; // If you want an float result, you can multiply one of them to 1.0
(float) a / b; // Or, you can also use a simple type cast

// Exponent
// Not Available
// Use math.h library

// Modulus
a % b; // It returns the "remainder" after the division (modulo division)

Back to top

C++ (Cpp)

// Addition
a + b;

// Subtraction
a – b;

// Multiplication
a * b;

// Division & Floor Division
a / b; // If both are Integers, result will be a Integer
a / b * 1.0; // If you want an float result, you can multiply one of them to 1.0
static_cast<float>(a) / b; // Or, you can also use a C++ static cast

// Exponent
// Not Available

// Modulus
a % b; // It returns the "remainder" after the division (modulo division)

Back to top

C# (Csharp)

// Addition
a + b;

// Subtraction
a – b;

// Multiplication
a * b;

// Division & Floor Division
a / b; // If both are Integers, result will be a Integer
a / b * 1.0; // If you want an float result, you can multiply one of them to 1.0
(float) a / b; // Or, you can also use a simple type cast

// Exponent
// Not Available

// Modulus
a % b; // It returns the "remainder" after the division (modulo division)

Back to top

Java

// Addition
a + b;

// Subtraction
a – b;

// Multiplication
a * b;

// Division & Floor Division
a / b; // If both are Integers, result will be a Integer
a / b * 1.0; // If you want an float result, you can multiply one of them to 1.0
(float) a / b; // Or, you can also use a simple type cast

// Exponent
// Not Available

// Modulus
a % b; // It returns the "remainder" after the division (modulo division)

Back to top

Rust

// TODO

Back to top

Go

// TODO

Back to top

Javascript

// TODO

Back to top

Typescript

// TODO

Back to top

Python

# Addition
a + b

# Subtraction
a – b

# Multiplication
a * b

# Division
a / b # Result will be a Float

#Floor Division
a // b # Result will be a Integer

# Exponent
a ** b

# Modulus
a % b # It returns the "remainder" after the division (modulo division)

Back to top