print_int: Print appropriately formatted integer

Description Usage Arguments Value Examples

Description

This function is a helper function to print integers 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.

Usage

1
print_int(number, digits = 8)

Arguments

number

Type: numeric. The integer you want formatted.

digits

Type: integer. The number of digits you want to print. Unlike print_fp, it does not need to handle negative values in a special case.

Value

The formatted integer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
print_int(12, 7) # "0000012"
print_int(12, 6) # "000012"
print_int(12, 5) # "00012"
print_int(12, 4) # "0012"
print_int(12, 3) # "012"
print_int(12, 1) # "12"
print_int(12, 2) # "12"
print_int(123456, 7) # "0123456"
print_int(123456789, 7) # "123456789"
print_int(-12, 4) # "-012"
print_int(-12, 3) # "-12"
print_int(-12, 2) # "-12"
print_int(-12, 1) # "-12"
print_int(-1234, 6) # "-01234"
print_int(-1234, 5) # "-1234"
print_int(-1234, 4) # "-1234"

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