Trap representation

R

ramu

Hi,
I read the phrase " trap representation" in the topic "Union
arrangement" in this group. Can you please tell me what do you mean by
it?

regards
 
C

CBFalconer

ramu said:
I read the phrase " trap representation" in the topic "Union
arrangement" in this group. Can you please tell me what do you
mean by it?

The better systems (rare these days) can detect uninitialized or
otherwise improper values in an object by storing a special code
there. The hardware detects any attempt to use that code and traps
it.

For example, a 2's complement machine could have INT_MAX = 32767;
INT_MIN = -32767; and reserve the bit pattern for -32768 (or
0x8000) as a trap value. That same machine would have to be able
to turn off the trap mechanism for any unsigned ints.

The same machine might be able to implement 17 bit storage for
ints, and reserve the extra bit to signal a trap representation.
That bit would never show up in the arithmetic. That way nothing
special would be needed to handle unsigned ints.

A further example is ECC memory, where a set of extra bits are used
to automatically correct any one bit errors, and detect two bit
errors. If a method existed to write something containing a two
bit error, that could serve as a trap representation. This would
be an excellent way to default initialize memory, because all use
of programatically uninitialized storage would then be detected.

--
"The power of the Executive to cast a man into prison without
formulating any charge known to the law, and particularly to
deny him the judgement of his peers, is in the highest degree
odious and is the foundation of all totalitarian government
whether Nazi or Communist." -- W. Churchill, Nov 21, 1943
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top