diff --git a/toolkits/math/arcade_math/tools/arithmetic.py b/toolkits/math/arcade_math/tools/arithmetic.py index 1bb128f7..77238503 100644 --- a/toolkits/math/arcade_math/tools/arithmetic.py +++ b/toolkits/math/arcade_math/tools/arithmetic.py @@ -1,8 +1,11 @@ +import decimal from decimal import Decimal from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def add( diff --git a/toolkits/math/arcade_math/tools/exponents.py b/toolkits/math/arcade_math/tools/exponents.py index a7362131..746da832 100644 --- a/toolkits/math/arcade_math/tools/exponents.py +++ b/toolkits/math/arcade_math/tools/exponents.py @@ -1,9 +1,12 @@ +import decimal import math from decimal import Decimal from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def log( diff --git a/toolkits/math/arcade_math/tools/miscellaneous.py b/toolkits/math/arcade_math/tools/miscellaneous.py index f3d624cf..0f414897 100644 --- a/toolkits/math/arcade_math/tools/miscellaneous.py +++ b/toolkits/math/arcade_math/tools/miscellaneous.py @@ -1,9 +1,12 @@ +import decimal import math from decimal import Decimal from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def abs_val( diff --git a/toolkits/math/arcade_math/tools/rounding.py b/toolkits/math/arcade_math/tools/rounding.py index 59b7becd..2e410ddd 100644 --- a/toolkits/math/arcade_math/tools/rounding.py +++ b/toolkits/math/arcade_math/tools/rounding.py @@ -1,9 +1,12 @@ +import decimal import math from decimal import Decimal from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def ceil( diff --git a/toolkits/math/arcade_math/tools/statistics.py b/toolkits/math/arcade_math/tools/statistics.py index b197a7e2..a91a938d 100644 --- a/toolkits/math/arcade_math/tools/statistics.py +++ b/toolkits/math/arcade_math/tools/statistics.py @@ -1,9 +1,12 @@ +import decimal from decimal import Decimal from statistics import median as stats_median from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def avg( diff --git a/toolkits/math/arcade_math/tools/trigonometry.py b/toolkits/math/arcade_math/tools/trigonometry.py index e7cecb3f..c58c2b23 100644 --- a/toolkits/math/arcade_math/tools/trigonometry.py +++ b/toolkits/math/arcade_math/tools/trigonometry.py @@ -1,9 +1,12 @@ +import decimal import math from decimal import Decimal from typing import Annotated from arcade.sdk import tool +decimal.getcontext().prec = 100 + @tool def deg_to_rad( diff --git a/toolkits/math/tests/test_arithmetic.py b/toolkits/math/tests/test_arithmetic.py index 2404f80b..8804d612 100644 --- a/toolkits/math/tests/test_arithmetic.py +++ b/toolkits/math/tests/test_arithmetic.py @@ -62,13 +62,13 @@ def test_subtract(a, b, expected): ( "12345678901234567890", "18000000162000001474380013420000", - "2.222222222222222222222222223E+50", + "222222222222222222222222222261233060226101083800000", ), # Big floats ( "12345678901234567890.120", "12345678901234567890.120", - "1.524157875323883675048681628E+38", + "152415787532388367504868162811315348393.614400", ), ], ) @@ -81,7 +81,12 @@ def test_multiply(a, b, expected): [ ("-1", "2", "-0.5"), ("-10", "1", "-10"), - ("0.5", "10.9", "0.04587155963302752293577981651"), + ( + "0.5", + "10.9", + "0.0458715596330275229357798165137614678899082568807339" + "4495412844036697247706422018348623853211009174312", + ), # Big ints ("152407406035740740602050", "12345678901234567890", "12345"), # Big floats diff --git a/toolkits/math/tests/test_exponents.py b/toolkits/math/tests/test_exponents.py index f5825a85..d5628fda 100644 --- a/toolkits/math/tests/test_exponents.py +++ b/toolkits/math/tests/test_exponents.py @@ -20,10 +20,19 @@ def test_log(): def test_power(): assert power("-8", "2") == "64" assert power("0", "10") == "0" - assert power("2", "0.5") == "1.414213562373095048801688724" + assert ( + power("2", "0.5") == "1.41421356237309504880168872420969807856" + "9671875376948073176679737990732478462107038850387534327641573" + ) assert power("2", "3") == "8" - assert power("2.", "-0.5") == "0.7071067811865475244008443621" - assert power("2.1234", "0.6") == "1.571155202490495156807227175" + assert ( + power("2.", "-0.5") == "0.707106781186547524400844362104849039" + "2848359376884740365883398689953662392310535194251937671638207864" + ) + assert ( + power("2.1234", "0.6") == "1.571155202490495156807227174573016145" + "282682479346448636509576776014844055570115193494685328114403375" + ) assert power("2.1234", "1") == "2.1234" assert power("2.1234", "3") == "9.574044440904" assert power("8", "-2") == "0.015625" diff --git a/toolkits/math/tests/test_miscellaneous.py b/toolkits/math/tests/test_miscellaneous.py index 8946e88a..a4a88510 100644 --- a/toolkits/math/tests/test_miscellaneous.py +++ b/toolkits/math/tests/test_miscellaneous.py @@ -41,16 +41,34 @@ def test_sqrt(): assert sqrt("1") == "1" assert sqrt("0") == "0" assert sqrt("-0") == "-0" - assert sqrt("23") == "4.795831523312719541597438064" - assert sqrt("24") == "4.898979485566356196394568149" - assert sqrt("10") == "3.162277660168379331998893544" + assert ( + sqrt("23") == "4.79583152331271954159743806416269391999670704190" + "4129346485309114448257235907464082492191446436918861" + ) + assert ( + sqrt("24") == "4.89897948556635619639456814941178278393189496131" + "3340256865385134501920754914630053079718866209280470" + ) + assert ( + sqrt("10") == "3.16227766016837933199889354443271853371955513932" + "5216826857504852792594438639238221344248108379300295" + ) assert sqrt("0.0") == "0.0" assert sqrt("0.0000") == "0.00" assert sqrt("-0.0") == "-0.0" assert sqrt("1.0") == "1.0" - assert sqrt("3.14") == "1.772004514666935040199112510" - assert sqrt("0.4") == "0.6324555320336758663997787089" - assert sqrt("10.0") == "3.162277660168379331998893544" + assert ( + sqrt("3.14") == "1.772004514666935040199112509753631525073608516" + "162942966817771970290992972348902551472561151153909188" + ) + assert ( + sqrt("0.4") == "0.6324555320336758663997787088865437067439110278" + "650433653715009705585188877278476442688496216758600590" + ) + assert ( + sqrt("10.0") == "3.162277660168379331998893544432718533719555139" + "325216826857504852792594438639238221344248108379300295" + ) with pytest.raises(ToolExecutionError): sqrt("-1") with pytest.raises(ToolExecutionError):