Converts an object to a real number.
Xis any object
X is any complex number with zero imaginary part, then
X as an object of type
RealNumber; if the imaginary part is non-zero, an error is returned.
X is a vector, matrix, list, set, or structure – in each case containing only a single element which is a number with zero imaginary part – then this number is returned in the form of a real number object.
X is a string, an attempt is made to parse it as a real number. If successful, the parsed number is returned.
In all other cases,
RealNumber(X) returns an error.
'((n ≔ 687), (x ≔ RealNumber(n))) @ type
integer real number
RealNumber(❨❨5, 9, 3, 1❩❩ ⋅ ❨❨7❩, ❨2❩, ❨4❩, ❨0❩❩)
RealNumber(❨❨5, 9, 3, 1❩❩ ⋅ ❨❨7❩, ❨2❩, ❨4❩, ❨i❩❩)
Complex number 65 + i cannot be converted to a real number.
Call stack: RealNumber
'("3.14", "−5E6", ".57") @ RealNumber
3.14 −5000000 0.57
Type conversion functions (list)