Skip to main content

number

Numbers in Soul represent numeric values using high-precision decimal arithmetic. They can be integers or floating-point numbers and support all standard arithmetic operations.

Basic Number Literals

Create numbers with literal notation:

Arithmetic Operations

Perform basic arithmetic with numbers:

Number Precision

Soul uses high-precision decimal arithmetic to avoid floating-point errors:

Number Methods

Common number operations:

Number Comparisons

Compare numbers using comparison operators:

Number Validation

Check if values are valid numbers:

Number Parsing

Convert strings to numbers:

Number Formatting

Format numbers for display:

Mathematical Operations

Common mathematical functions:

Number Ranges

Work with number ranges:

Number Sequences

Generate number sequences:

Number Aggregation

Calculate aggregate values:

Number Constants

Define useful number constants:

Number Utilities

Utility functions for numbers:

Number Conversion

Convert between different number representations:

Number Error Handling

Handle number-related errors:

Best Practices

  1. Use appropriate precision: Choose the right precision for your use case
  2. Validate inputs: Check for null and invalid numbers
  3. Handle edge cases: Consider zero, negative numbers, and infinity
  4. Use constants: Define meaningful constants for magic numbers
  5. Format for display: Format numbers appropriately for user interfaces
Numbers are fundamental to most Soul applications. Use them with proper validation, error handling, and appropriate precision for reliable and accurate calculations.