Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8213045

Add commonly used symbolic math constants to the JDK

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 12
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Filed on behalf of Robert Ligouri, robert@ligourisoftware.com. I cut down the definition of NEAR_ONE.

      Here's a simple utility class you may want to use in an upcoming
      version of the JDK.

      ---------

      import java.math.BigDecimal;

      public class JMathConstant {

           private JMathConstant() {
           }

           // ZERO, 1/2 AND ONE
           public static final BigDecimal ZERO = new
      BigDecimal("0.0");
           public static final BigDecimal LANDAUS = new
      BigDecimal("0.5");
           public static final BigDecimal ONE = new
      BigDecimal("1.0");
           public static final BigDecimal LEGENDRE = new
      BigDecimal("1.0");

           // SILVER AND GOLD
           public static final BigDecimal ARCHIMEDES_RATIO = new
      BigDecimal("3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989");
           public static final BigDecimal UNKNOWN_NAME = new
      BigDecimal("2.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989");
           public static final BigDecimal SILVER_RATIO = new
      BigDecimal("2.4142135623730950488");
           public static final BigDecimal PYTHAGORAS = new
      BigDecimal("1.4142135623730950488");
           public static final BigDecimal GOLDEN_RATIO = new
      BigDecimal("1.61803398874989484820458683436563811772030917980576286213544862270526046281890");
           public static final BigDecimal INVERSE_GOLDEN_RATIO = new
      BigDecimal("0.61803398874989484820458683436563811772030917980576286213544862270526046281890");

           // ADDITIONAL RATIO CONSTANTS
           public static final BigDecimal FEIGENBAUMS_RATIO_1 = new
      BigDecimal("4.66920160910299067185320382046620161");
           public static final BigDecimal FEIGENBAUMS_RATIO_2 = new
      BigDecimal("2.50290787509589282228390287321821578");

           // OTHERS
           public static final BigDecimal MEISSEL_MERTENS = new
      BigDecimal("0.26149721284764278375542683860869585");
           public static final BigDecimal BERNSTEINS = new
      BigDecimal("0.28016949902386913303");
           public static final BigDecimal GAUSS_KKUZMIN_WIRSING = new
      BigDecimal("0.30366300289873265859744812190155623");
           public static final BigDecimal HAFNER_SARNAK_MCCURLEY = new
      BigDecimal("0.35323637185499598454351655043268201");
           public static final BigDecimal OMEGA = new
      BigDecimal("0.56714329040978387299996866221035555");
           public static final BigDecimal EULER_MASCHERONI = new
      BigDecimal("0.57721");
           public static final BigDecimal GOLOMB_DICKMAN = new
      BigDecimal("0.6243299885435508709929363831083724");
           public static final BigDecimal CAHEN = new
      BigDecimal("0.6434105463");
           public static final BigDecimal TWO_PRIME = new
      BigDecimal("0.6601618158468695739281211001455577");
           public static final BigDecimal LAPLANE_LIMIT = new
      BigDecimal("0.66274341934918158097474209710925290");
           public static final BigDecimal EMBREE_TREFETHEN = new
      BigDecimal("0.70258");
           public static final BigDecimal LANDAU_RAMANUJAN = new
      BigDecimal("0.76422365358922066299069873125009232");
           public static final BigDecimal ALLADI_GRINSTEAD = new
      BigDecimal("0.8093940205");
           public static final BigDecimal BRUN = new
      BigDecimal("0.8705883800");
           public static final BigDecimal CATALANS = new
      BigDecimal("0.91596559417721901505460351493238411");
           public static final BigDecimal LENGYELS = new
      BigDecimal("1.0986858055");
           public static final BigDecimal VISWANATHS = new
      BigDecimal("1.13198824");
           public static final BigDecimal APERYS = new
      BigDecimal("1.20205690315959428539973816151144999");
           public static final BigDecimal GLAISHER_KINKELIN = new
      BigDecimal("1.2824271291");
           public static final BigDecimal CONWAYS = new
      BigDecimal("1.30357726903429639125709911215255189");
           public static final BigDecimal MILLS = new
      BigDecimal("1.30637788386308069046861449260260571");
           public static final BigDecimal PLASTIC = new
      BigDecimal("1.32471795724474602596090885447809734");
           public static final BigDecimal RAMANUJAN_SOLDNER = new
      BigDecimal("1.45136923488338105028396848589202744");
           public static final BigDecimal PORTERS = new
      BigDecimal("1.4670780794");
           public static final BigDecimal BACKHOUSE = new
      BigDecimal("1.45607494858268967139959535111654356");
           public static final BigDecimal LIEBS_SQUARE_ICE = new
      BigDecimal("1.5396007178");
           public static final BigDecimal ERDOS_BORWEIN = new
      BigDecimal("1.60669515241529176378330152319092458");
           public static final BigDecimal NIVENS = new
      BigDecimal("1.70521114010536776428855145343450816");
           public static final BigDecimal THEODORUS = new
      BigDecimal("1.73205080756887729352744634150587236");
           public static final BigDecimal BRUNS = new
      BigDecimal("1.9021605823");
           public static final BigDecimal UNIVERSAL_PARABOLIC = new
      BigDecimal("2.29558714939263807403429804918949039");
           public static final BigDecimal SIERPINSKI = new
      BigDecimal("2.58498175957925321706589358738317116");
           public static final BigDecimal KHINCHIN = new
      BigDecimal("2.68545200106530644530971483548179569");
           public static final BigDecimal NAPIERS = new
      BigDecimal("2.7182818284590452353602874713527");
           public static final BigDecimal FRANSEN_ROBINSON = new
      BigDecimal("2.80777024202851936522150118655777293");
           public static final BigDecimal LEVYS = new
      BigDecimal("3.27582291872181115978768188245384386");
           public static final BigDecimal RECIPROCAL_FIBONACCI = new
      BigDecimal("3.35988566624317755317201130291892717");
           public static final BigDecimal GRAVITY = new
      BigDecimal("32.17404856"); // ft/sec^2

           public static final BigDecimal NEAR_ONE = new
      BigDecimal("0.99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999");

           public static final BigDecimal DIVIDE_BY_998001 = new
      BigDecimal("0.000001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089090091092093094095096097098099100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997999");

           // ALTERNATE NAMES
           public static final BigDecimal PI = ARCHIMEDES_RATIO;

           public static void main(String[] args) {
               System.out.println("MEISSEL_MERTENS CONSTANT: " +
      MEISSEL_MERTENS);
           }
      }

        Attachments

          Activity

            People

            • Assignee:
              bpb Brian Burkhalter
              Reporter:
              phh Paul Hohensee
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: