Skip to content

'shl' and 'shr' inconsistency when shifting with value >= bitsof(left operand) #95

@jangko

Description

@jangko

this is actually Nim 'shl'/'shr' inconsistency, but it also reflected by stint.

'shl' inconsistency:

  • 1.u256 shl 256 runtime will produce 0
  • 1.u256 shl 256 compiletime will produce 1

on the other hand shr at runtime and compiletime will will produce 0 if we shift beyond number of bits of the left operand.

probably signed integer version also suffered from this.
there is no documentation and tests for this gray area.
related Nim PR nim-lang/Nim#11555

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