# HG changeset patch # User Claus Gittinger # Date 829838310 -7200 # Node ID 10d17781616f338c2daa6a5cf5076f74319c6474 # Parent 4f05e716a6a734e0d7f9a11ee1490208bad590b3 added #signedByteAt: / #signedByteAt:put: diff -r 4f05e716a6a7 -r 10d17781616f ByteArray.st --- 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 $' ! !