Skip to content

format_numbers() formats 0 as NaN x 10^-Inf #10

@iofarm

Description

@iofarm

Passing x = 0 to format_numbers() produces NaNs in scientific and engineering notation:

format_numbers(0, format = "sci")
#> [1] "$NaN \\times 10^{-Inf}$"

format_numbers(0, format = "engr")
#> [1] "$NaN \\times 10^{-Inf}$"

I assume this is because the power is calculated using log10(x). This can be easily avoided using decimal notation:

format_numbers(0, format = "dcml")
#> [1] "$0$"

However, it would be convenient to not have to handle zeroes specially, especially when x is programmatically generated and may or may not be 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions