LimitedPrecisionReal.st
changeset 3426 a648de89ac72
parent 3395 02f47135d80f
child 3732 bf041aa09cc4
equal deleted inserted replaced
3425:f7faef75f0d8 3426:a648de89ac72
   239             selector:#asInteger
   239             selector:#asInteger
   240             errorString:'receiver is NaN in #asInteger'
   240             errorString:'receiver is NaN in #asInteger'
   241 
   241 
   242     ].
   242     ].
   243 
   243 
       
   244     "/ NOTICE: this must be redefined in float
       
   245     "/ subclasses to handle the smallinteger range;
       
   246     "/ i.e. this may only be invoked for reals
       
   247     "/ which are NOT within the smallInt range.
       
   248     "/ otherwise, endless recursion is the consequence.
       
   249 
   244     max := SmallInteger maxVal // 2 + 1.
   250     max := SmallInteger maxVal // 2 + 1.
   245     maxF := max asFloat.
   251     maxF := max asFloat.
       
   252 
   246     ^ (self quo:maxF) * max + (self rem:maxF) truncated
   253     ^ (self quo:maxF) * max + (self rem:maxF) truncated
   247 
   254 
   248     "
   255     "
   249      12345.0 asInteger
   256      12345.0 asInteger
   250      1e15 asInteger
   257      1e15 asInteger
   494 ! !
   501 ! !
   495 
   502 
   496 !LimitedPrecisionReal class methodsFor:'documentation'!
   503 !LimitedPrecisionReal class methodsFor:'documentation'!
   497 
   504 
   498 version
   505 version
   499     ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.27 1998-04-22 19:12:26 cg Exp $'
   506     ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.28 1998-05-08 12:02:08 cg Exp $'
   500 ! !
   507 ! !