Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation from source code
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Arithmetical Functions
Arithmetic Operators
Array Declaration
Assignment Operators
Assignments
Binary Data Representation
Bits Manipulation Functions
Character Test Functions
Comparison methods
Complex numbers
Constant Declaration
Constant Expression
Conversion Functions
Datatype Functions
Datatypes
Date & Time Functions
Enumeration declaration
Error Management
Event Loop
Event Management
Events declaration
Expressions
External Function Management
File & Directory Functions
File & Directory Paths
File mode syntax
Floating Point Numbers
Formatting functions
Gambas Object Model
Global Special Event Handlers
Integer numbers
Intrinsic Functions
Language Constants
Localization and Translation Functions
Local Variable Declaration
Logarithms & Exponentials Functions
Logical Operators
Loop Control Structures
Method Declaration
Miscellaneous Control Structures
Miscellaneous Functions
Native Arrays
Native Container Classes
Object & Class Management
Operator Evaluation Order
Predefined Constants
Process Management
Property Declaration
Random Numbers Functions
Special Methods
Stream & Input/Output functions
String Functions
String Operators
Structure declaration
Test Control Structures & Functions
Trigonometric Functions
User-defined formats
Using reserved keywords as identifiers
Variable Declaration
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Arithmetic Operators

Number + Number Adds two numbers.
- Number Computes the opposite sign of a number. Zero is the opposite of itself.
Number - Number Subtracts two numbers.
Number * Number Multiplies two numbers.
Number / Number Divides two numbers, and returns the result as a floating-point number. A Division By Zero (26) error will occur if the value of the number to the right of the slash is zero.
Number ^ Power Raises Number to the power Power.

For example, 4 ^ 3 = 64
Number \ Number

Number DIV Number
Computes the quotient of the two Integer numbers, truncating the result. A Division By Zero (26) error will occur if the value of the number to the right of the backslash is zero.

For example, 13 \ 6 = 2

A \ B = Int(A / B)
Number % Number

Number MOD Number
Computes the remainder of the quotient of the two numbers. A Division By Zero (26) error will occur if the value of the number to the right of the operator MOD is zero.

Comparison

Number = Number Returns TRUE if two numbers are equal.
Number <> Number Returns TRUE if two numbers are different.
Number1 < Number2 Returns TRUE if Number1 is strictly lower than Number2.
Number1 > Number2 Returns TRUE if Number1 is strictly greater than Number2.
Number1 <= Number2 Returns TRUE if Number1 is lower or equal than Number2.
Number1 >= Number2 Returns TRUE if Number1 is greater or equal than Number2.

If the result of a Comparison is assigned to an integer variable, then the result is either -1 (True) or 0 (False)

See also