number

number — attempts to convert an expression to a number.

Syntax

number (s_exp)

		

Arguments

s_exp

Any Gamma or Lisp expression.

Returns

A numeric representation of the s_exp if possible, otherwise zero.

Description

The function attempts to convert its argument to a number. Integer and floating point values remain untouched. String arguments are converted to numbers by attempting to read a number from the string starting at the first character in the string. The longest legal number at the beginning of the string is used. All other data types return zero. If possible, the result will be an integer. If the result cannot be represented as an integer, a real (floating point) number is returned.

Example

Gamma> number(5);
5
Gamma> number("5.4m");
5.4000000000000003553
Gamma> number("m5.4");
0
Gamma> number(#a);
0
Gamma>