CPS 109 Lecture Notes - Lecture 10: Attractor, Arbitrary-Precision Arithmetic, Memory Management

146 views26 pages

Document Summary

/** the class fraction implements the integer fractions and some. * are internally implemented using java"s biginteger class for. * arbitrarily large integer values based on heap memory. * @author ilkka kokkarinen public class fraction implements comparable { * comparable interface is used to order the objects of user-defined class. * this interface is found in java. lang package and contains only one method named compareto(object). * it provide only single sorting sequence i. e. you can sort the elements on based on single datamember only. * for instance it may be either rollno,name,age or anything else. // a fraction is internally encoded as numerator and denominator, both bigintegers. private biginteger num; // the numerator private biginteger den; // the denominator, should always be > 0. Note that we don"t have setter methods, since the fraction. // class is immutable, which means that an object, once created, cannot change. // (this has various advantages which may not be intuitive right now. )

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents