Write a routine to discover the number of address present in one n Kbytes of memory. Assume that n is always to the power of 2.

Sample input: 2

Sample output: 11

I don"t need particular coding help, yet I don"t understand the relation between deal with lines and memory.

You are watching: How to calculate address lines for memory

To refer in an extremely easy terms, without any kind of bus-multiplexing, the variety of bits compelled to address a storage is the number of lines (address or data) required to access that memory.

Quoting indigenous the Wikipedia article,

a mechanism with a 32-bit address bus can address 232 (4,294,967,296) memory locations.

for a an easy example, think about this, you have actually 3 resolve lines (A, B, C), for this reason the values which can be developed using 3 bits are

A B C0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1Total 8 values. So using ABC, girlfriend can accessibility any that those eight values, i.e., you have the right to reach any type of of those memory addresses.

So, TL;DR, the straightforward relationship is, v n variety of lines, we can represent 2n variety of addresses.

re-publishing
improve this price
monitor
edited Jul 6 "15 in ~ 9:39
answered Jul 6 "15 at 9:33

Sourav GhoshSourav Ghosh
0
include a comment |
1
An attend to line usually refers to a physical connection in between a CPU/chipset and memory. They specify which resolve to accessibility in the memory. For this reason the task is to find out how many bits are required to pass the entry number as an address.

In your example, the entry is 2 kilobytes = 2048 = 2^11, thus the prize 11. If your input is 64 kilobytes, the price is 16 (65536 = 2^16).

re-superstructure
follow
reply Jul 6 "15 in ~ 9:33

DarkDustDarkDust
1
include a comment |

Thanks for contributing solution to stack Overflow!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based upon opinion; earlier them increase with referrals or an individual experience.

To find out more, view our tips on writing good answers.

See more: How Many Feet Is 220 Meters To Feet, How Many Feet Is 220 Meters

Draft saved

authorize up utilizing Email and Password
send

### Post as a guest

name
email Required, however never shown

### Post together a guest

name
email

Required, however never shown

## Not the answer you're spring for? Browse various other questions tagged storage memory-address or questioning your very own question.

The Overflow Blog
Featured top top Meta
associated
648
In Java, what is the best method to recognize the dimension of one object?
673
how to determine CPU and also memory usage from within a process
796
How have the right to I measure up the actual memory consumption of an applications or process?
505
How deserve to I explicitly totally free memory in Python?
3
Assigning A details Memory address from another program, and changing it's worth
1
exactly how to calculate the target physical deal with given the base resolve and the storage
0
exactly how do I find a memory address programmatically...?
0
What is the beginning address of the stack Memory?
1
What is the relation to the bespeak of which storage is save on computer
warm Network inquiries more hot concerns

concern feed

ridge Overflow
commodities
firm
stack Exchange Network
site architecture / logo © 2021 ridge Exchange Inc; user contributions licensed under cc by-sa. Rev2021.11.5.40661

Stack Overflow works finest with JavaScript enabled

her privacy

By clicking “Accept all cookies”, friend agree stack Exchange deserve to store cookies on your device and disclose info in accordance with our Cookie Policy.