Skip to main content

Module num_fmt

Module num_fmt 

Source
Expand description

Formatting utilities for numbers.

These functions are low-level, but are designed to be extremely fast for their designed use cases. They have strict requirements, and may not return the most ergonomic types to avoid unnecessary allocations and copying.

Structsยง

StackStr ๐Ÿ”’
A string type with a maximum length known at compile time, stored on the stack.

Staticsยง

SINGLE_DIGITS ๐Ÿ”’
SPACE_PADDED_PAIRS ๐Ÿ”’ formatting
ZERO_PADDED_PAIRS ๐Ÿ”’

Functionsยง

div_100 ๐Ÿ”’
five_digits_zero_padded ๐Ÿ”’ formatting
Obtain three strings which together represent n. The first string is the most significant. Leading zeros are included if the number has fewer than 5 digits. The first string will be empty if n is less than 10,000.
four_digits_space_padded ๐Ÿ”’ formatting
Obtain two strings of two ASCII digits each representing n. The first string is the most significant. Leading spaces are included if the number has fewer than 4 digits.
four_digits_zero_padded ๐Ÿ”’
Obtain two strings of two ASCII digits each representing n. The first string is the most significant. Leading zeros are included if the number has fewer than 4 digits.
four_to_six_digits ๐Ÿ”’
Obtain three strings which together represent n. The first string is the most significant. Leading zeros are included if the number has fewer than 4 digits. The first string will be empty if n is less than 10,000.
one_to_four_digits_no_padding ๐Ÿ”’ formatting
Obtain two strings of ASCII digits representing n. The first string is the most significant. No leading zeros or spaces are included.
one_to_three_digits_no_padding ๐Ÿ”’ formatting
Obtain two strings of ASCII digits representing n. The first string is most significant. No leading zeros or spaces are included.
one_to_two_digits_no_padding ๐Ÿ”’
Obtain a string of one or two ASCII digits representing n. No leading zeros or spaces are included.
single_digit ๐Ÿ”’
Obtain a string containing a single ASCII digit representing n.
six_digits_zero_padded ๐Ÿ”’ formatting
Obtain three strings which together represent n. The first string is the most significant. Leading zeroes are included if the number has fewer than 6 digits.
str_from_raw_parts ๐Ÿ”’ โš 
Safety
subsecond_from_nanos ๐Ÿ”’
Obtain five strings which together represent n, which is a number of nanoseconds.
three_digits_space_padded ๐Ÿ”’ formatting
Obtain two strings of ASCII digits representing n. The first string is the most significant. Leading spaces are included if the number has fewer than 3 digits.
three_digits_zero_padded ๐Ÿ”’ formatting
Obtain two strings of ASCII digits representing n. The first string is the most significant. Leading zeros are included if the number has fewer than 3 digits.
truncated_subsecond_from_nanos ๐Ÿ”’
Obtain a string of 1 to 9 ASCII digits representing n, which is a number of nanoseconds.
two_digits_space_padded ๐Ÿ”’ formatting
Obtain a string of two ASCII digits representing n. This includes a leading space if n is less than 10.
two_digits_zero_padded ๐Ÿ”’
Obtain a string of two ASCII digits representing n. This includes a leading zero if n is less than 10.