CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • If Statements
  • Comparison Functions
  • Natural and String Comparison
  • Deep & Elementwise Equality
  • Logical Functions
  • Notes for CalcTree
  1. Calculations
  2. Parameters
  3. Math formulas
  4. Native Functions

Logical & Comparison Functions

PreviousTrigonometric FunctionsNextMatrix & Vector Functions

Last updated 1 day ago

CalcTree supports standard logical and comparison functions using and .

These functions return true or false, and are often used in conditional expressions and ternary operations (e.g. a > b ? "yes" : "no").

If Statements

MathJS does not use a traditional if(...) {} structure. Instead, native CalcTree parameters support conditional logic using the ternary operator:

condition ? value_if_true : value_if_false

Example: Basic if logic

result = load > limit ? "Fail" : "Pass"

Nested conditions (like else if)

check = ratio < 1 ? "OK" : ratio < 1.5 ? "Warning" : "Fail"

Comparison Functions

Function
Description
CalcTree Example

equal(a, b)

Checks strict equality

equal(2, 2) → true

unequal(a, b)

Checks inequality

unequal(2, 3) → true

smaller(a, b)

Less than

smaller(1, 2) → true

smallerEq(a, b)

Less than or equal

smallerEq(2, 2) → true

larger(a, b)

Greater than

larger(3, 1) → true

largerEq(a, b)

Greater than or equal

largerEq(3, 3) → true

Natural and String Comparison

Function
Description
CalcTree Example

compare(a, b)

General numerical comparison

compare(2, 3) → -1

compareText(a, b)

Lexical string comparison

compareText("a", "b") → -1

compareNatural(a, b)

Natural-order comparison (e.g., v1 < v2)

compareNatural("2", "10") → -1

Deep & Elementwise Equality

Function
Description
CalcTree Example

deepEqual(a, b)

Element-wise equality for arrays/matrices

deepEqual([1, 2], [1, 2]) → true

equalText(a, b)

Text string equality

equalText("abc", "abc") → true

Logical Functions

Function
Description
CalcTree Example

and(a, b)

Logical AND

and(true, true) → true

or(a, b)

Logical OR

or(false, true) → true

not(a)

Logical NOT

not(true) → false

xor(a, b)

Exclusive OR

xor(true, false) → true

Notes for CalcTree

  • Logical outputs (true, false) can be used in conditional formulas like:

    result = load > limit ? "Fail" : "Pass"
  • For multi-value comparisons (e.g. arrays), use deepEqual() instead of equal().

  • Comparisons between unit-bearing quantities must be dimensionally consistent (e.g. 2 m > 1 m is valid, 2 m > 1 kg is not).

📘 Looking for more functions? CalcTree’s expression engine is powered by . For a full list of available functions, visit the . Most functions listed there are supported in CalcTree unless otherwise noted.

MathJS syntax
comparison operators
MathJS
MathJS Function Reference