: Can you explain this block of code? public int getValue(String bitsValue) { bits = new StringBuffer(bitsValue).reverse().toString();
Fantastic news! We've Found the answer you've been seeking!
Question:
: Can you explain this block of code?
public int getValue(String bitsValue) { bits = new StringBuffer(bitsValue).reverse().toString(); int digit = 0; int ndigit; for (int i = 0; i < bits.length(); i++) { String bit = bits.substring(i, i + 1); if (bit.equals("0")) { ndigit = 0; } else { ndigit = 1; } digit = digit + ndigit * (int) Math.pow(2, i); } return digit; }
Related Book For
Posted Date: