Skip to content

Rounding issue (expect round up, but down) #180

Open
@tiendc

Description

@tiendc

I have an issue with rounding numbers.

d, _ := decimal.New(0, 0).SetString("1.45")
fmt.Println(d.Round(2)) -> Expect: 1.5 actual: 1.4

d, _ := decimal.New(0, 0).SetString("1.5")
fmt.Println(d.Round(1)) -> Expect: 2 actual: 2 (seems not consistent with the above case)

d, _ := decimal.New(0, 0).SetString("1.451")
fmt.Println(d.Round(2)) -> Expect: 1.5 actual: 1.5 (correct)

Any investigation? thanks.

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