English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how would i work out of what would the value stored be

the absalute error and the relitive error

you see im stuck on my assignment, im not asking for the answer but how to get the answer, how can i work it out, i did this awhile ago and my teacher gave it me back and ive got a few errors which i need to sort out HELP!

id ask my teacher but he speakes in tongues and i dont get what hes saying

2007-06-09 16:00:00 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

nope it actually says that in the question, i actually put what you said that only 127 can only be stored but by teacher says its wrong

2007-06-09 16:15:28 · update #1

what do you mean by 127 to -128, i get the 127 but when you say 127 to -128 you confuse me sorry

2007-06-10 06:55:49 · update #2

4 answers

This is a tricky question and is easier to solve if you convert to binary and look at the last 8 bits....

Signed numbers are stored as 2's compliment where
the leading bit is the sign bit and set to 1 to indicate a negative number.

you can represent 127 to -128 in an 8bit signed number

8402 = 0010000011010010 ( 16 bits)

this would be shifted into an 8 bit register (bits 9 to 16 would pass through an over flow bit)

The result of shifting this number into an 8 bit register means that only the last 8 bits will be saved in the register.

this would give you
11010010
Notice that the leading bit is a one (a negative number)
This means that the first seven bits are stored as 2's compliment and need to be converted in to a negative number
_1010010 (7 bit 2's compliment)
_0101101 ( invert the bits)
00000001 + add one
--------------
_0101110 (7 bit negative result) = -46 decimal

2007-06-09 20:35:13 · answer #1 · answered by MarkG 7 · 0 0

The answer to this is kinda tricky.

As you know, integers can't store fractional values, so just get rid of that part.

As the other poster said, a signed 1 byte integer can only store -128 to 127. This is 256 different values.

The easiest way to figure it out what number you'd end up with is to subtract 256 from your number until you get a value that falls between -128 and 127. This is the number that your variable would end up with.

2007-06-09 23:36:54 · answer #2 · answered by Tarindel 3 · 1 0

well read up on the IEEE Floating point specification so you would understand floating point numbers. Then using that information, construct the 32-bits that would make up that number and then take the lowest byte and see what its value would be if it were a 1 byte signed integer. Ask your professor what byte ordering you should use and what byte the processor would store in such a conversion. Also, ask him if you are using a direct MOVE instruction and just convert without using any intelligence or using a special instruction which rounds the number. If it is the latter then the value would probably be zero but a carry or overflow exception occured.

Basically it all matters on the cpu that this program is theoretically running on.

2007-06-09 23:52:59 · answer #3 · answered by iammisc 5 · 0 1

A 1-byte signed int can have values of 127 to -128.

It can't store decimal parts and it can't store numbers bigger than this. You may have misunderstood the question.

2007-06-09 23:11:21 · answer #4 · answered by Ted 7 · 0 0

fedest.com, questions and answers