LPReal.st
changeset 4615 e480d1e6090f
parent 4455 2d31d0d986be
equal deleted inserted replaced
4614:14d5ce4bf117 4615:e480d1e6090f
   245             selector:#asInteger
   245             selector:#asInteger
   246             errorString:'receiver is NaN in #asInteger'
   246             errorString:'receiver is NaN in #asInteger'
   247 
   247 
   248     ].
   248     ].
   249 
   249 
   250     "/ NOTICE: this must be redefined in float
   250     self abs < 2e16 ifTrue:[
   251     "/ subclasses to handle the smallinteger range;
   251         "/ NOTICE: this must be redefined in float
   252     "/ i.e. this may only be invoked for reals
   252         "/ subclasses to handle the smallinteger range;
   253     "/ which are NOT within the smallInt range.
   253         "/ i.e. this may only be invoked for reals
   254     "/ otherwise, endless recursion is the consequence.
   254         "/ which are NOT within the smallInt range.
   255 
   255         "/ otherwise, endless recursion is the consequence.
   256     max := SmallInteger maxVal // 2 + 1.
   256 
   257     maxF := max asFloat.
   257         max := SmallInteger maxVal // 2 + 1.
   258 
   258         maxF := max asFloat.
   259     ^ (self quo:maxF) * max + (self rem:maxF) truncated
   259 
   260 
   260         ^ (self quo:maxF) * max + (self rem:maxF) truncated
   261     "
   261     ].
   262      12345.0 asInteger
   262     ^ self asTrueFraction
   263      1e15 asInteger
   263 
   264      1e33 asInteger
   264     "
       
   265      12345.0 asInteger     
       
   266      1e15 asInteger        
       
   267      1e33 asInteger asFloat
       
   268      1e303 asInteger asFloat
   265     "
   269     "
   266 
   270 
   267     "Modified: 12.2.1997 / 16:45:07 / cg"
   271     "Modified: 12.2.1997 / 16:45:07 / cg"
   268 !
   272 !
   269 
   273 
   491 ! !
   495 ! !
   492 
   496 
   493 !LimitedPrecisionReal class methodsFor:'documentation'!
   497 !LimitedPrecisionReal class methodsFor:'documentation'!
   494 
   498 
   495 version
   499 version
   496     ^ '$Header: /cvs/stx/stx/libbasic/Attic/LPReal.st,v 1.31 1999-07-26 09:10:36 stefan Exp $'
   500     ^ '$Header: /cvs/stx/stx/libbasic/Attic/LPReal.st,v 1.32 1999-08-19 01:20:08 cg Exp $'
   497 ! !
   501 ! !