--- a/SmallInteger.st Thu Mar 10 16:21:42 2016 +0100
+++ b/SmallInteger.st Thu Mar 10 16:21:48 2016 +0100
@@ -2608,9 +2608,9 @@
!
digitLength
- "return the number bytes required to represent this Integer.
- For negative receivers, the digitLength of its absolute value
- is returned."
+ "return the number of bytes needed for the unsigned binary representation of the receiver.
+ For negative receivers, the result is not defined by the language standard.
+ ST/X returns the digitLength of its absolute value."
%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
@@ -2619,21 +2619,21 @@
if (val < 0) val = -val;
if ((val & 0xFFFFFFFF00000000L) != 0) {
- val >>= 32;
- offs = 4;
+ val >>= 32;
+ offs = 4;
}
if ((val & 0xFFFF0000) != 0) {
- if ((val & 0xFF000000) != 0) {
- offs += 4;
- } else {
- offs += 3;
- }
+ if ((val & 0xFF000000) != 0) {
+ offs += 4;
+ } else {
+ offs += 3;
+ }
} else {
- if ((val & 0x0000FF00)!= 0) {
- offs += 2;
- } else {
- offs += 1;
- }
+ if ((val & 0x0000FF00)!= 0) {
+ offs += 2;
+ } else {
+ offs += 1;
+ }
}
return __c__._RETURN( STInteger._qnew(offs) );
#else
@@ -2641,27 +2641,27 @@
int offs = 0;
if (val < 0) {
- val = -val;
+ val = -val;
}
# if __POINTER_SIZE__ == 8
if (val & 0xFFFFFFFF00000000L) {
- val >>= 32;
- offs = 4;
+ val >>= 32;
+ offs = 4;
}
# endif
if (val & 0xFFFF0000) {
- if (val & 0xFF000000) {
- RETURN ( __mkSmallInteger(4+offs));
- } else {
- RETURN ( __mkSmallInteger(3+offs));
- }
+ if (val & 0xFF000000) {
+ RETURN ( __mkSmallInteger(4+offs));
+ } else {
+ RETURN ( __mkSmallInteger(3+offs));
+ }
} else {
- if (val & 0x0000FF00) {
- RETURN ( __mkSmallInteger(2+offs));
- } else {
- RETURN ( __mkSmallInteger(1+offs));
- }
+ if (val & 0x0000FF00) {
+ RETURN ( __mkSmallInteger(2+offs));
+ } else {
+ RETURN ( __mkSmallInteger(1+offs));
+ }
}
#endif /* not SCHTEAM */
%}.