You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to bind some existing c programs and libraries to python, and I have a problem when creating an array object. Then I found that the parser did not round towards zero in the integer division, and the array was multiplied by float cause the struct to fail
The following is the current parser result
// Test int div 9 / 2 should be 4floatx3=9.0 / 2.0;
intx4=9 / 2;
floatx5=9 / 2;
Also note that python integer division will take floor, but c is rounded towards zero
python3 -9 // 2 = -5
c -9 / 2 = -4
Update1
I've researched the issue, recombine(tok) causes eval to lose type, and currently I think there are two possible ways to do it.
The first one is to avoid recombine and directly processing on AST,
The second is to wrap a class outside the int type to check when division operation.
Both of these methods will inevitably make a lot of modifications to the paser or testcase
The text was updated successfully, but these errors were encountered:
r888800009
changed the title
dividing two integers should be round towards zero
Dividing two integers should be round towards zero
Apr 10, 2023
Hello, I am trying to bind some existing c programs and libraries to python, and I have a problem when creating an array object. Then I found that the parser did not round towards zero in the integer division, and the array was multiplied by float cause the struct to fail
The following is the current parser result
If you actually test the c program, it should be the following result
Then I also made some testcases, if necessary r888800009@d02ee92
Also note that python integer division will take floor, but c is rounded towards zero
python3
-9 // 2 = -5
c
-9 / 2 = -4
Update1
I've researched the issue,
recombine(tok)
causes eval to lose type, and currently I think there are two possible ways to do it.The first one is to avoid recombine and directly processing on AST,
The second is to wrap a class outside the int type to check when division operation.
Both of these methods will inevitably make a lot of modifications to the paser or testcase
The text was updated successfully, but these errors were encountered: