TwosComplement

Description

Twos Complement demonstrates twos complement arithmetic as implemented in logic registers. Registers operations, including basic arithmetic and logical functions, are implemented with boolean operations without use of numbers.A BitRegister represents on single-bit register with a value (set or not set) and a carry bit. A TwosComplementRegister uses a collection of single-bit registers to form a register of arbitrary width.A register is not a number, but its current contents can be converted to an integer, and an integer can be stored in a register. A register can accumulate the results of basic arithmetic, shift, and bitwise operations with the contents of another register, maintaining an overflow flag set by the last operation performed. Overflow status is displayed (with trailing $+) in the register printString.See unit tests for examples.17 asRegister ==> a TwosComplementRegister with value 17 (00000000000000000000000000010001)TwosComplementRegister width: 30 value: SmallInteger maxVal ==> a TwosComplementRegister with value -1 (111111111111111111111111111111)TwosComplementRegister width: 30 value: SmallInteger maxVal + 1 ==> a TwosComplementRegister with value 0 (000000000000000000000000000000+)Author: Dave LewisLicense: MITMembersCreator:Dave LewisAdmin:Dave LewisTagslearningLicenseCode commited to this repository will be automatically underMITlicense.RegistrationMCHttpRepositorylocation: 'http://www.squeaksource.com/TwosComplement'user: ''password: ''PackagesTwosComplementLinkshttp://www.squeaksource.com/TwosComplement.htmlhttp://www.squeaksource.com/TwosComplementGlobal:ReadStatisticsRegistered:3 October 2011 4:05:12 amTotal Releases:0Total Versions:10Total Downloads:6153

Details

Source
SqueakSource
Dialect
squeak (25% confidence)

Categories

Testing Scientific Education / Howto System / OS
← Back to results