d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Decimal To Fraction?
Prev123
Add Reply New Topic New Poll
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 7 2014 11:16pm
Quote (carteblanche @ Nov 8 2014 12:09am)
hmm i'd make it public. if i want a Fraction object to represent 10/100, i'm not sure i want it to auto reduce to 1/10 from the constructor. i'd only want it to auto reduce after performing arithmetic. maybe have a setting for it. http://onemangaforums.com/public/style_emoticons/default/shrug.gif

then again, i'm not sure i don't want it to auto reduce from the constructor either. not sure what the downsides are. thats just how apache commons does it iirc, but that's because their equals doesn't first reduce both fractions.


Very valid points. I guess it would depend on the implementation requirements. If we are required to always keep it in reduced form then I would make it private and auto reduce in the constructor. Otherwise, maybe making it public and let the consumer decide how to represent the data, reduced or not.
Go Back To Programming & Development Topic List
Prev123
Add Reply New Topic New Poll