Skip to content

Instantly share code, notes, and snippets.

@IvanPizhenko
Created March 9, 2018 09:46
Show Gist options
  • Save IvanPizhenko/1fb04bc8570da4801a19efba5ec8945f to your computer and use it in GitHub Desktop.
Save IvanPizhenko/1fb04bc8570da4801a19efba5ec8945f to your computer and use it in GitHub Desktop.
import java.math.BigDecimal;
import java.math.BigInteger;
public class TeaConstants {
public static void main(String[] args) {
final BigDecimal z = new BigDecimal("1.6180339887498948482045868343656");
BigDecimal p = new BigDecimal("256.0000000000000000000000000000000");
for (int i = 0; i < 5; ++i) {
final BigDecimal k = p.divide(z, BigDecimal.ROUND_FLOOR);
final BigInteger ki = k.toBigInteger();
System.out.println(String.format("%s (0x%s)", ki, ki.toString(16)));
p = p.multiply(p);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment