Skip to content

Power of integer64 is not precise #288

@hcirellu

Description

@hcirellu

When calculating the power of integer64 the result is not the expected:

x = as.integer64(c("94906267", "2147483650"))
x^2L
# integer64
# [1] 9007199515875288    4611686027017322496
x*x
# integer64
# [1] 9007199515875289    4611686027017322500

In addition, there appears no overflow warning, even though it should appear, according to the code.

I think that two cases should be separated, i.e. the exponent is integer64 or double. In case of an integer64 exponent I would expect a precise calculation, because otherwise there is no point in using integer64 compared to double. In case of a double exponent (e.g. 1.5) I would tolerate rounding and other numerical precision issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions