CSML Reference
  • Introduction
  • Installing CSML
  • Sending and Receiving Messages
    • Message Payloads
    • Custom Components
  • The Event
  • Memory
    • Using Variables in Messages
    • Temporary and Long-Term variables
    • Global variables
  • Navigating in a CSML Bot
  • Conditional Logic
  • External Code Execution
  • Native CSML Functions
  • Value Types
  • Automatic Type Inference
  • 📑CSML Studio Documentation
  • Standard Library
    • Keywords
    • Built-in Functions
    • HTTP Client
    • SMTP Client
    • Crypto Utilities
      • JWT
      • Hash, HMAC
      • Base64, Hex
    • String methods
    • Array methods
    • Object methods
    • Number methods
    • Generic methods
Powered by GitBook
On this page
  • .pow(Number)
  • .abs()
  • .cos(), .sin(), .tan()
  • .floor(), .ceil(), .round()
  • .precision(n)

Was this helpful?

Edit on Git
Export as PDF
  1. Standard Library

Number methods

Although CSML differentiates between Float and Integer, all methods are available on all Number types. Hence, the Number type does not really exist but represents indifferently Float and Integer.

Given the automatic type inference, CSML will automatically try to map integers and floats to whichever type makes more sense in the context.

.pow(Number)

Raise the target integer to the power of the given integer.

number.pow(Number) => Number

// example
do val = 3
do val.pow(2) // 9

.abs()

Return the absolute value of the target number.

integer.abs() => Number

// example
do val = -42
do val.abs() // 42

.cos(), .sin(), .tan()

Return the cosine, sine or tangent of the target number.

float.cos() => Float
float.sin() => Float

// example
do val = 12.34
do val.cos() // 0,9744873988
do val.sin() // -0,224442219
do val.tan() // -0,2303182363

.floor(), .ceil(), .round()

Round the number respectively down, up or using mathematical rounding.

float.floor() => Integer
float.ceil() => Integer
float.round() => Integer

// example
do val = 10.5
do val.floor() // 10
do val.ceil() // 11
do val.round() // 11

.precision(n)

do val = 1.234567.precision(2) // 1.23
PreviousObject methodsNextGeneric methods

Last updated 3 years ago

Was this helpful?