Answer:
Doing what is right I think
Answer:
public class Brainly
{
public static void main(String[] args)
{
BinaryConverter conv = new BinaryConverter();
String binStr = "01001101";
System.out.print(binStr + " in decimal is "+conv.BinToDec(binStr));
}
}
public class BinaryConverter
{
public int BinToDec(String binStr)
{
int d = 0;
while(binStr.length() > 0)
{
d = (d << 1) + ((binStr.charAt(0) == '1') ? 1: 0);
binStr = binStr.substring(1);
}
return d;
}
}
Explanation:
The program "eats" the string from left to right, and builds up the integer representation in variable "d" on the go. While there are digits left, it shifts the previous result to the left and sets the least signficant bit to 1 only if the corresponding string character is a 1.
Answer:

Explanation:
Considering the number are stored using binary notations.
If there are total 86 bits and 1 bit is used as sign bit. Then in total one can have
bit combinations since a bit can be either stored as 0 or as 1.
Therefore, the largest number that can be stored will be
.
To understand it in better way let's scale down the problem to 3 bits representation. The largest number that can be stored using 3 bits is 111 which in decimal form is 7 and is equal to
.
Answer:
Following are the code in the PHP Programming Language:
<u>foreach ($country_codes as $code => $name) {
</u>
Explanation:
The following option is true because the Foreach statement only works on the objects and array and this statement is good for accessing the key and value pairs from the array.
So, that's why to print following associative array through echo statement we use the Foreach loop statement with following right condition.
<u>syntax</u>:
foreach (array as value)
{
code or body to execute;
}