Learn R Programming

flint (version 0.1.4)

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, sep = NULL,
       digits.mag = NULL, rnd.mag = NULL, ...)
# S4 method for arf
format(x, base = 10L, sep = NULL,
       digits = NULL, rnd = NULL, ...)
# S4 method for acf
format(x, base = 10L, sep = NULL,
       digits = NULL, rnd = NULL, ...)
# S4 method for arb
format(x, base = 10L, sep = NULL,
       digits = NULL, digits.mag = NULL,
       rnd = NULL, rnd.mag = "A", ...)
# S4 method for arb
format(x, base = 10L, sep = NULL,
       digits = NULL, digits.mag = NULL,
       rnd = NULL, rnd.mag = "A", ...)

Value

A character vector containing ASCII strings of equal length, preserving the length, dimensions, dimension names, and names of

x.

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.

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.

digits, digits.mag

integers indicating how many digits of the significand are reported when formatting floating-point numbers. When more than one digit is printed, a radix point is 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 values NULL are equivalent to getOption("digits") and getOption("digits.mag", 4L).

rnd, rnd.mag

character strings indicating the rounding modes used when formatting floating-point numbers. The default values NULL are equivalent to flintRnd() and flintRndMag(); see there for a description of valid character strings and the corresponding rounding modes.

...

further optional arguments, though these are currently unused.

Details

Formatting of arf and arf midpoints of acf, arb, and acb uses arguments digits and rnd. Formatting of mag and mag radii of arb and acb uses arguments digits.mag and rnd.mag.

Note that radii are not incremented to account for error introduced by rounding of midpoints. Hence it is possible that the enclosure obtained by formatting does not contain the enclosure represented in memory.

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