print_fp: Print appropriately formatted fixed point

Description Usage Arguments Value Examples

Description

This function is a helper function to print double precision values for your own convenience. If the number doesn't fit, it will be stretched which might cause an issue (for aligning your prints). Remember that negative value signs take 1 one space in digits.

Usage

1
print_fp(number, digits = 4, decimals = 4)

Arguments

number

Type: numeric. The double precision value you want formatted.

digits

Type: integer. The number of digits you want to print (pre-dot).

decimals

Type: integer. The number of decimals you want to print (post-dot).

Value

The formatted double precision value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
print_fp(123.456, 5, 5) # "00123.45600"
print_fp(123.456, 5, 4) # "00123.4560"
print_fp(123.456, 5, 3) # "00123.456"
print_fp(123.456, 5, 2) # "00123.46"
print_fp(123.456, 5, 1) # "00123.5"
print_fp(123.456, 5, 0) # "00123"
print_fp(123.456, 4, 0) # "0123"
print_fp(123.456, 3, 0) # "123"
print_fp(123.456, 2, 0) # "123"
print_fp(123.456, 1, 0) # "123"
print_fp(-123.456, 5, 5) # "-0123.45600"
print_fp(-123.456, 5, 4) # "-0123.4560"
print_fp(-123.456, 5, 3) # "-0123.456"
print_fp(-123.456, 5, 2) # "-0123.46"
print_fp(-123.456, 5, 1) # "-0123.5"
print_fp(-123.456, 5, 0) # "-0123"
print_fp(-123.456, 4, 0) # "-123"
print_fp(-123.456, 3, 0) # "-123"
print_fp(-123.456, 2, 0) # "-123"
print_fp(-123.456, 1, 0) # "-123"

Laurae2/Laurae documentation built on May 8, 2019, 7:59 p.m.