User Tools

Site Tools


cubloc:abs:index

Abs

The Abs function returns the absolute value of a Long integer. In other words, it removes any negative sign and returns the magnitude of the number. This is especially useful in calculations where only the size of a value matters, regardless of whether it was originally positive or negative—such as distance, difference comparisons, error magnitudes, or general numeric normalization.

When Abs is applied to a negative number, it converts it to its positive equivalent. If the value is already positive (or zero), it is returned unchanged.

Example

Dim A As Long, B As Long
B = -1234
A=Abs B      ' Return |B|.
Debug Dec A  ' Print 1234

Explanation:

  • B is assigned the value -1234.
  • Abs B evaluates to 1234, because the absolute value strips the negative sign.
  • The result is stored in A, and the Debug Dec A statement outputs 1234.

See also FAbs.

Go CUBLOC home

cubloc/abs/index.txt · Last modified: by 127.0.0.1