Number.st
changeset 5360 1aef297d3cbe
parent 5322 411b6c0f7250
child 5552 31b5cc144476
--- a/Number.st	Fri Apr 07 10:09:58 2000 +0200
+++ b/Number.st	Fri Apr 07 10:10:40 2000 +0200
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+"{ Package: 'stx:libbasic' }"
+
 ArithmeticValue subclass:#Number
 	instanceVariableNames:''
 	classVariableNames:''
@@ -613,6 +615,23 @@
 
 !Number methodsFor:'testing'!
 
+isDivisibleBy:aNumber
+    "return true, if the receiver can be divided by the argument, aNumber without a remainder.
+     Notice, that the result is only worth trusting, if the receiver is an integer."
+
+    aNumber = 0 ifTrue: [^ false].
+    aNumber isInteger ifFalse: [^ false].
+    ^ (self \\ aNumber) = 0
+
+    "
+     3 isDivisibleBy:2     
+     4 isDivisibleBy:2
+     4.0 isDivisibleBy:2   
+     4.5 isDivisibleBy:4.5 
+     4.5 isDivisibleBy:1.0 
+    "
+!
+
 isNumber
     "return true, if the receiver is a kind of number"
 
@@ -702,5 +721,5 @@
 !Number class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.59 2000-03-24 11:54:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.60 2000-04-07 08:10:40 cg Exp $'
 ! !