Calculating bits of RAM
up vote
6
down vote
favorite
Consider I have 30-bit RAM to calculate its size: 2^30 = 1073741824 / 10^9 = 1GB
What if I had for example 512 MB RAM is there formula to convert it to n-bit
? this is might be noob question but I'm not good with math :/
operating-systems
add a comment |
up vote
6
down vote
favorite
Consider I have 30-bit RAM to calculate its size: 2^30 = 1073741824 / 10^9 = 1GB
What if I had for example 512 MB RAM is there formula to convert it to n-bit
? this is might be noob question but I'm not good with math :/
operating-systems
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
1
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
4
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
Consider I have 30-bit RAM to calculate its size: 2^30 = 1073741824 / 10^9 = 1GB
What if I had for example 512 MB RAM is there formula to convert it to n-bit
? this is might be noob question but I'm not good with math :/
operating-systems
Consider I have 30-bit RAM to calculate its size: 2^30 = 1073741824 / 10^9 = 1GB
What if I had for example 512 MB RAM is there formula to convert it to n-bit
? this is might be noob question but I'm not good with math :/
operating-systems
operating-systems
asked Jun 26 '16 at 21:19
user
444
444
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
1
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
4
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28
add a comment |
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
1
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
4
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
1
1
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
4
4
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28
add a comment |
2 Answers
2
active
oldest
votes
up vote
18
down vote
accepted
You're looking for a logarithm, a base-two logarithm specifically. Logarithms do the opposite of exponentiation, so if bx = y, then x = logb y. 24 = 16, so log2 16 = 4.
First, you'll need to figure out how many bytes you have. If your number is in kilobytes, multiply by 210. For megabytes, 220, for gigabytes 230, et cetera. As you can see, I'm using the powers-of-1024 definitions of these units rather the powers-of-1000 definitions, so one kilobyte here is 1024 bytes. The unambiguous name for 1024 bytes is kibibyte. Anyway, 512 MB is equal to 512 • 220 = 536870912 bytes.
Now you'll need a scientific calculator. I like Wolfram Alpha, which lets you do base-two logarithms with the log2
function. log2(536870912)
produces 29, which makes sense, considering that 512 MB is half of 1 GB, so it takes one less power of two. You can use pretty much any operator imaginable in a Wolfram Alpha expression, so log2(512 * 10^20)
works too.
If you get a number with a decimal part, round up. For example, you'd need three bits to address five bytes of RAM, though log2(5)
is roughly 2.32.
6
FYI, Google also evaluateslog2(536870912)
just fine.
– Bob
Jun 27 '16 at 3:56
4
Feels likelog(536870912) / log(2)
could be mentioned in caselog2()
is unavailable.
– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell[math]::Log(536870912, 2)
. Orecho "l(536870912)/l(2)" | bc -l
orpython -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
add a comment |
up vote
4
down vote
Additionally to what Ben said, I recommend first doing the logarithm of your number without units
log₂512 = 9
And then take units into consideration: sum 10 for kibibytes, 20 for mebibytes, 30 for gibibytes, ...
9 + 20 = 29
And that's it. No need to calculate huge numbers. That's because logarithms have the following properties:
logₙ(a × b) = logₙ(a) + logₙ(b)
logₙ(aᵇ) = b × logₙ(a)
Therefore,
log₂(512 × 2²⁰) = log₂(512) + 20
However, if you already know log₂(1 GiB) = 30
,
log₂(512 MiB) = log₂(1 GiB / 2) = log₂(1 GiB) - log₂(2) = 30 - 1 = 29
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
18
down vote
accepted
You're looking for a logarithm, a base-two logarithm specifically. Logarithms do the opposite of exponentiation, so if bx = y, then x = logb y. 24 = 16, so log2 16 = 4.
First, you'll need to figure out how many bytes you have. If your number is in kilobytes, multiply by 210. For megabytes, 220, for gigabytes 230, et cetera. As you can see, I'm using the powers-of-1024 definitions of these units rather the powers-of-1000 definitions, so one kilobyte here is 1024 bytes. The unambiguous name for 1024 bytes is kibibyte. Anyway, 512 MB is equal to 512 • 220 = 536870912 bytes.
Now you'll need a scientific calculator. I like Wolfram Alpha, which lets you do base-two logarithms with the log2
function. log2(536870912)
produces 29, which makes sense, considering that 512 MB is half of 1 GB, so it takes one less power of two. You can use pretty much any operator imaginable in a Wolfram Alpha expression, so log2(512 * 10^20)
works too.
If you get a number with a decimal part, round up. For example, you'd need three bits to address five bytes of RAM, though log2(5)
is roughly 2.32.
6
FYI, Google also evaluateslog2(536870912)
just fine.
– Bob
Jun 27 '16 at 3:56
4
Feels likelog(536870912) / log(2)
could be mentioned in caselog2()
is unavailable.
– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell[math]::Log(536870912, 2)
. Orecho "l(536870912)/l(2)" | bc -l
orpython -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
add a comment |
up vote
18
down vote
accepted
You're looking for a logarithm, a base-two logarithm specifically. Logarithms do the opposite of exponentiation, so if bx = y, then x = logb y. 24 = 16, so log2 16 = 4.
First, you'll need to figure out how many bytes you have. If your number is in kilobytes, multiply by 210. For megabytes, 220, for gigabytes 230, et cetera. As you can see, I'm using the powers-of-1024 definitions of these units rather the powers-of-1000 definitions, so one kilobyte here is 1024 bytes. The unambiguous name for 1024 bytes is kibibyte. Anyway, 512 MB is equal to 512 • 220 = 536870912 bytes.
Now you'll need a scientific calculator. I like Wolfram Alpha, which lets you do base-two logarithms with the log2
function. log2(536870912)
produces 29, which makes sense, considering that 512 MB is half of 1 GB, so it takes one less power of two. You can use pretty much any operator imaginable in a Wolfram Alpha expression, so log2(512 * 10^20)
works too.
If you get a number with a decimal part, round up. For example, you'd need three bits to address five bytes of RAM, though log2(5)
is roughly 2.32.
6
FYI, Google also evaluateslog2(536870912)
just fine.
– Bob
Jun 27 '16 at 3:56
4
Feels likelog(536870912) / log(2)
could be mentioned in caselog2()
is unavailable.
– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell[math]::Log(536870912, 2)
. Orecho "l(536870912)/l(2)" | bc -l
orpython -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
add a comment |
up vote
18
down vote
accepted
up vote
18
down vote
accepted
You're looking for a logarithm, a base-two logarithm specifically. Logarithms do the opposite of exponentiation, so if bx = y, then x = logb y. 24 = 16, so log2 16 = 4.
First, you'll need to figure out how many bytes you have. If your number is in kilobytes, multiply by 210. For megabytes, 220, for gigabytes 230, et cetera. As you can see, I'm using the powers-of-1024 definitions of these units rather the powers-of-1000 definitions, so one kilobyte here is 1024 bytes. The unambiguous name for 1024 bytes is kibibyte. Anyway, 512 MB is equal to 512 • 220 = 536870912 bytes.
Now you'll need a scientific calculator. I like Wolfram Alpha, which lets you do base-two logarithms with the log2
function. log2(536870912)
produces 29, which makes sense, considering that 512 MB is half of 1 GB, so it takes one less power of two. You can use pretty much any operator imaginable in a Wolfram Alpha expression, so log2(512 * 10^20)
works too.
If you get a number with a decimal part, round up. For example, you'd need three bits to address five bytes of RAM, though log2(5)
is roughly 2.32.
You're looking for a logarithm, a base-two logarithm specifically. Logarithms do the opposite of exponentiation, so if bx = y, then x = logb y. 24 = 16, so log2 16 = 4.
First, you'll need to figure out how many bytes you have. If your number is in kilobytes, multiply by 210. For megabytes, 220, for gigabytes 230, et cetera. As you can see, I'm using the powers-of-1024 definitions of these units rather the powers-of-1000 definitions, so one kilobyte here is 1024 bytes. The unambiguous name for 1024 bytes is kibibyte. Anyway, 512 MB is equal to 512 • 220 = 536870912 bytes.
Now you'll need a scientific calculator. I like Wolfram Alpha, which lets you do base-two logarithms with the log2
function. log2(536870912)
produces 29, which makes sense, considering that 512 MB is half of 1 GB, so it takes one less power of two. You can use pretty much any operator imaginable in a Wolfram Alpha expression, so log2(512 * 10^20)
works too.
If you get a number with a decimal part, round up. For example, you'd need three bits to address five bytes of RAM, though log2(5)
is roughly 2.32.
edited Jun 27 '16 at 14:41
answered Jun 26 '16 at 21:38
Ben N
28.9k1394141
28.9k1394141
6
FYI, Google also evaluateslog2(536870912)
just fine.
– Bob
Jun 27 '16 at 3:56
4
Feels likelog(536870912) / log(2)
could be mentioned in caselog2()
is unavailable.
– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell[math]::Log(536870912, 2)
. Orecho "l(536870912)/l(2)" | bc -l
orpython -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
add a comment |
6
FYI, Google also evaluateslog2(536870912)
just fine.
– Bob
Jun 27 '16 at 3:56
4
Feels likelog(536870912) / log(2)
could be mentioned in caselog2()
is unavailable.
– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell[math]::Log(536870912, 2)
. Orecho "l(536870912)/l(2)" | bc -l
orpython -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
6
6
FYI, Google also evaluates
log2(536870912)
just fine.– Bob
Jun 27 '16 at 3:56
FYI, Google also evaluates
log2(536870912)
just fine.– Bob
Jun 27 '16 at 3:56
4
4
Feels like
log(536870912) / log(2)
could be mentioned in case log2()
is unavailable.– grawity
Jun 27 '16 at 7:24
Feels like
log(536870912) / log(2)
could be mentioned in case log2()
is unavailable.– grawity
Jun 27 '16 at 7:24
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
Although it is covered in the linked Wikipedia article, it would improve this answer to add a few words about why you're looking for a logarithm. That way, it can be understood not as this strange mathematical concept, but simply as the inverse operation to exponentiation, which the asker already has a grasp on.
– Cody Gray
Jun 27 '16 at 12:03
you can use powershell
[math]::Log(536870912, 2)
. Or echo "l(536870912)/l(2)" | bc -l
or python -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
you can use powershell
[math]::Log(536870912, 2)
. Or echo "l(536870912)/l(2)" | bc -l
or python -c 'import math; print math.log(536870912, 2)'
– phuclv
Nov 20 at 7:55
add a comment |
up vote
4
down vote
Additionally to what Ben said, I recommend first doing the logarithm of your number without units
log₂512 = 9
And then take units into consideration: sum 10 for kibibytes, 20 for mebibytes, 30 for gibibytes, ...
9 + 20 = 29
And that's it. No need to calculate huge numbers. That's because logarithms have the following properties:
logₙ(a × b) = logₙ(a) + logₙ(b)
logₙ(aᵇ) = b × logₙ(a)
Therefore,
log₂(512 × 2²⁰) = log₂(512) + 20
However, if you already know log₂(1 GiB) = 30
,
log₂(512 MiB) = log₂(1 GiB / 2) = log₂(1 GiB) - log₂(2) = 30 - 1 = 29
add a comment |
up vote
4
down vote
Additionally to what Ben said, I recommend first doing the logarithm of your number without units
log₂512 = 9
And then take units into consideration: sum 10 for kibibytes, 20 for mebibytes, 30 for gibibytes, ...
9 + 20 = 29
And that's it. No need to calculate huge numbers. That's because logarithms have the following properties:
logₙ(a × b) = logₙ(a) + logₙ(b)
logₙ(aᵇ) = b × logₙ(a)
Therefore,
log₂(512 × 2²⁰) = log₂(512) + 20
However, if you already know log₂(1 GiB) = 30
,
log₂(512 MiB) = log₂(1 GiB / 2) = log₂(1 GiB) - log₂(2) = 30 - 1 = 29
add a comment |
up vote
4
down vote
up vote
4
down vote
Additionally to what Ben said, I recommend first doing the logarithm of your number without units
log₂512 = 9
And then take units into consideration: sum 10 for kibibytes, 20 for mebibytes, 30 for gibibytes, ...
9 + 20 = 29
And that's it. No need to calculate huge numbers. That's because logarithms have the following properties:
logₙ(a × b) = logₙ(a) + logₙ(b)
logₙ(aᵇ) = b × logₙ(a)
Therefore,
log₂(512 × 2²⁰) = log₂(512) + 20
However, if you already know log₂(1 GiB) = 30
,
log₂(512 MiB) = log₂(1 GiB / 2) = log₂(1 GiB) - log₂(2) = 30 - 1 = 29
Additionally to what Ben said, I recommend first doing the logarithm of your number without units
log₂512 = 9
And then take units into consideration: sum 10 for kibibytes, 20 for mebibytes, 30 for gibibytes, ...
9 + 20 = 29
And that's it. No need to calculate huge numbers. That's because logarithms have the following properties:
logₙ(a × b) = logₙ(a) + logₙ(b)
logₙ(aᵇ) = b × logₙ(a)
Therefore,
log₂(512 × 2²⁰) = log₂(512) + 20
However, if you already know log₂(1 GiB) = 30
,
log₂(512 MiB) = log₂(1 GiB / 2) = log₂(1 GiB) - log₂(2) = 30 - 1 = 29
answered Jun 26 '16 at 23:57
Oriol
67471630
67471630
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1093790%2fcalculating-bits-of-ram%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Number of Bytes*8? ;) put attention to the prefix for k M G T or ki... Gi...
– Hastur
Jun 26 '16 at 21:29
No I want to convert it to n-bit just like the example in first line
– user
Jun 26 '16 at 21:31
1
Your first-line calculation is wrong: the result is ~1 Gigabit (1Gb) or ~128 Megabytes (128MB).
– AFH
Jun 26 '16 at 22:16
4
@AFH I think the OP meant that one gigabyte of RAM can be addressed by a 30-bit pointer, assuming that each RAM location is a byte.
– Ben N
Jun 27 '16 at 0:28