ByteArray.st
changeset 1213 10d17781616f
parent 1169 6b6e228d22e0
child 1230 c349c4e9e594
equal deleted inserted replaced
1212:4f05e716a6a7 1213:10d17781616f
   741      |b|
   741      |b|
   742      b := ByteArray new:8.
   742      b := ByteArray new:8.
   743      b quadWordAtIndex:1 put:16r0807060504030201 MSB:false.
   743      b quadWordAtIndex:1 put:16r0807060504030201 MSB:false.
   744      b inspect
   744      b inspect
   745     "
   745     "
       
   746 !
       
   747 
       
   748 signedByteAt:index
       
   749     "return the byte at index as a signed 8 bit value."
       
   750 
       
   751     |b "{ Class: SmallInteger }"|
       
   752 
       
   753     b := self at:index.
       
   754     (b > 16r7F) ifTrue:[
       
   755         ^ b - 16r100
       
   756     ].
       
   757     ^ b
       
   758 
       
   759     "
       
   760      |b|
       
   761      b := ByteArray new:2.
       
   762      b at:1 put:16rFF.
       
   763      b at:2 put:16r7F.
       
   764      b signedByteAt:1  
       
   765     "
       
   766 
       
   767     "Modified: 18.4.1996 / 16:34:55 / cg"
       
   768 !
       
   769 
       
   770 signedByteAt:index put:aSignedByteValue
       
   771     "return the byte at index as a signed 8 bit value.
       
   772      Return the signedByteValue argument."
       
   773 
       
   774     |b "{ Class: SmallInteger }"|
       
   775 
       
   776     aSignedByteValue > 0 ifTrue:[
       
   777         b := aSignedByteValue
       
   778     ] ifFalse:[
       
   779         b := 16r100 + aSignedByteValue
       
   780     ].
       
   781     self at:index put:b.
       
   782     ^ aSignedByteValue
       
   783 
       
   784     "
       
   785      |b|
       
   786      b := ByteArray new:2.
       
   787      b signedByteAt:1 put:-1.
       
   788      b at:1   
       
   789     "
       
   790 
       
   791     "Modified: 18.4.1996 / 16:37:40 / cg"
   746 !
   792 !
   747 
   793 
   748 signedDoubleWordAt:index
   794 signedDoubleWordAt:index
   749     "return the 4-bytes starting at index as a signed Integer.
   795     "return the 4-bytes starting at index as a signed Integer.
   750      The value is retrieved in the machines natural byte order."
   796      The value is retrieved in the machines natural byte order."
  2099 ! !
  2145 ! !
  2100 
  2146 
  2101 !ByteArray class methodsFor:'documentation'!
  2147 !ByteArray class methodsFor:'documentation'!
  2102 
  2148 
  2103 version
  2149 version
  2104     ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.51 1996-04-13 12:20:14 cg Exp $'
  2150     ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.52 1996-04-18 14:38:30 cg Exp $'
  2105 ! !
  2151 ! !