Skip to content

Integer division for casts, int array elements, bitwise results, ** and int-returning subroutines #480

Open

Description

@HVSharma12

After #474, / divides as integers when both operands are integer literals or int/uint variables. Other integer-typed operands still use true division:

OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
int[32] a = 2;
int[32] b = 3;
float[64] f = 7.9;
array[int[32], 2] arr = {7, 1};
def h() -> int[32] { return 7; }
rx(int[32](f) / a) q[0];   // rx(3.5), spec gives 3
rx(arr[0] / a) q[0];       // rx(3.5), spec gives 3
rx((b | 4) / a) q[0];      // rx(3.5), spec gives 3
rx(h() / a) q[0];          // rx(3.5), spec gives 3

Casts to int/uint, elements of integer arrays, bitwise and shift results on integers, int ** int, and subroutines that return int/uint are all integer-typed in the spec (language/types.rst, language/classical.rst). Raised in the review of #474.

Activity

  1. HVSharma12 commented on Nov 18, 2026

    @HVSharma12
    ContributorAuthor

    I have a fix for this ready on top of #474. I'll open the PR as soon as #474 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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