0
$\begingroup$

I'm studying numerical analysis and i am stuck with one of my exercises. In the book "Numerical Analysis: Mathematics of scientific Computing" they introduce a hypothetical computer called MARC-32. In the book the computer is a 32-bits computer representing a nonzero real number with the form: x = ±q * 2^m

with the allocation:

  • sign of the real number x: 1 bit
  • biased exponent (integer e): 8 bits
  • mantissa part (real number f): 23 bits

marc-32

My problem is that i really do not understand the computer and hence can not solve the following problems:

Determine whether the following numbers are machine numbers in the Marc-32:

  • 10^40
  • 2^-1+2^-29
  • 1/3
  • 1/5

I have read the chapter a couple of times and still i don't get it. I really want to know what they mean by the hypothetical computer and how to solve it.

$\endgroup$
  • 1
    $\begingroup$ What about the description of the representation is it you don't understand? $\endgroup$ – hmakholm left over Monica Sep 12 '19 at 15:38
  • $\begingroup$ It is relevant to add how the true exponent is computed from the biased exponent, i.e., what is the shift used by the Marc-32. The answers depend on the exact shift. Moreover, can you determine the exact binary representation of the four numbers? $\endgroup$ – Carl Christian Sep 12 '19 at 18:05
  • $\begingroup$ @CarlChristian - while technically you are correct, I have a hard time believing it would be anything other than e = m + 128, thereby allowing exponents of 2 from -128 to +127. $\endgroup$ – Paul Sinclair Sep 13 '19 at 3:44
  • $\begingroup$ @PaulSinclair: The shift used in IEEE single precision is 127 and not 128. Assuming OP is referring to a book by Kincaid and Cheney, the Marc-32 has a permissible range of exponents from -126 to 127. This is consistent with IEEE SP where the smallest exponent, i.e. -127 is used for zero or subnormal numbers, while the largest exponent 128 is used for infinities or NaN. $\endgroup$ – Carl Christian Sep 13 '19 at 10:00
  • $\begingroup$ @CarlChristian - all of which has no impact on the answers to the questions asked, because none of the questions involve exponents in that range. $\endgroup$ – Paul Sinclair Sep 13 '19 at 16:01
0
$\begingroup$

If you write $x$ in binary, it would looks something like this (as an example): $$x=1010011.011010010001_b$$ Then you convert it to the binary version of scientific notation: $$x = 1.010011011010010001_b \times 2^{110_b}$$

For this example,

  • The number is positive, so the sign bit would be $1$ (or possibly $0$, depending on the system architecture - for these problems, it doesn't matter which is used.)
  • The exponent $m = 6 = 110_b$. But we want to store positive and negative exponents in the eight bits, and there is no sign bit. So we bias the result by adding a value. 8 bits can store 256 different values, so if we alot half of them for negative exponents, that is 128. This means the range of allowable exponents is from $-128$ to $+127$. When the exponent is stored, we add $128$ so the value we store is from $0$ to $255$. For the example, the exponent stored is $110_b + 10000000_b = 10000110_b$.
  • The bit in front of the point is always $1$. This is what defines the exponent value. It is the exponent that brings the leading $1$ to be right in front of the "decimal" point. Since this bit is always $1$, there is no need to store it. The "mantissa" is the part of the number to the right of the point. In the example, the mantissa is $010011011010010001_b$. Since we have 23 bits, it is actually stored as: $$01001101101001000100000$$
$\endgroup$
  • $\begingroup$ I should note about the final bullet, that when $x = 0$, the bit in front of the decimal point cannot be $1$, even though it is for every other number. It is usual to assign a particular value as representing $0$ (for example, all 32 bits being 0), instead of interpreting per the scheme described above. $\endgroup$ – Paul Sinclair Sep 13 '19 at 4:12
  • $\begingroup$ Thank you Paul for the answer, it was really understandable with that step by step guide. So let me try to tell you what I understood. 1) First I convert my decimal number (which I want to determine is a marc 32 number) to binary 2) Then I convert my exponent to binary 3) Now I can write the number as the binary version of scientific notation 4) I want to store the exponent as a 8 bit so I add the binary number 10000000 5) Now I look at the mentissa and add/discard to 23 bits 6) and finally I have the number x = 1.(23 bits mantissa)^(8 bits exponent). Did I understand it correctlly? $\endgroup$ – restingquartH Sep 15 '19 at 20:53
  • $\begingroup$ and i have just tried to convert 10^40 to binary, it is impossible!? $\endgroup$ – restingquartH Sep 15 '19 at 20:56
  • $\begingroup$ It is not impossible, but the result will be roughly 132 bits, of which about 92 will be significant (i.e., either $1$ or followed by a $1$ somewhere in lower orders). And that is all you need to know. As Carl Christian points out, you need to double-check that the Marc 32 doesn't do something weird to allow exponents greater than 128 (even though it would be rather pointless to do so). But unless it does, the fact that $10^{40}$ has an base-2 exponent of 132 rules out this as being a machine number, so there is no reason to check it any farther. $\endgroup$ – Paul Sinclair Sep 16 '19 at 3:30
  • $\begingroup$ As for your steps, I was just trying to clarify the basic storage scheme to improve your understanding, not give step-by-step instructions on solving the problem. As you've noticed, following those steps in that order can be daunting. But you don't have to actually do it - you just have to figure out if it will be possible. That is usually easier. $10^{40}$ fails because it is relatively easy to find the base 2 exponent. It is the only one that actually takes a calculator or paper to figure out. The second is matter of counting, and the other two a matter of divisibility. $\endgroup$ – Paul Sinclair Sep 16 '19 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.