Advertisement
jundarer

Untitled

Jun 20th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. package ms1;
  2.  
  3. import java.lang.Math;
  4. import java.math.BigDecimal;
  5. import java.math.MathContext;
  6. import java.math.RoundingMode;
  7.  
  8. public class Mathcore {
  9. public static final int STELLEN_INTERN = 200;
  10. public static final int STELLEN_OUTPUT = 30;
  11. public static final MathContext mc = new MathContext(STELLEN_INTERN, RoundingMode.HALF_EVEN);
  12. public static final MathContext mc_out = new MathContext(STELLEN_OUTPUT, RoundingMode.HALF_EVEN);
  13. public static final BigDecimal epsilon = BigDecimal.ONE.scaleByPowerOfTen(-(STELLEN_INTERN + 1));
  14. public static final String PI = "3.141592653589793238462643383279502884197169399375105820974944592307816406286208"
  15. + "99862803482534211706798214808651328230664709384460955058223172535940812848111745"
  16. + "02841027019385211055596446229489549303819644288109756659334461284756482337867831"
  17. + "65271201909145648566923460348610454326648213393607260249141273724587006606315588"
  18. + "17488152092096282925409171536436789259036001133053054882046652138414695194151160"
  19. + "94330572703657595919530921861173819326117931051185480744623799627495673518857527"
  20. + "24891227938183011949129833673362440656643086021394946395224737190702179860943702"
  21. + "77053921717629317675238467481846766940513200056812714526356082778577134275778960"
  22. + "91736371787214684409012249534301465495853710507922796892589235420199561121290219"
  23. + "60864034418159813629774771309960518707211349999998372978049951059731732816096318"
  24. + "59502445945534690830264252230825334468503526193118817101000313783875288658753320"
  25. + "83814206171776691473035982534904287554687311595628638823537875937519577818577805"
  26. + "32171226806613001927876611195909216420198938095257201065485863278865936153381827"
  27. + "96823030195203530185296899577362259941389124972177528347913151557485724245415069"
  28. + "59508295331168617278558890750983817546374649393192550604009277016711390098488240"
  29. + "12858361603563707660104710181942955596198946767837449448255379774726847104047534"
  30. + "64620804668425906949129331367702898915210475216205696602405803815019351125338243"
  31. + "00355876402474964732639141992726042699227967823547816360093417216412199245863150"
  32. + "30286182974555706749838505494588586926995690927210797509302955321165344987202755"
  33. + "96023648066549911988183479775356636980742654252786255181841757467289097777279380"
  34. + "00816470600161452491921732172147723501414419735685481613611573525521334757418494"
  35. + "68438523323907394143334547762416862518983569485562099219222184272550254256887671"
  36. + "79049460165346680498862723279178608578438382796797668145410095388378636095068006"
  37. + "42251252051173929848960841284886269456042419652850222106611863067442786220391949"
  38. + "450471237137869609563643719172874677646575739624138908658326459958133904780275901";
  39. public static final String E = "2.718281828459045235360287471352662497757247093699959574966967627724076630353547"
  40. + "59457138217852516642742746639193200305992181741359662904357290033429526059563073"
  41. + "81323286279434907632338298807531952510190115738341879307021540891499348841675092"
  42. + "44761460668082264800168477411853742345442437107539077744992069551702761838606261"
  43. + "33138458300075204493382656029760673711320070932870912744374704723069697720931014"
  44. + "16928368190255151086574637721112523897844250569536967707854499699679468644549059"
  45. + "87931636889230098793127736178215424999229576351482208269895193668033182528869398"
  46. + "49646510582093923982948879332036250944311730123819706841614039701983767932068328"
  47. + "23764648042953118023287825098194558153017567173613320698112509961818815930416903"
  48. + "51598888519345807273866738589422879228499892086805825749279610484198444363463244"
  49. + "96848756023362482704197862320900216099023530436994184914631409343173814364054625"
  50. + "31520961836908887070167683964243781405927145635490613031072085103837505101157477"
  51. + "04171898610687396965521267154688957035035402123407849819334321068170121005627880"
  52. + "23519303322474501585390473041995777709350366041699732972508868769664035557071622"
  53. + "68447162560798826517871341951246652010305921236677194325278675398558944896970964"
  54. + "09754591856956380236370162112047742722836489613422516445078182442352948636372141"
  55. + "74023889344124796357437026375529444833799801612549227850925778256209262264832627"
  56. + "79333865664816277251640191059004916449982893150566047258027786318641551956532442"
  57. + "58698294695930801915298721172556347546396447910145904090586298496791287406870504"
  58. + "89585867174798546677575732056812884592054133405392200011378630094556068816674001"
  59. + "69842055804033637953764520304024322566135278369511778838638744396625322498506549"
  60. + "95886234281899707733276171783928034946501434558897071942586398772754710962953741"
  61. + "52111513683506275260232648472870392076431005958411661205452970302364725492966693"
  62. + "81151373227536450988890313602057248176585118063036442812314965507047510254465011"
  63. + "727211555194866850800368532281831521960037356252794495158284188294787610852639814";
  64.  
  65. public static BigDecimal add(BigDecimal a,BigDecimal b){
  66. return a.add(b);
  67. }
  68.  
  69. public static BigDecimal sub(BigDecimal a,BigDecimal b){
  70. return a.subtract(b);
  71. }
  72.  
  73. public static BigDecimal div(BigDecimal a,BigDecimal b){
  74. return a.divide(b);
  75. }
  76.  
  77. public static BigDecimal mul(BigDecimal a,BigDecimal b){
  78. return a.multiply(b);
  79. }
  80.  
  81. public static BigDecimal fak(BigDecimal a){
  82. BigDecimal out=BigDecimal.ONE;
  83. for (BigDecimal i = BigDecimal.ZERO; i.compareTo(a) < 0; i = i.add(BigDecimal.ONE)){
  84. out=out.multiply(i.add(BigDecimal.ONE));
  85. }
  86. return out;
  87. }
  88.  
  89. public static BigDecimal exp(BigDecimal a){
  90. return a;
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement