Calculating bits of RAM











up vote
6
down vote

favorite
2












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 :/










share|improve this question






















  • 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















up vote
6
down vote

favorite
2












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 :/










share|improve this question






















  • 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













up vote
6
down vote

favorite
2









up vote
6
down vote

favorite
2






2





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 :/










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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










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.






share|improve this answer



















  • 6




    FYI, Google also evaluates log2(536870912) just fine.
    – Bob
    Jun 27 '16 at 3:56








  • 4




    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










  • 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


















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





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    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

























    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.






    share|improve this answer



















    • 6




      FYI, Google also evaluates log2(536870912) just fine.
      – Bob
      Jun 27 '16 at 3:56








    • 4




      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










    • 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















    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.






    share|improve this answer



















    • 6




      FYI, Google also evaluates log2(536870912) just fine.
      – Bob
      Jun 27 '16 at 3:56








    • 4




      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










    • 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













    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.






    share|improve this answer














    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 27 '16 at 14:41

























    answered Jun 26 '16 at 21:38









    Ben N

    28.9k1394141




    28.9k1394141








    • 6




      FYI, Google also evaluates log2(536870912) just fine.
      – Bob
      Jun 27 '16 at 3:56








    • 4




      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










    • 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














    • 6




      FYI, Google also evaluates log2(536870912) just fine.
      – Bob
      Jun 27 '16 at 3:56








    • 4




      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










    • 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








    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












    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





    share|improve this answer

























      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





      share|improve this answer























        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





        share|improve this answer












        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 26 '16 at 23:57









        Oriol

        67471630




        67471630






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            AnyDesk - Fatal Program Failure

            How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

            QoS: MAC-Priority for clients behind a repeater