LimitedPrecisionReal.st
changeset 24277 96315a6ab1f3
parent 24264 45aec98294cc
child 24283 797c465efa5c
equal deleted inserted replaced
24276:f748df283009 24277:96315a6ab1f3
  1227 ! !
  1227 ! !
  1228 
  1228 
  1229 !LimitedPrecisionReal methodsFor:'double dispatching'!
  1229 !LimitedPrecisionReal methodsFor:'double dispatching'!
  1230 
  1230 
  1231 differenceFromFraction:aFraction
  1231 differenceFromFraction:aFraction
  1232     "sent when a fraction does not know how to subtract the receiver, a float"
  1232     "sent when a fraction does not know how to subtract the receiver"
  1233 
  1233 
  1234     |d|
  1234     |d|
  1235 
  1235 
  1236     d := aFraction denominator.
  1236     d := aFraction denominator.
  1237     ^ (aFraction numerator - (self * d)) / d
  1237     ^ (aFraction numerator - (self * d)) / d
       
  1238 
       
  1239     "Modified (comment): / 07-06-2019 / 02:19:52 / Claus Gittinger"
  1238 !
  1240 !
  1239 
  1241 
  1240 productFromFraction:aFraction
  1242 productFromFraction:aFraction
  1241     "sent when a fraction does not know how to multiply the receiver, a float"
  1243     "sent when a fraction does not know how to multiply the receiver"
  1242 
  1244 
  1243     ^ self * aFraction numerator / aFraction denominator
  1245     ^ self * aFraction numerator / aFraction denominator
       
  1246 
       
  1247     "Modified (comment): / 07-06-2019 / 02:19:47 / Claus Gittinger"
  1244 !
  1248 !
  1245 
  1249 
  1246 quotientFromFraction:aFraction
  1250 quotientFromFraction:aFraction
  1247     "Return the quotient of the argument, aFraction and the receiver.
  1251     "Return the quotient of the argument, aFraction and the receiver.
  1248      Sent when aFraction does not know how to divide by the receiver."
  1252      Sent when aFraction does not know how to divide by the receiver."
  1249 
  1253 
  1250     ^ aFraction numerator / (self * aFraction denominator)
  1254     ^ aFraction numerator / (self * aFraction denominator)
  1251 !
  1255 !
  1252 
  1256 
  1253 sumFromFraction:aFraction
  1257 sumFromFraction:aFraction
  1254     "sent when a fraction does not know how to add the receiver, a float"
  1258     "sent when a fraction does not know how to add the receiver"
  1255 
  1259 
  1256     |d|
  1260     |d|
  1257 
  1261 
  1258     d := aFraction denominator.
  1262     d := aFraction denominator.
  1259     ^ (self * d + aFraction numerator) / d
  1263     ^ (self * d + aFraction numerator) / d
       
  1264 
       
  1265     "Modified (comment): / 07-06-2019 / 02:19:35 / Claus Gittinger"
  1260 !
  1266 !
  1261 
  1267 
  1262 sumFromTimestamp:aTimestamp
  1268 sumFromTimestamp:aTimestamp
  1263     "I am to be interpreted as seconds, return the timestamp this number of seconds
  1269     "I am to be interpreted as seconds, return the timestamp this number of seconds
  1264      after aTimestamp"
  1270      after aTimestamp"