Division Operator (/)

Summary

Divides two numbers.

Syntax

expression1 / expression2

Parameters

expression1
An expression that evaluates to a number.
expression2
An expression that evaluates to a number.

Description

For numeric data, the / operator divides two numbers. For example, 8 / 2 will evaluate to the result 4. To calculate remainders from a division operation, use the modulus operator.

Differences from JavaScript

  • If two integers are used in division, the result is an integer and will not be a floating point number.

  • In JS++, arithmetic cannot be performed on Booleans. In JavaScript, for these operations, false is treated as 0 and true is treated as 1.

  • In JS++, arithmetic operations cannot be performed on null. In JavaScript, null is treated as 0.

  • In JS++, undefined cannot be used in arithmetic operations. In addition, NaN can never occur from integer arithmetic. In JavaScript, an arithmetic expression that evaluates to undefined or NaN results in NaN for the result.

Examples

Basic Usage
1
2
3
4
import System;
 
Console.log(4 / 2); // 2
Console.log(8 / 2); // 4

See Also

Share

HTML | BBCode | Direct Link