Skip to content

Format string for rounding to nearest integer #745

@eradman

Description

@eradman

version: numbro 2.4.0

After transitioning from numeral.js I noticed that a format string of '0' does not round to the nearest integer

> var numbro = require("numbro");
undefined
> num = numbro(23.4333333);
R { _value: 23.4333333 }
> num.format('0')
'23.4333333'

Adding one or more decimal places does round to the specified number of digits

> num.format('0.0')
'23.4'
> num.format('0.00')
'23.43'

Is there an alternate syntax for displaying a number with no decimal places?

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