# Numeric Functions

> [HTML Version](numericfunctions.htm)

_Updated February 2023; see History_

These functions all return numeric values, although some may operate on string arguments.

| | |
|------|------|
| **Function** | **Description** |
| ABS(x) | Returns absolute value of _x_.  |
| EXP(x) | Returns the constant e (2.718218285) raised to the power _x_.  |
| FACT(x) | Returns the factorial of _x_.  |
| FIX(x) | Returns the integer part of the floating point value _x_. See _History_. |
| [IFE()](ife()andife$().md) | Ternary function; returns one of two parameters based on value of first. |
| [IFELSE()](ifelseandifelse$().md) | Ternary function; returns one of two parameters based on condition. |
| INT(x) | Returns the largest integer less than or equal to _x_. FIX() and INT() are same for positive numbers, but differ for negative numbers. See _History_. |
| LEN(a\$) | Returns the length of a\$. See in [String Functions](string_functions.md). |
| LOG(x) | Returns the natural (base e) log of _x_. |
| LOG10(x) | Returns the decimal logarithm of _x_. |
| NUMEXPR() | See in [String Functions](string_functions.md). |
| [RND(x)](randomnumbergenerators.md) | Returns a random number. |
| [RND2()](randomnumbergenerators.md) | Enhanced version of RND(x).  |
| [SRND2()](randomnumbergenerators.md) | Initializes the RND(x) generator. |
| SGN(x) | Returns the sign of _x_: -1 if _x_ < 0, 0 if _x_ = 0, 1 if _x_ > 0.  |
| SQR(x) | Returns the square root of _x_. |
| [VAL()](val()andval$().md) | Returns the decimal value of a string.  |




**History**

2025 January, A-Shell 7.0.1767.0:  The fudge factor described above for INT() and FIX() may now be completely disabled by calling  MX\_ROUND with a factor of -1.  

2023 February, A-Shell 6.5.1724:  INT() and FIX() update. When FPROUND is not set, these functions now apply a fudge factor of .0000005 (one tenth of the standard FPROUND factor). This minimizes the problem illustrated whereby an expression like INT(140.4\*100) might result in 14039 rather than 14040. The discrepancy is caused by the inherent imprecision of binary floating point representation of decimal fractions—e.g., 14039.999999975 instead of 14040.0). 

There are various other ways to deal with this issue, including setting the FPROUND option, but the issue continues to catch programmers by surprise; this automatic adjustment should minimize that problem. But note that it only works for numbers up to about 8 significant digits, after which the tiny fudge factor becomes too small to matter. If you regularly work with larger numbers and aren't explicitly dealing with rounding within the application, you may want to set your rounding factor somewhat higher. See "Rounding of Floating Point Variables" in the A-Shell reference for more details..

2016 July, A-Shell 6.3.1517:  Add second random number generator, RND2 and SRND2.

**Subtopics**

- [Random Number Generators](randomnumbergenerators.md)