Skip to content

bigint: bug with division of a small number by a bigint #6456

Description

@hoshiumiarata

It seems that the division of a small number by a bigint, where one of the operands is a negative number, is not working correctly.

For example, the following code:

-1 / (10**20)

mruby returns 1, while ruby 3.3 returns -1.

The same issue occurs with the divmod method:

-1.divmod(10**20)

mruby returns [1, 99999999999999999999], while ruby 3.3 returns [-1, 99999999999999999999].

Probably, there is a problem with the calculation of the sign of the result after rounding.

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