Re: Fwd: Re: JMathConstant submission for upcoming JDK
Here are the measurement systems, as I see them. public enum MeasurementSystem { INTERNATIONAL_SYSTEM_OF_UNITS, METRIC, UNITED_STATES_CUSTOMARY, BRITISH_IMPERIAL }
Re: Fwd: Re: JMathConstant submission for upcoming JDK
Hello, I would not support a class with this purpose of this scale to be added to the JDK. BigDecimal has had constants for zero, one, and ten since JDK 5.0 shipped in 2004. I consider myself to have a reasonable math background for a non-mathematician and I don't know what field many of these constants are from. In other words, many of the constants are for more specialized use as opposed to being generally usable. In terms of how the constants are structured, for a BigDecimal-based API I would expect a method that took a MathContext to determine how many digits are needed and under what rounding mode as opposed to a field with a fixed precision (unless the constant is some exactly representable number). For example, it would be a "small matter or programming" to provide methods like BigDecimal pi(MathContext mc) BigDecimal tau(MathContext mc) BigDecimal euler(MathContext mc) that returned suitably rounded approximation of those transcendental values. A value like GRAVITY is a poor fit for BigDecimal; first it depends on the units (SI vs Imperial units) and is subject to adjustment with further scientific investigation. Cheers, -Joe On 10/26/2018 12:12 PM, Roger Riggs wrote: [Sorry for the repeat, this time to ensure Robert sees the question] Hi Robert, No doubt a useful list of constants for some developers. Can you elaborate on why you think these constants should be in the JDK and why they are the right constants especially as related to precision and length. I would expect for some applications these would be more precise than they need and hurt performance and for other applications they would not have enough precision. Thanks, Roger On 10/26/18 12:39 PM, rob...@liguorisoftware.com wrote: Hi Chris, I wrote this simple utility class you may want to use in an upcoming version of the JDK. Btw, I'm the author of the Java Pocket Guide.:) Or is there a better place I can submit simple code like this for the JDK? Thanks, Robert 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.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); public static final BigDecimal UNKNOWN_NAME = new BigDecimal("2.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); 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.618033988749894848204586834365638
Re: JMathConstant submission for upcoming JDK
Redirecting to core-libs-dev. I filed https://bugs.openjdk.java.net/browse/JDK-8213045. Paul On 10/26/18, 10:50 AM, "jdk-dev on behalf of Hohensee, Paul" wrote: This would go to core-libs-dev, and would be a spec change since it adds a class. The concept could be expanded to BigInteger, Long, Integer, etc. Instead of adding a class, one could add these constants directly to BigDecimal (and the others), but that would also be a spec change since it adds public members. You should file a JBS bug. If you don't have access to JBS, I'd be happy to file it for you. Thanks, Paul On 10/26/18, 9:41 AM, "jdk-dev on behalf of rob...@liguorisoftware.com" wrote: Hi Chris, I wrote this simple utility class you may want to use in an upcoming version of the JDK. Btw, I'm the author of the Java Pocket Guide. :) Or is there a better place I can submit simple code like this for the JDK? Thanks, Robert 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.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019 27876611 1959092164201989"); public static final BigDecimal UNKNOWN_NAME = new BigDecimal("2.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019 27876611 1959092164201989"); 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")
Fwd: Re: JMathConstant submission for upcoming JDK
[Sorry for the repeat, this time to ensure Robert sees the question] Hi Robert, No doubt a useful list of constants for some developers. Can you elaborate on why you think these constants should be in the JDK and why they are the right constants especially as related to precision and length. I would expect for some applications these would be more precise than they need and hurt performance and for other applications they would not have enough precision. Thanks, Roger On 10/26/18 12:39 PM, rob...@liguorisoftware.com wrote: Hi Chris, I wrote this simple utility class you may want to use in an upcoming version of the JDK. Btw, I'm the author of the Java Pocket Guide.:) Or is there a better place I can submit simple code like this for the JDK? Thanks, Robert 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.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); public static final BigDecimal UNKNOWN_NAME = new BigDecimal("2.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); 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.567143290409783872686622103"); public static final BigDecimal EULER_MASCHERONI = new BigDecimal("0.57721"); public static final BigDecimal GOLOMB_DICKMAN = new BigDecimal("0.6243
Re: JMathConstant submission for upcoming JDK
Hi Robert, No doubt a useful list of constants for some developers. Can you elaborate on why you think these constants should be in the JDK and why they are the right constants especially as related to precision and length. I would expect for some applications these would be more precise than they need and hurt performance and for other applications they would not have enough precision. Thanks, Roger On 10/26/18 12:39 PM, rob...@liguorisoftware.com wrote: Hi Chris, I wrote this simple utility class you may want to use in an upcoming version of the JDK. Btw, I'm the author of the Java Pocket Guide. :) Or is there a better place I can submit simple code like this for the JDK? Thanks, Robert 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.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); public static final BigDecimal UNKNOWN_NAME = new BigDecimal("2.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001! 927876611 1959092164201989"); 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.567143290409783872686622103"); public static final BigDecimal EULER_MASCHERONI = new BigDecimal("0.57721"); public static final BigDecimal GOLOMB_DICKMAN = new BigDecimal("0.6243299885435508709929363831083724"); public static final BigDeci