473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Compute the number of words needed?

In a compiler there are 36bits for a word and to store a character
8bits are needed. In this to store a character two words appended.
Then for storing k characters string,how many words are needed?

Jul 16 '07 #1
4 2060
sumedh..... wrote On 07/16/07 10:34,:
In a compiler there are 36bits for a word and to store a character
8bits are needed. In this to store a character two words appended.
Then for storing k characters string,how many words are needed?
What is a "word?" Before answering, observe that
it cannot be an int or long or any other C data type.
(Every C object can be viewed and manipulated as an
array of bytes; your four-and-a-half-byte "word" does
not meet that criterion.)

--
Er*********@sun.com
Jul 16 '07 #2
"sumedh....." <su**********@gmail.comwrote:
In a compiler there are 36bits for a word and to store a character
8bits are needed.
This is possible.
In this to store a character two words appended.
This is ungrammatical, and without meaning.
Then for storing k characters string,how many words are needed?
This is homework. Do it yourself.

Richard
Jul 16 '07 #3
sumedh..... wrote:
In a compiler there are 36bits for a word and to store a character
8bits are needed. In this to store a character two words appended.
Then for storing k characters string,how many words are needed?
I suppose this is homework, so it's probably a good thing that the
question is not stated clearly. In particular, it is underspecified.
Suppose that you have 10 bytes to recover. These can be in 9 bytes in
one conjoined 72-bit chunk + 1 more byte. Must you retrieve two words
(a 72-bit bit chunk) for that last byte, or can you do it with only one
more 36-bit word? The answer in this case could be either 3 or 4 words.

Let's consider some real-life cases.
The major 36-bit word machines I have used are in the IBM 7090/7094, DEC
PDP-6/PDP-10, and GE 635/645 families. In all of these, addressing of
bytes had to be to groups of contiguous bits within a word. That meant
that the world you seem to be concerned with did not obtain: two
contiguous 36-bit words could not be treated as one 72-word for purposes
of byte addressing. Hoe, then, does one handle bytes.

In the GE 635/645 case, a common answer was to use 9-bit bytes. This
meant one could have a 512 character character set, or 256 characters
with a bit used as a flag of some sort, or just a wasted bit per char.

In the PDP 6/PDP-10 case, where a byte pointer stored the base word
address, the size of a byte (1-36 bits) and the position of the next
byte (relative to the end of the word), the normal choices were
a) 6x6-bit bytes, inappropriate for C, but useful in situations
where case sensitivity was not needed
a') an even more restricted set of 40 characters (RAD50) which were
rarely interpreted, but rather an encoded word was created and
used in symbol tables. much as a password look up table.
b) 5x7-bit bytes, with the last bit either wasted of used as a
flag. Inappropriate for C, but capable of handling ASCII text.
c) 4x8-bit bytes, with 4 bits either wasted or used as a set of
flags. C chars can be accommodated within this scheme, but attempts
to fit this into a coherent integer type system can be tricky.
d) 4x9-bit bytes, as in the GE 635/645 case. This accommodates C chars
nicely, and because the PDP-6/PDP-10 series have instructions for
retrieving and storing either the right or left hand 18-bits of a
word separately, it is trivial to implement using the basic
instruction set for the machine a type system including
9-bit chars
18-bit shorts
36-bit int
and, if you choose to make ints and longs different lengths,
72-bit longs can be added at small cost in computation.
Jul 16 '07 #4
"sumedh....." wrote:
>
In a compiler there are 36bits for a word and to store a character
8bits are needed. In this to store a character two words appended.
Then for storing k characters string,how many words are needed?
AFAIK, it's up to the implementation.

I used a 36-bit word system (DEC KL-10), back in college, but this was
before I started programming in C. On that platform, the Fortran
compiler would store text as five 7-bit characters per 36-bit word,
with one bit wasted. (Filenames were six 6-bit characters, equivalent
to ASCII range 0x20 through 0x5F offset by 0x20.)

I don't think a C compiler could do that, as I seem to recall that
CHAR_BITS must be at least 8. However, it could store four 8-bit
characters, wasting 4 bits per word. It could also store one 8-bit
character per word, wasting 28 bits. Or, it could do anything in
between. Perhaps it would store four 9-bit chars per word?

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Jul 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
by: Dick Moores | last post by:
I need to figure out how to compute pi to base 12, to as many digits as possible. I found this reference, <http://mathworld.wolfram.com/Base.html>, but I really don't understand it well enough....
1
by: rock72 | last post by:
I am developing a application using this fields as required by the company. 1. Date Login 2. Time IN 3. Time OUT My question is how to produce the number of days with 1 entry of Date is...
4
by: PengYu.UT | last post by:
Hi All, For example, I want to declare an array double array; Of cause, I can define an macro for the 4th power of VERY_VERY_VERY_LONG_NAME. But I want to know whether there is any build...
40
by: RadiationX | last post by:
I have a problem that I really don't understand at all. In my previous post I could get started on my projects I just had a few problems with syntax errors. This problem is something that I don't...
22
by: MLH | last post by:
If 3 things can be in one of 2 states, the number of possible combinations is equal to 2^3. But if I have 3 things, 2 of which can be in 2 states and the other in 3 states, what's the simplest...
1
by: dharnE | last post by:
I'm Hoping that this Problem will answer.The Problem is"Create A Program to compute the pay of employees as entered by the user using function statement" Sample Output: Enter Number of Employees:3...
5
by: gracia | last post by:
I need to compute the value of binomial(n, k)=n!/k!(n-k)! * (1-p)^n * p^k. When n and k is very big (e.g. n 160), the step to compute n!/k!(n- k)! is always overflow even when I used unsigned...
6
by: W. eWatson | last post by:
That's the question in Subject. For example, the difference between 08/29/2008 and 09/03/2008 is +5. The difference between 02/28/2008 and 03/03/2008 is 4, leap year--extra day in Feb. I'm really...
8
by: remlostime | last post by:
i use g++ to generater rand number, now i find that the RAND_MAX is 32367 in my computer, how can i make a bigger rand number( the number is wihin in the integer(2^32-1))
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.