05. Efficent division by a power of 2 {VeryLargeIntegers}R Documentation

Efficient Division by a Power of 2

Description

divp2 efficiently divides an object of class vli by a power of 2.

Usage

## S3 method for class 'vli'
divp2(x, k)

## Default S3 method:
divp2(x, k)

## S3 method for class 'numeric'
divp2(x, k)

## S3 method for class 'vli'
divp2(x, k)

Arguments

x

dividend; object of class vli or 32 bits integer

k

exponent of the divisor (the divisor will be 2^k); 32 bits integer

Details

Given two integers x (vli or 32 bits integer) and k (32 bits integer), the function divp2(x, k) computes and returns x/(2^k) as an object of class vli.

Value

object of class vli

Author(s)

Javier Leiva Cuadrado

Examples

# Dividing a random 500 digits integer by 2^10 = 1024
x <- rvlidigits(500)
x
divp2(x, 10)

[Package VeryLargeIntegers version 0.2.1 Index]