#FEATURE
authorStefan Vogel <sv@exept.de>
Tue, 17 Nov 2015 13:52:24 +0100
changeset 18899 df3418f55649
parent 18898 0dc54d84ac92
child 18900 ace3f7e03da3
#FEATURE class: LargeInteger added: #digitBytesSigned
LargeInteger.st
--- a/LargeInteger.st	Tue Nov 17 12:09:20 2015 +0100
+++ b/LargeInteger.st	Tue Nov 17 13:52:24 2015 +0100
@@ -316,6 +316,8 @@
     "Modified: / 8.5.1998 / 21:40:41 / cg"
 ! !
 
+
+
 !LargeInteger class methodsFor:'queries'!
 
 isBuiltInClass
@@ -1678,6 +1680,24 @@
     "Modified: / 5.5.1999 / 14:57:03 / stefan"
 !
 
+digitBytesSigned
+    "return a byteArray filled with the receiver's bits
+     (8 bits of the value (which may be negative) per element).
+     Least significant byte is first!!"
+
+    sign > 0 ifTrue:[
+        ^ digitByteArray
+    ].
+
+    "answer the 2's complement"
+    ^ (self bitInvert + 1) digitBytes.
+
+    " 
+        16r12345678901234567890 digitBytesSigned
+        -16r12345678901234567890 digitBytesSigned
+    "
+!
+
 digitLength
     "return the number bytes used by this Integer.
      For negative receivers, the digitLength of its absolute value