Skip to content

calling DivRound on a negative number returns a positive number #385

@fawkesley

Description

@fawkesley

Thanks for this library - happy user for years.

Discovered something today unexpected:

a := decimal.NewFromFloat(-35.0)
fmt.Println(a.DivRound(decimal.NewFromFloat(5.0))

7

This is different from Go's default behaviour:

fmt.Println(-35.0 / 5)

-7.0

Am I missing something? This seems fundamentally incorrect behaviour.

Is there a way divide and preserve sign?

Cheers
Paul

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