// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.math.BigDecimal;

public class BDFun {
    private static final int N = 18000;
    public static void main(String[] args) throws Exception {
        StringBuilder sb = new StringBuilder();
        sb.append('1');
        for(int i = 0; i < N - 1; i++) {
            sb.append('0');
        }
        sb.append('.');
        for(int i = 0; i < N - 1; i++) {
            sb.append('0');
        }
        sb.append('1');
        BigDecimal sum = new BigDecimal(0);
        BigDecimal v = new BigDecimal(sb.toString());
        sum = sum.add(v);
        sum = sum.add(v);
        sum = sum.add(v);
        String s = sum.toPlainString();
        if(s.charAt(0) != '3') throw new Exception("bad start");
        for(int i = 0; i < N - 1; i++) {
            if(s.charAt(1 + i) != '0') throw new Exception("bad first");
        }
        if(s.charAt(N) != '.') throw new Exception("bad middle");
        for(int i = 0; i < N - 1; i++) {
            if(s.charAt(N + 1 + i) != '0') throw new Exception("bad second");
        }
        if(s.charAt(2 * N) != '3') throw new Exception("bad end");
    }
}
