Auf Thema antworten

[code=java]

public class B2D {

    public static double b2d(String s) {

        double y = 0;

        for (int x = 0; x <= 7; x++) {

            if (s.charAt(x) == '1') {

                y = y + Math.pow(2, 7 - x);

            }

        }

        return y;

    }


    public static void main(String[] args) {

        System.out.println(b2d("00010110"));

    }

};

[/code]



Oben