Skip to main content

Abs

Returns the absolute value of the input.

Abs block

Description

The Abs block returns the absolute value of the input. This is a code block from the Math drawer.

Usage

Returns the absolute value of the input.

Syntax

Inputs in this block:

  • A number

Example

This is a model of molecules moving inside of a container. To ensure that the molecules stay within the bounds set by the volume slider, their position is calculated and corrected using the 'bounce' function. The absolute value button is used to make sure the molecules do not go outside the volume on either the negative or the positive x.

Abs example code
  • Difference - Returns the difference between two numbers
  • Sqrt - Returns the square root of a number