Skip to content

Rounding to D decimals, but keep a minimum of S significant figures #11

@jgehrcke

Description

@jgehrcke

I am looking into combining the decimals=D and sigfigs=S criteria, in a prioritized fashion. Namely: round to D decimals, but keep a minimum of S significant figures.

Say we want to round to two decimals, but we want the result to retain at least two significant figures, e.g. round 1234.56789 to 1234.57 (two decimals, first priority), but round 0.00018793 to 0.00019 (two significant figures).

I read the documentation and played with the API a tiny bit and I believe this requires custom logic and two calls to sigfig.round(). Is that correct? If yes -- is this use case too exotic or should it maybe be supported via an official method, maybe needing only a single call to sigfig.round()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions