Number.st
changeset 19136 5645cf0c4774
parent 19092 4a5b5b1e6f36
child 19137 199b5e15b1da
child 19140 b00fb7810ab6
--- a/Number.st	Mon Feb 01 16:34:29 2016 +0100
+++ b/Number.st	Mon Feb 01 18:15:27 2016 +0100
@@ -2389,6 +2389,25 @@
     ^ true
 !
 
+isPerfectSquare
+    "return true if I am a perfect square.
+     That is a number for which the square root is an integer."
+
+    self truncated = self ifFalse:[^ false].
+    ^ self asInteger isPerfectSquare
+
+    "
+     0 isPerfectSquare
+     0.0 isPerfectSquare
+     3 isPerfectSquare
+     3.0 isPerfectSquare
+     4 isPerfectSquare
+     4.0 isPerfectSquare
+     9 isPerfectSquare
+     9.0 isPerfectSquare
+    "
+!
+
 isReal
     "return true, if the receiver is some kind of real number (as opposed to a complex);
      true is returned here - the method is redefined from Object."