Fraction.st
changeset 11250 9a962a088d30
parent 11239 951d0e92ab3d
child 11671 6901343001b6
equal deleted inserted replaced
11249:1718c59b850f 11250:9a962a088d30
   907         denominator:denominator
   907         denominator:denominator
   908 
   908 
   909     "Modified: 28.7.1997 / 19:08:40 / cg"
   909     "Modified: 28.7.1997 / 19:08:40 / cg"
   910 ! !
   910 ! !
   911 
   911 
   912 
       
   913 !Fraction methodsFor:'printing & storing'!
   912 !Fraction methodsFor:'printing & storing'!
   914 
   913 
   915 printOn:aStream
   914 printOn:aStream
   916     "append a printed representation of the receiver to the
   915     "append a printed representation of the receiver to the
   917      argument, aStream"
   916      argument, aStream"
   947 
   946 
   948 reduced
   947 reduced
   949     "reduce the receiver; divide the numerator and denominator by their
   948     "reduce the receiver; divide the numerator and denominator by their
   950      greatest common divisor; if the result is integral, return an Integer.
   949      greatest common divisor; if the result is integral, return an Integer.
   951      Otherwise, return the normalized receiver.
   950      Otherwise, return the normalized receiver.
   952      (i.e. this is destructive wrt. the instance values)"
   951      CAVEAT: bad name; should be called reduce, as it has a side effect
       
   952      (i.e. this is destructive wrt. the instance values)."
   953 
   953 
   954     |gcd den|
   954     |gcd den|
   955 
   955 
   956     den := denominator.
   956     den := denominator.
   957     den < 0 ifTrue:[
   957     den < 0 ifTrue:[
  1103 ! !
  1103 ! !
  1104 
  1104 
  1105 !Fraction class methodsFor:'documentation'!
  1105 !Fraction class methodsFor:'documentation'!
  1106 
  1106 
  1107 version
  1107 version
  1108     ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.74 2008-10-19 21:25:16 cg Exp $'
  1108     ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.75 2008-10-21 10:13:29 cg Exp $'
  1109 ! !
  1109 ! !
  1110 
  1110 
  1111 Fraction initialize!
  1111 Fraction initialize!