Arithmetic / Logic: Difference between revisions
(Created page with "= Arithmetic / Logic = The '''Arithmetic / Logic''' module provides essential mathematical operations and logical comparisons for the SCM programming language. This module includes: * '''Type checking''': Functions to verify data types (int?, number?, nil?) * '''Basic arithmetic''': Addition (+), subtraction (-), multiplication (*), and division (/) * '''Comparison operations''': All standard comparison operators (>, <, >=, <=, equal?) * '''Logical operations''': Boole...") |
(No difference)
|
Latest revision as of 18:30, 25 August 2025
Arithmetic / Logic
The Arithmetic / Logic module provides essential mathematical operations and logical comparisons for the SCM programming language. This module includes:
- Type checking: Functions to verify data types (int?, number?, nil?)
- Basic arithmetic: Addition (+), subtraction (-), multiplication (*), and division (/)
- Comparison operations: All standard comparison operators (>, <, >=, <=, equal?)
- Logical operations: Boolean negation (!, not) and advanced equality checks
- Mathematical functions: Min/max operations and rounding functions (floor, ceil, round)
These functions form the mathematical foundation for calculations and logical decision-making in SCM programs.
← Back to Full SCM API documentation
int?
tells if the value is a integer
Allowed number of parameters: 1–1
Parameters:
- value (
any
): value
Returns: bool
number?
tells if the value is a number
Allowed number of parameters: 1–1
Parameters:
- value (
any
): value
Returns: bool
+
adds two or more numbers
Allowed number of parameters: 2–1000
Parameters:
- value... (
number
): values to add
Returns: number
-
subtracts two or more numbers from the first one
Allowed number of parameters: 2–1000
Parameters:
- value... (
number
): values
Returns: number
*
multiplies two or more numbers
Allowed number of parameters: 2–1000
Parameters:
- value... (
number
): values
Returns: number
/
divides two or more numbers from the first one
Allowed number of parameters: 2–1000
Parameters:
- value... (
number
): values
Returns: number
<=
compares two numbers or strings
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
<
compares two numbers or strings
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
>
compares two numbers or strings
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
>=
compares two numbers or strings
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
equal?
compares two values of the same type, (equal? nil nil) is true
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
equal??
performs a SQL compliant sloppy equality check on primitive values (number, int, string, bool. nil), strings are compared case insensitive, (equal? nil nil) is nil
Allowed number of parameters: 2–2
Parameters:
- value... (
any
): values
Returns: bool
!
negates the boolean value
Allowed number of parameters: 1–1
Parameters:
- value (
bool
): value
Returns: bool
not
negates the boolean value
Allowed number of parameters: 1–1
Parameters:
- value (
bool
): value
Returns: bool
nil?
returns true if value is nil
Allowed number of parameters: 1–1
Parameters:
- value (
any
): value
Returns: bool
min
returns the smallest value
Allowed number of parameters: 1–1000
Parameters:
- value... (
number|string
): value
Returns: number|string
max
returns the highest value
Allowed number of parameters: 1–1000
Parameters:
- value... (
number|string
): value
Returns: number|string
floor
rounds the number down
Allowed number of parameters: 1–1
Parameters:
- value (
number
): value
Returns: number
ceil
rounds the number up
Allowed number of parameters: 1–1
Parameters:
- value (
number
): value
Returns: number
round
rounds the number
Allowed number of parameters: 1–1
Parameters:
- value (
number
): value
Returns: number