# TheLongDecimalClass.py # YOUR NAME(S) AND NETID(S) HERE # Skeleton by the CS 1110 Profs, Spring 2016 # Date """ Contains a class that supports long decimal addition and multiplication. """ from TheLongIntClass import * class LongDecimal(object): """ Attributes: Whole: the whole number part [LongInt] Fract: the fraction part [LongInt] UPDATE (Mon May 9): Fract's String should always have length >= 1, and should contain no extra trailing zeroes. For example, '0' is allowed; "", None, '00' and '04000' are not allowed. """ def __init__(self,x): """ PreC: x can be either a string that is composed of digits and at most one decimal point. or a valid nonnegative int or float literal, i.e., 37 , .37 , 37. or a reference to a LongDecimal object. UPDATE (Mon May 9): for the purposes of this assignment, assume input is not in scientific notation. """ pass def __str__(self): pass def __add__(self,other): """ Returns the sum of self and other as a LongDecimal PreC: other is a reference to a LongDecimal or LongInt object. """ pass def __mul__(self,other): """ Returns the product of self and other as a LongDecimal PreC: other is a reference to a LongDecimal or LongInt object. """ pass # UPDATE (Mon May 9) added this helper function for students to use. # helper method. def fix_trailing(self): """Remove trailing zeroes from the (String of) Fract of LongDecimal ld. If removing all the trailing zeroes would leave an empty string, set the Frac String to "0". Returns self (as a convenience to the caller). PreC: self.Fract.String is a string. """ self.Fract.String = self.Fract.String.rstrip('0') if len(self.Fract.String) == 0: self.Fract.String = "0" return self