UninterpretedBytes.st
branchjv
changeset 17864 e6010e48defb
parent 17847 62aa54f44969
child 17865 598963c6ff8e
--- a/UninterpretedBytes.st	Wed Sep 28 13:33:14 2011 +0100
+++ b/UninterpretedBytes.st	Wed Sep 28 13:46:37 2011 +0100
@@ -390,22 +390,28 @@
 !UninterpretedBytes methodsFor:'accessing-bytes'!
 
 bcdByteAt:index
-    "return the bcd-value for a byte at index."
+    "return the bcd-value for a byte at index in the range 0..99.
+     BCD treats nibbles (4-bit) as an encoded decimal number's digits
+     (i.e. the value n is encoded as: ((n // 10) * 16) + (n \\ 10)"
 
     ^ (self byteAt:index) decodeFromBCD
 
     "
-     #[ 16r55 ] bcdByteAt:1
-     #[ 16r99] bcdByteAt:1
+     #[ 16r55 ] bcdByteAt:1  
+     #[ 16r99] bcdByteAt:1   
      #[ 16rAA] bcdByteAt:1
     "
+
+    "Modified (comment): / 26-09-2011 / 11:57:33 / cg"
 !
 
 bcdByteAt:index put:aNumber
-    "set the byte at index as bcd-value."
+    "set the byte at index as bcd-value in the range 0..99.
+     BCD treats nibbles (4-bit) as an encoded decimal number's digits
+     (i.e. the value n is encoded as: ((n // 10) * 16) + (n \\ 10)"
 
     (aNumber between:0 and:99) ifFalse:[
-	self error:'invalid value for BCD encoding'
+        self error:'invalid value for BCD encoding'
     ].
     ^ self byteAt:index put:aNumber encodeAsBCD
 
@@ -415,10 +421,12 @@
      (((ByteArray new:1) bcdByteAt:1 put:100; yourself) at:1) hexPrintString
      (((ByteArray new:1) bcdByteAt:1 put:-1; yourself) at:1) hexPrintString
     "
+
+    "Modified (comment): / 26-09-2011 / 11:57:36 / cg"
 !
 
 signedByteAt:index
-    "return the byte at index as a signed 8 bit value.
+    "return the byte at index as a signed 8 bit value in the range -128..+127.
      The index is a smalltalk index (i.e. 1-based).
      This may be worth a primitive."
 
@@ -432,11 +440,12 @@
      b signedByteAt:1
     "
 
-    "Modified: 1.7.1996 / 21:13:53 / cg"
+    "Modified: / 01-07-1996 / 21:13:53 / cg"
+    "Modified (comment): / 26-09-2011 / 11:57:14 / cg"
 !
 
 signedByteAt:index put:aSignedByteValue
-    "return the byte at index as a signed 8 bit value.
+    "return the byte at index as a signed 8 bit value in the range -128..+127.
      The index is a smalltalk index (i.e. 1-based).
      Return the signedByteValue argument.
      This may be worth a primitive."
@@ -444,9 +453,9 @@
     |b "{ Class: SmallInteger }"|
 
     aSignedByteValue >= 0 ifTrue:[
-	b := aSignedByteValue
+        b := aSignedByteValue
     ] ifFalse:[
-	b := 16r100 + aSignedByteValue
+        b := 16r100 + aSignedByteValue
     ].
     self at:index put:b.
     ^ aSignedByteValue
@@ -458,7 +467,8 @@
      b at:1
     "
 
-    "Modified: 1.7.1996 / 21:12:37 / cg"
+    "Modified: / 01-07-1996 / 21:12:37 / cg"
+    "Modified (comment): / 26-09-2011 / 11:57:18 / cg"
 ! !
 
 !UninterpretedBytes methodsFor:'accessing-floats & doubles'!
@@ -834,7 +844,7 @@
     "Created: / 5.3.1998 / 10:51:11 / stefan"
 ! !
 
-!UninterpretedBytes methodsFor:'accessing-longlongs'!
+!UninterpretedBytes methodsFor:'accessing-longlongs (64bit)'!
 
 longLongAt:index
     "return the 8-bytes starting at index as a signed Integer.
@@ -1068,7 +1078,7 @@
     "Created: / 5.3.1998 / 14:06:02 / stefan"
 ! !
 
-!UninterpretedBytes methodsFor:'accessing-longs'!
+!UninterpretedBytes methodsFor:'accessing-longs (32bit)'!
 
 doubleWordAt:index
     "return the 4-bytes starting at index as an (unsigned) Integer.
@@ -1850,7 +1860,7 @@
     "Modified: / 5.3.1998 / 11:47:30 / stefan"
 ! !
 
-!UninterpretedBytes methodsFor:'accessing-shorts'!
+!UninterpretedBytes methodsFor:'accessing-shorts (16bit)'!
 
 shortAt:index
     "return the 2-bytes starting at index as a signed Integer.
@@ -2901,10 +2911,11 @@
 !UninterpretedBytes class methodsFor:'documentation'!
 
 version
-    ^ '$Id: UninterpretedBytes.st 10665 2011-08-10 14:59:08Z vranyj1 $'
+    ^ '$Id: UninterpretedBytes.st 10694 2011-09-28 12:46:37Z vranyj1 $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.79 2011/08/09 23:41:11 cg Exp '
+    ^ 'Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.80 2011/09/26 09:58:22 cg Exp '
 ! !
 
+