Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- TRUNCATE_LIMIT = 5
- ROUND_LIMIT = 5
- def truncate(f, n):
- return math.floor(f * 10 ** n) / 10 ** n
- def float_multiply_trunc(a, b):
- c = a * b
- return truncate(c, TRUNCATE_LIMIT)
- def float_multiply_round(a, b):
- c = a * b;
- return round(c, ROUND_LIMIT)
- d = float_multiply_trunc(56.78224, float_multiply_trunc(52.34252345, 89089.90));
- e = float_multiply_round(56.78224, float_multiply_round(52.34252345, 89089.90));
- print(d)
- print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement