equal
deleted
inserted
replaced
1551 |
1551 |
1552 digitAt:index |
1552 digitAt:index |
1553 "return 8 bits of value, starting at byte index" |
1553 "return 8 bits of value, starting at byte index" |
1554 |
1554 |
1555 %{ |
1555 %{ |
1556 #ifdef __JAVA__ |
1556 #ifdef __SCHTEAM__ |
1557 return context._RETURN( ((STLargeInteger)self).digitAt( index.intValue() ) ); |
1557 return context._RETURN( ((STLargeInteger)self).digitAt( index.intValue() ) ); |
1558 #endif |
1558 #endif |
1559 %}. |
1559 %}. |
1560 index > digitByteArray size ifTrue:[^ 0]. |
1560 index > digitByteArray size ifTrue:[^ 0]. |
1561 ^ digitByteArray at:index |
1561 ^ digitByteArray at:index |
1563 |
1563 |
1564 digitAt:index put:aByte |
1564 digitAt:index put:aByte |
1565 "set the 8 bits, index is a byte index" |
1565 "set the 8 bits, index is a byte index" |
1566 |
1566 |
1567 %{ |
1567 %{ |
1568 #ifdef __JAVA__ |
1568 #ifdef __SCHTEAM__ |
1569 ERROR("cannot modify the digits of a LargeInteger"); |
1569 ERROR("cannot modify the digits of a LargeInteger"); |
1570 #endif |
1570 #endif |
1571 %}. |
1571 %}. |
1572 digitByteArray at:index put:aByte |
1572 digitByteArray at:index put:aByte |
1573 ! |
1573 ! |
1578 for negative ones, the actual bit representation is returned." |
1578 for negative ones, the actual bit representation is returned." |
1579 |
1579 |
1580 |t digits| |
1580 |t digits| |
1581 |
1581 |
1582 %{ |
1582 %{ |
1583 #ifdef __JAVA__ |
1583 #ifdef __SCHTEAM__ |
1584 return context._RETURN( ((STLargeInteger)self).digitByteAt( index.intValue() ) ); |
1584 return context._RETURN( ((STLargeInteger)self).digitByteAt( index.intValue() ) ); |
1585 #endif |
1585 #endif |
1586 %}. |
1586 %}. |
1587 sign >= 0 ifTrue:[ |
1587 sign >= 0 ifTrue:[ |
1588 index > digitByteArray size ifTrue:[ |
1588 index > digitByteArray size ifTrue:[ |
1613 "return a byteArray filled with the receivers bits |
1613 "return a byteArray filled with the receivers bits |
1614 (8 bits of the absolute value per element). |
1614 (8 bits of the absolute value per element). |
1615 Least significant byte is first!!" |
1615 Least significant byte is first!!" |
1616 |
1616 |
1617 %{ |
1617 %{ |
1618 #ifdef __JAVA__ |
1618 #ifdef __SCHTEAM__ |
1619 return context._RETURN( ((STLargeInteger)self).digitBytes() ); |
1619 return context._RETURN( ((STLargeInteger)self).digitBytes() ); |
1620 #endif |
1620 #endif |
1621 %}. |
1621 %}. |
1622 ^ digitByteArray |
1622 ^ digitByteArray |
1623 |
1623 |
1657 for their digitLength |
1657 for their digitLength |
1658 " |
1658 " |
1659 |l "{ Class: SmallInteger }" | |
1659 |l "{ Class: SmallInteger }" | |
1660 |
1660 |
1661 %{ |
1661 %{ |
1662 #ifdef __JAVA__ |
1662 #ifdef __SCHTEAM__ |
1663 return context._RETURN( ((STLargeInteger)self).digitLength() ); |
1663 return context._RETURN( ((STLargeInteger)self).digitLength() ); |
1664 #endif |
1664 #endif |
1665 %}. |
1665 %}. |
1666 l := digitByteArray size. |
1666 l := digitByteArray size. |
1667 [l ~~ 0 and:[(digitByteArray at:l) == 0]] whileTrue:[ |
1667 [l ~~ 0 and:[(digitByteArray at:l) == 0]] whileTrue:[ |
5388 |
5388 |
5389 negative |
5389 negative |
5390 "return true, if the receiver is < 0" |
5390 "return true, if the receiver is < 0" |
5391 |
5391 |
5392 %{ |
5392 %{ |
5393 #ifdef __JAVA__ |
5393 #ifdef __SCHTEAM__ |
5394 return context._RETURN( ((STLargeInteger)self).largeValue.signum() < 0 ? STObject.True : STObject.False); |
5394 return context._RETURN( ((STLargeInteger)self).largeValue.signum() < 0 ? STObject.True : STObject.False); |
5395 #endif |
5395 #endif |
5396 %}. |
5396 %}. |
5397 ^ (sign < 0) |
5397 ^ (sign < 0) |
5398 ! |
5398 ! |
5407 |
5407 |
5408 positive |
5408 positive |
5409 "return true, if the receiver is >= 0" |
5409 "return true, if the receiver is >= 0" |
5410 |
5410 |
5411 %{ |
5411 %{ |
5412 #ifdef __JAVA__ |
5412 #ifdef __SCHTEAM__ |
5413 return context._RETURN( ((STLargeInteger)self).largeValue.signum() >= 0 ? STObject.True : STObject.False); |
5413 return context._RETURN( ((STLargeInteger)self).largeValue.signum() >= 0 ? STObject.True : STObject.False); |
5414 #endif |
5414 #endif |
5415 %}. |
5415 %}. |
5416 ^ (sign >= 0) |
5416 ^ (sign >= 0) |
5417 ! |
5417 ! |
5418 |
5418 |
5419 sign |
5419 sign |
5420 "return the sign of the receiver (-1, 0 or 1)" |
5420 "return the sign of the receiver (-1, 0 or 1)" |
5421 |
5421 |
5422 %{ |
5422 %{ |
5423 #ifdef __JAVA__ |
5423 #ifdef __SCHTEAM__ |
5424 return context._RETURN( STInteger._new( ((STLargeInteger)self).largeValue.signum() )); |
5424 return context._RETURN( STInteger._new( ((STLargeInteger)self).largeValue.signum() )); |
5425 #endif |
5425 #endif |
5426 %}. |
5426 %}. |
5427 ^ sign |
5427 ^ sign |
5428 ! |
5428 ! |
5429 |
5429 |
5430 strictlyPositive |
5430 strictlyPositive |
5431 "return true, if the receiver is > 0" |
5431 "return true, if the receiver is > 0" |
5432 |
5432 |
5433 %{ |
5433 %{ |
5434 #ifdef __JAVA__ |
5434 #ifdef __SCHTEAM__ |
5435 return context._RETURN( ((STLargeInteger)self).largeValue.signum() > 0 ? STObject.True : STObject.False); |
5435 return context._RETURN( ((STLargeInteger)self).largeValue.signum() > 0 ? STObject.True : STObject.False); |
5436 #endif |
5436 #endif |
5437 %}. |
5437 %}. |
5438 ^ (sign > 0) |
5438 ^ (sign > 0) |
5439 ! ! |
5439 ! ! |
5440 |
5440 |
5441 !LargeInteger class methodsFor:'documentation'! |
5441 !LargeInteger class methodsFor:'documentation'! |
5442 |
5442 |
5443 version |
5443 version |
5444 ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.224 2015-04-19 22:31:45 cg Exp $' |
5444 ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.225 2015-04-20 10:48:54 cg Exp $' |
5445 ! |
5445 ! |
5446 |
5446 |
5447 version_CVS |
5447 version_CVS |
5448 ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.224 2015-04-19 22:31:45 cg Exp $' |
5448 ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.225 2015-04-20 10:48:54 cg Exp $' |
5449 ! ! |
5449 ! ! |