views:

101

answers:

4

in hexadecimal "10 10 10 10" system you have 0-255 posibilities right? in total 256 different posibilities as there are 8 1s and 0s.

how many different posibilities would i get?

if i had 10 digits. instead of 8?

or how would i calculate that in php ?

+11  A: 

I assume you are thinking of binary rather than hexadecimal? Binary is base 2 (hence either 0 or 1s) where as Hexadecimal is base 16.

Assuming you are talking about binary:

  • If you have 8 bits you have 28 possibilities.
  • If you have 9 bits you have 29 possibilities.
  • If you have 10 bits you have 210 possibilities.

Etc...

You can therefore use the PHP pow function:

$possibilities = pow(2, 10);
Yacoby
are you absolutely sure what i mean ? that gives me a 1024 posibilities
Val
@Val assuming you are talking about binary, then yes. If you had 10 bits (where each bit is 0 or 1) you could store the numbers between 0 - 1023. (So there are 1024 total different possibilities)
Yacoby
Yes that is right, to put it another way, each time you add a binary bit, you double the the number of possibilities, just as when you add a decimal digit, you multiply the number of possibilities by 10.
Martin
+1  A: 

It would be 2^10 (2*2*2*2*2*2*2*2*2*2)

In SQL Server

SELECT 2*2*2*2*2*2*2*2*2*2

SELECT POWER(2,10)
SQLMenace
A: 

You should read and learn http://en.wikipedia.org/wiki/Numerical_base .

phresnel
+2  A: 

As much as I love the idea to send a query to SQL Server for this, the OP could appreciate a pure PHP implementation.

I suggest this:

#!/usr/bin/php
<?php
function howmanypossibilities($digits) {
    preg_match_all('{<b>.+= (.+?)</b>}',·
    file_get_contents('http://www.google.com/search?q=2**'.$digits), $matches);
    return str_replace('<font size=-2> </font>', ',', "{$matches[1][0]}\n");
}

print howmanypossibilities(10);
?>
Marco Mariani
+1: Brilliant! :-)
Vicky