roundToBase: Round To Base

Description Usage Arguments Value Examples

Description

roundToBase rounds value to nearest base.

Usage

1
roundToBase(x, base, direction)

Arguments

x

An integer to be rounded

base

An integer base value

direction

A character value specifying the rounding directions (can be either 'up' or 'down')

Value

An integer rounded to the nearest base value

Examples

1
2
3
4
roundToBase(17, 2, 'up') # would give 18
roundToBase(17, 10, 'up') # would give 20
roundToBase(17, 10, 'down') # would give 10
roundToBase(-17, 10, 'down') # would give -20

sanger-pathogens/deago documentation built on May 28, 2019, 8:42 a.m.