Closed ldo closed 4 years ago
The bin_ops.roundToMultiple routine can be shortened as follows:
bin_ops.roundToMultiple
diff --git a/bin_ops.py b/bin_ops.py index b8109ee..fc3d1cc 100644 --- a/bin_ops.py +++ b/bin_ops.py @@ -21,10 +21,7 @@ class TypeFormat: def roundToMultiple(numToRound, multiple): - remainder = numToRound % multiple - if (remainder == 0): - return numToRound - return numToRound + multiple - remainder + return (numToRound + multiple - 1) // multiple * multiple
Actually, given that it is only used to round to multiples of xps_const.ROUND_MULTIPLE, which is 4, it could be simplified even further.
xps_const.ROUND_MULTIPLE
The
bin_ops.roundToMultiple
routine can be shortened as follows:Actually, given that it is only used to round to multiples of
xps_const.ROUND_MULTIPLE
, which is 4, it could be simplified even further.