Advertisement
srjchoubey2

NUMERICAL ANALYSIS

Sep 18th, 2022
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | Source Code | 0 0
  1. import math
  2.  
  3. TRUNCATE_LIMIT = 5
  4. ROUND_LIMIT = 5
  5.  
  6. def truncate(f, n):
  7.     return math.floor(f * 10 ** n) / 10 ** n
  8.  
  9. def float_multiply_trunc(a, b):
  10.     c = a * b
  11.     return truncate(c, TRUNCATE_LIMIT)
  12.  
  13. def float_multiply_round(a, b):
  14.     c = a * b;
  15.     return round(c, ROUND_LIMIT)
  16.    
  17. d = float_multiply_trunc(56.78224, float_multiply_trunc(52.34252345, 89089.90));
  18. e = float_multiply_round(56.78224, float_multiply_round(52.34252345, 89089.90));
  19.  
  20. print(d)
  21. print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement