Learn R Programming

flint (version 0.1.3)

TypeClass: Test What is Representable by a Type or Class

Description

isSigned tests if the type or class of the argument can represent nonzero numbers with sign (value divided by modulus) not equal to 1.

isComplex tests if the type or class of the argument can represent complex numbers with nonzero imaginary part.

isFloating tests if the type or class of the argument represents floating-point real or complex numbers.

Usage

isSigned(x)
isComplex(x)
isFloating(x)

Value

A logical, either TRUE or FALSE.

Arguments

x

a vector-like R object representing numbers.

Details

isSigned(x) equal to FALSE implies that sign(x) is all 0 or 1. The converse is not true in general.

isComplex(x) equal to FALSE implies that Imag(x) (equivalently Im(x)) is all 0. The converse is not true in general.

For x of class arb or acb, methods inherit behaviour from the class of the midpoint, returning the value of is*(Mid(x)).

See Also

Virtual class flint.

Examples

Run this code
try(isSigned(NULL)) # an error if 'x' does not represent numbers

L <- sapply(c(if (getRversion() >= "4.5") "raw", # for as(NULL, "raw")
              "logical", "integer", "double", "complex",
              "ulong", "slong", "fmpz", "fmpq", "mag", "arf", "acf",
              "arb", "acb"),
            as, object = NULL, simplify = FALSE)
F <- function (x) c(isSigned   = isSigned  (x),
                    isComplex  = isComplex (x),
                    isFloating = isFloating(x))
t(vapply(L, F, logical(3L)))

Run the code above in your browser using DataLab