daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.math.BigDecimal;
  2. import java.math.BigInteger;
  3. import java.math.MathContext;
  4.  
  5. int digits = 11;
  6. MathContext mc = new MathContext(digits*digits + 1);
  7. BigDecimal c = new BigDecimal(0.25);
  8. BigDecimal hundred = new BigDecimal(100);
  9. BigDecimal e = BigDecimal.ONE.divide(hundred.pow(digits-1), mc);
  10. BigDecimal z = BigDecimal.ZERO;
  11. BigInteger iterations = new BigInteger((int)(pow(2, 32)));
  12. BigDecimal two = new BigDecimal(2);
  13.  
  14. void setup() {
  15.   size(1440, 1080);
  16.   c = c.add(e, mc);
  17. }
  18.  
  19. void draw() {
  20.   for (int i = 0; i < 10691; i++) {
  21.     if (z.compareTo(two) == -1) {
  22.       z = z.multiply(z, mc);
  23.       z = z.add(c, mc);
  24.       //if (iterations % 10000 == 0 || z.compareTo(two) == 1) {
  25.       //println(z.toString());
  26.       iterations = iterations.add(BigInteger.ONE);
  27.     } else {
  28.       noLoop();
  29.       break;
  30.     }
  31.   }
  32.  
  33.   background(0);
  34.   fill(255);
  35.   textSize(48);
  36.   textAlign(CENTER);
  37.   text(iterations.toString(), width/2+250, height/2+textDescent());
  38. }
  39.  
  40. String padLeftZeros(String inputString, int length) {
  41.   if (inputString.length() >= length) {
  42.     return inputString;
  43.   }
  44.   StringBuilder sb = new StringBuilder();
  45.   while (sb.length() < length - inputString.length()) {
  46.     sb.append('0');
  47.   }
  48.   sb.append(inputString);
  49.  
  50.   return sb.toString();
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top