ByteArray.st
changeset 1213 10d17781616f
parent 1169 6b6e228d22e0
child 1230 c349c4e9e594
--- a/ByteArray.st	Thu Apr 18 14:18:53 1996 +0200
+++ b/ByteArray.st	Thu Apr 18 16:38:30 1996 +0200
@@ -745,6 +745,52 @@
     "
 !
 
+signedByteAt:index
+    "return the byte at index as a signed 8 bit value."
+
+    |b "{ Class: SmallInteger }"|
+
+    b := self at:index.
+    (b > 16r7F) ifTrue:[
+        ^ b - 16r100
+    ].
+    ^ b
+
+    "
+     |b|
+     b := ByteArray new:2.
+     b at:1 put:16rFF.
+     b at:2 put:16r7F.
+     b signedByteAt:1  
+    "
+
+    "Modified: 18.4.1996 / 16:34:55 / cg"
+!
+
+signedByteAt:index put:aSignedByteValue
+    "return the byte at index as a signed 8 bit value.
+     Return the signedByteValue argument."
+
+    |b "{ Class: SmallInteger }"|
+
+    aSignedByteValue > 0 ifTrue:[
+        b := aSignedByteValue
+    ] ifFalse:[
+        b := 16r100 + aSignedByteValue
+    ].
+    self at:index put:b.
+    ^ aSignedByteValue
+
+    "
+     |b|
+     b := ByteArray new:2.
+     b signedByteAt:1 put:-1.
+     b at:1   
+    "
+
+    "Modified: 18.4.1996 / 16:37:40 / cg"
+!
+
 signedDoubleWordAt:index
     "return the 4-bytes starting at index as a signed Integer.
      The value is retrieved in the machines natural byte order."
@@ -2101,5 +2147,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.51 1996-04-13 12:20:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.52 1996-04-18 14:38:30 cg Exp $'
 ! !