Skip to content

Commit

Permalink
Python3 compatibility: math error compatibility
Browse files Browse the repository at this point in the history
The way math is handled with typing is completely different in python3.

% python2<<EOF
x=10
y=8
print((x + (y - 1)) / y * y)
EOF
16

python3<<EOF
x=10
y=8
print((x + (y - 1)) / y * y)
EOF
17.0

So we need to force an integer for the round function as follows and
maintain compatibility with python2.

python3<<EOF
x=10
y=8
print(int((x + (y - 1)) / y) * y)
EOF
16

Signed-off-by: Jason Wessel <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
jwessel authored and blp committed Jul 6, 2017
1 parent fa145f1 commit 3fa5aa4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-actions
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ line = ""
arg_structs = set()

def round_up(x, y):
return (x + (y - 1)) / y * y
return int((x + (y - 1)) / y) * y

def open_file(fn):
global file_name
Expand Down

0 comments on commit 3fa5aa4

Please sign in to comment.