Skip to content

Conversation

@WeiguoMa
Copy link
Contributor

Add the function floor_divide() for all backends. Also a test in test_backends.py.

@refraction-ray
Copy link
Member

where will this function be used? what is the difference between directly call floor(a/b)?

@WeiguoMa
Copy link
Contributor Author

We don't use floor(x/y) because we found that it may cause problems due to floating-point precision in subsequent programs. x/y will lead to int->float conversion, which may result in ±1 errors during the conversion process in counts or something. Therefore, we use the more standardized floor_divide(). This function will be used in future quantum.sample_int2bin().

@refraction-ray
Copy link
Member

LGTM

@refraction-ray refraction-ray merged commit 5955c07 into tensorcircuit:master Aug 31, 2025
1 check passed
@WeiguoMa WeiguoMa deleted the backends branch September 1, 2025 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants