Learn R Programming

flint (version 0.0.3)

format-methods: Format FLINT-type Numbers as Strings

Description

Format a flint vector for pretty printing.

Usage

# S4 method for ulong
format(x, base = 10L, ...)
# S4 method for slong
format(x, base = 10L, ...)
# S4 method for fmpz
format(x, base = 10L, ...)
# S4 method for fmpq
format(x, base = 10L, ...)
# S4 method for mag
format(x, base = 10L, digits = NULL, sep = NULL,
       rnd = flintRnd(), ...)
# S4 method for arf
format(x, base = 10L, digits = NULL, sep = NULL,
       rnd = flintRnd(), ...)
# S4 method for acf
format(x, base = 10L, digits = NULL, sep = NULL,
       rnd = flintRnd(), ...)
# S4 method for arb
format(x, base = 10L, digits = NULL, sep = NULL,
       rnd = flintRnd(), ...)
# S4 method for acb
format(x, base = 10L, digits = NULL, sep = NULL,
       rnd = flintRnd(), ...)

Value

A character vector containing ASCII strings of equal length.

Arguments

x

a flint vector.

base

an integer from 2 to 62 indicating a base for output. Values 2, 10, and 16 correspond to binary, decimal, and hexadecimal output. Digits are represented by characters [0-9A-Za-z], in that significance order, hence the maximum 10+26+26=62.

digits

an integer indicating how many digits of the significand are reported when formatting floating type vectors. When more than one digit is printed, a radix point inserted after the first digit. Value 0 is equivalent to the minimum integer d such that all elements of x are represented exactly by d digits in the specified base. The default value NULL is equivalent to getOption("digits", 99999L).

sep

a nonempty character string used to separate the significand from the exponent. The default value NULL is a equivalent to "e" for base equal to 10 and to "@" for all other bases.

rnd

a nonempty character string whose first character indicates a rounding mode. Methods for arb and acb require rnd of length 2, specifying rounding modes separately for midpoints and radii. See flintRnd for information about valid character strings.

...

further optional arguments, though these are currently unused.

Examples

Run this code
q <- .fmpq(num = c(-1L, 1L) * 0:5, den = 1:6)
for (b in 2:8) {
    cat("base = ", b, ":\n", sep = "")
    print(format(q, base = b), quote = FALSE, width = 12L)
}

z <- .acb(real = .arb(mid = pi, rad = 0.5 * pi))
format(z)
format(z, base = 62L, sep = "*[62]^")
strsplit(format(Re(z), digits = 80L), "[( )]")[[1L]][c(FALSE, TRUE)]

Run the code above in your browser using DataLab