equal
deleted
inserted
replaced
19 |
19 |
20 SmallInteger comment:' |
20 SmallInteger comment:' |
21 COPYRIGHT (c) 1988 by Claus Gittinger |
21 COPYRIGHT (c) 1988 by Claus Gittinger |
22 All Rights Reserved |
22 All Rights Reserved |
23 |
23 |
24 $Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.22 1995-02-24 16:38:13 claus Exp $ |
24 $Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.23 1995-02-26 18:14:08 claus Exp $ |
25 '! |
25 '! |
26 |
26 |
27 !SmallInteger class methodsFor:'documentation'! |
27 !SmallInteger class methodsFor:'documentation'! |
28 |
28 |
29 copyright |
29 copyright |
40 " |
40 " |
41 ! |
41 ! |
42 |
42 |
43 version |
43 version |
44 " |
44 " |
45 $Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.22 1995-02-24 16:38:13 claus Exp $ |
45 $Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.23 1995-02-26 18:14:08 claus Exp $ |
46 " |
46 " |
47 ! |
47 ! |
48 |
48 |
49 documentation |
49 documentation |
50 " |
50 " |
214 if (! _isNonNilObject(aNumber)) { |
214 if (! _isNonNilObject(aNumber)) { |
215 /* a smallint or nil */ |
215 /* a smallint or nil */ |
216 RETURN ( false ); |
216 RETURN ( false ); |
217 } |
217 } |
218 |
218 |
219 if (_qClass(aNumber) == Float) { |
219 if (__isFloatLike(aNumber)) { |
220 RETURN ( ((double)_intVal(self) == _floatVal(aNumber)) ? true : false ); |
220 RETURN ( ((double)_intVal(self) == _floatVal(aNumber)) ? true : false ); |
221 } |
221 } |
222 %} |
222 %} |
223 . |
223 . |
224 aNumber respondsToArithmetic ifFalse:[^ false]. |
224 aNumber respondsToArithmetic ifFalse:[^ false]. |
236 if (! _isNonNilObject(aNumber)) { |
236 if (! _isNonNilObject(aNumber)) { |
237 /* a smallint or nil */ |
237 /* a smallint or nil */ |
238 RETURN ( true ); |
238 RETURN ( true ); |
239 } |
239 } |
240 |
240 |
241 if (_qClass(aNumber) == Float) { |
241 if (__isFloatLike(aNumber)) { |
242 RETURN ( ((double)_intVal(self) == _floatVal(aNumber)) ? false : true ); |
242 RETURN ( ((double)_intVal(self) == _floatVal(aNumber)) ? false : true ); |
243 } |
243 } |
244 %} |
244 %} |
245 . |
245 . |
246 aNumber respondsToArithmetic ifFalse:[^ true]. |
246 aNumber respondsToArithmetic ifFalse:[^ true]. |
258 #else |
258 #else |
259 /* tag bit does not change ordering */ |
259 /* tag bit does not change ordering */ |
260 RETURN ( ((INT)self < (INT)aNumber) ? true : false ); |
260 RETURN ( ((INT)self < (INT)aNumber) ? true : false ); |
261 #endif |
261 #endif |
262 } |
262 } |
263 if (__isFloat(aNumber)) { |
263 if (__isFloatLike(aNumber)) { |
264 RETURN ( ((double)_intVal(self) < _floatVal(aNumber)) ? true : false ); |
264 RETURN ( ((double)_intVal(self) < _floatVal(aNumber)) ? true : false ); |
265 } |
265 } |
266 %} |
266 %} |
267 . |
267 . |
268 ^ aNumber lessFromInteger:self |
268 ^ aNumber lessFromInteger:self |
280 #else |
280 #else |
281 /* tag bit does not change ordering */ |
281 /* tag bit does not change ordering */ |
282 RETURN ( ((INT)self > (INT)aNumber) ? true : false ); |
282 RETURN ( ((INT)self > (INT)aNumber) ? true : false ); |
283 #endif |
283 #endif |
284 } |
284 } |
285 if (__isFloat(aNumber)) { |
285 if (__isFloatLike(aNumber)) { |
286 RETURN ( ((double)_intVal(self) > _floatVal(aNumber)) ? true : false ); |
286 RETURN ( ((double)_intVal(self) > _floatVal(aNumber)) ? true : false ); |
287 } |
287 } |
288 %} |
288 %} |
289 . |
289 . |
290 ^ self retry:#> coercing:aNumber |
290 ^ self retry:#> coercing:aNumber |
301 #else |
301 #else |
302 /* tag bit does not change ordering */ |
302 /* tag bit does not change ordering */ |
303 RETURN ( ((INT)self >= (INT)aNumber) ? true : false ); |
303 RETURN ( ((INT)self >= (INT)aNumber) ? true : false ); |
304 #endif |
304 #endif |
305 } |
305 } |
306 if (__isFloat(aNumber)) { |
306 if (__isFloatLike(aNumber)) { |
307 RETURN ( ((double)_intVal(self) >= _floatVal(aNumber)) ? true : false ); |
307 RETURN ( ((double)_intVal(self) >= _floatVal(aNumber)) ? true : false ); |
308 } |
308 } |
309 %} |
309 %} |
310 . |
310 . |
311 ^ self retry:#>= coercing:aNumber |
311 ^ self retry:#>= coercing:aNumber |
322 #else |
322 #else |
323 /* tag bit does not change ordering */ |
323 /* tag bit does not change ordering */ |
324 RETURN ( ((INT)self <= (INT)aNumber) ? true : false ); |
324 RETURN ( ((INT)self <= (INT)aNumber) ? true : false ); |
325 #endif |
325 #endif |
326 } |
326 } |
327 if (__isFloat(aNumber)) { |
327 if (__isFloatLike(aNumber)) { |
328 RETURN ( ((double)_intVal(self) <= _floatVal(aNumber)) ? true : false ); |
328 RETURN ( ((double)_intVal(self) <= _floatVal(aNumber)) ? true : false ); |
329 } |
329 } |
330 %} |
330 %} |
331 . |
331 . |
332 ^ self retry:#<= coercing:aNumber |
332 ^ self retry:#<= coercing:aNumber |
353 #endif |
353 #endif |
354 RETURN ( self ); |
354 RETURN ( self ); |
355 } |
355 } |
356 RETURN ( aNumber ); |
356 RETURN ( aNumber ); |
357 } |
357 } |
358 if (__isFloat(aNumber)) { |
358 if (__isFloatLike(aNumber)) { |
359 if ( (double)_intVal(self) < _floatVal(aNumber) ) { |
359 if ( (double)_intVal(self) < _floatVal(aNumber) ) { |
360 RETURN ( self ); |
360 RETURN ( self ); |
361 } |
361 } |
362 RETURN ( aNumber ); |
362 RETURN ( aNumber ); |
363 } |
363 } |
381 #endif |
381 #endif |
382 RETURN ( self ); |
382 RETURN ( self ); |
383 } |
383 } |
384 RETURN ( aNumber ); |
384 RETURN ( aNumber ); |
385 } |
385 } |
386 if (__isFloat(aNumber)) { |
386 if (__isFloatLike(aNumber)) { |
387 if ( (double)_intVal(self) > _floatVal(aNumber) ) { |
387 if ( (double)_intVal(self) > _floatVal(aNumber) ) { |
388 RETURN ( self ); |
388 RETURN ( self ); |
389 } |
389 } |
390 RETURN ( aNumber ); |
390 RETURN ( aNumber ); |
391 } |
391 } |
531 RETURN ( _MKSMALLINT(sum) ); |
531 RETURN ( _MKSMALLINT(sum) ); |
532 } |
532 } |
533 RETURN ( _MKLARGEINT(sum) ); |
533 RETURN ( _MKLARGEINT(sum) ); |
534 #endif |
534 #endif |
535 } |
535 } |
536 if ((aNumber != nil) && (_qClass(aNumber) == Float)) { |
536 if (__isFloatLike(aNumber)) { |
537 OBJ newFloat; |
537 OBJ newFloat; |
538 double val; |
538 double val; |
539 |
539 |
540 val = _floatVal(aNumber); |
540 val = _floatVal(aNumber); |
541 _qMKFLOAT(newFloat, (double)(_intVal(self)) + val, SENDER); |
541 _qMKFLOAT(newFloat, (double)(_intVal(self)) + val, SENDER); |
563 RETURN ( _MKSMALLINT(diff) ); |
563 RETURN ( _MKSMALLINT(diff) ); |
564 } |
564 } |
565 RETURN ( _MKLARGEINT(diff) ); |
565 RETURN ( _MKLARGEINT(diff) ); |
566 #endif |
566 #endif |
567 } |
567 } |
568 if ((aNumber != nil) && (_qClass(aNumber) == Float)) { |
568 if (__isFloatLike(aNumber)) { |
569 OBJ newFloat; |
569 OBJ newFloat; |
570 double val; |
570 double val; |
571 |
571 |
572 val = _floatVal(aNumber); |
572 val = _floatVal(aNumber); |
573 _qMKFLOAT(newFloat, (double)(_intVal(self)) - val, SENDER); |
573 _qMKFLOAT(newFloat, (double)(_intVal(self)) - val, SENDER); |
724 _MKSMALLINT(hiBits(productLow)), |
724 _MKSMALLINT(hiBits(productLow)), |
725 _MKSMALLINT(lowBits(productHi)), |
725 _MKSMALLINT(lowBits(productHi)), |
726 _MKSMALLINT(hiBits(productHi)) ); |
726 _MKSMALLINT(hiBits(productHi)) ); |
727 RETURN(aLarge); |
727 RETURN(aLarge); |
728 } |
728 } |
729 } else if ((aNumber != nil) && (_qClass(aNumber) == Float)) { |
729 } else if (__isFloatLike(aNumber)) { |
730 OBJ newFloat; |
730 OBJ newFloat; |
731 double val; |
731 double val; |
732 |
732 |
733 val = _floatVal(aNumber); |
733 val = _floatVal(aNumber); |
734 _qMKFLOAT(newFloat, (double)(_intVal(self)) * val, SENDER); |
734 _qMKFLOAT(newFloat, (double)(_intVal(self)) * val, SENDER); |
767 #endif |
767 #endif |
768 RETURN ( _MKSMALLINT(t) ); |
768 RETURN ( _MKSMALLINT(t) ); |
769 } |
769 } |
770 } |
770 } |
771 } else { |
771 } else { |
772 if (__isFloat(aNumber)) { |
772 if (__isFloatLike(aNumber)) { |
773 dval = _floatVal(aNumber); |
773 dval = _floatVal(aNumber); |
774 if (dval != 0.0) { |
774 if (dval != 0.0) { |
775 OBJ newFloat; |
775 OBJ newFloat; |
776 |
776 |
777 me = _intVal(self); |
777 me = _intVal(self); |