chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
8d0f0d1d-1c1a-4f9f-9f83-ad73a649855b
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,803
supabase-export-v2
3bbf27a738df9d4d
of a mixed operation is silently recorded by setting :exc:`FloatOperation` in the context flags. Explicit conversions with :meth:`~decimal.Decimal.from_float` or :meth:`~decimal.Context.create_decimal_from_float` do not set the flag. Otherwise (the signal is trapped), only equality comparisons and explicit conversions...
trusted_official_docs
CPython Docs
of a mixed operation is silently recorded by setting :exc:`FloatOperation` in the context flags. Explicit conversions with :meth:`~decimal.Decimal.from_float` or :meth:`~decimal.Context.create_decimal_from_float` do not set the flag. Otherwise (the signal is trapped), only equality comparisons and explicit conversions...
of a mixed operation is silently recorded by setting :exc:`FloatOperation` in the context flags. Explicit conversions with :meth:`~decimal.Decimal.from_float` or :meth:`~decimal.Context.create_decimal_from_float` do not set the flag. Otherwise (the signal is trapped), only equality comparisons and explicit conversions...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8d3e5c23-3790-4fd5-90b9-090a805057eb
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,886
supabase-export-v2
f15450a83288769d
an application does not care about tracking significance, it is easy to remove the exponent and trailing zeroes, losing significance, but keeping the value unchanged: >>> def remove_exponent(d): ... return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
trusted_official_docs
CPython Docs
an application does not care about tracking significance, it is easy to remove the exponent and trailing zeroes, losing significance, but keeping the value unchanged: >>> def remove_exponent(d): ... return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
an application does not care about tracking significance, it is easy to remove the exponent and trailing zeroes, losing significance, but keeping the value unchanged: >>> def remove_exponent(d): ... return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
python, official-docs, cpython, P0
Local_Trusted_Corpus
8db9b65f-397d-4521-a180-f459c7b27668
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,597
supabase-export-v2
d2caa739d3f80b01
.. attribute:: clamp Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of a :class:`Decimal` instance representable in this context is strictly limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is ``0`` then a weaker condition holds: the adjusted exponent of the :cla...
trusted_official_docs
CPython Docs
.. attribute:: clamp Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of a :class:`Decimal` instance representable in this context is strictly limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is ``0`` then a weaker condition holds: the adjusted exponent of the :cla...
.. attribute:: clamp Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of a :class:`Decimal` instance representable in this context is strictly limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is ``0`` then a weaker condition holds: the adjusted exponent of the :cla...
python, official-docs, cpython, P0
Local_Trusted_Corpus
910e9a15-37e5-4781-a81e-73999c09ed1a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,349
supabase-export-v2
7570058703d4778f
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())) >>> max(data) Decimal('9.25') >>> min(data) Decimal('0.03') >>> sorted(data) [Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'), Decimal('2.35'), Decimal('3.45'), Decimal('9.2...
trusted_official_docs
CPython Docs
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())) >>> max(data) Decimal('9.25') >>> min(data) Decimal('0.03') >>> sorted(data) [Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'), Decimal('2.35'), Decimal('3.45'), Decimal('9.2...
.. doctest:: :options: +NORMALIZE_WHITESPACE >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())) >>> max(data) Decimal('9.25') >>> min(data) Decimal('0.03') >>> sorted(data) [Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'), Decimal('2.35'), Decimal('3.45'), Decimal('9.2...
python, official-docs, cpython, P0
Local_Trusted_Corpus
914b41e3-8235-46f2-adca-b926158934cd
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,582
supabase-export-v2
6605ea4f6b2734ca
In single threaded environments, it is preferable to not use this context at all. Instead, simply create contexts explicitly as described below. The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperat...
trusted_official_docs
CPython Docs
In single threaded environments, it is preferable to not use this context at all. Instead, simply create contexts explicitly as described below. The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperat...
In single threaded environments, it is preferable to not use this context at all. Instead, simply create contexts explicitly as described below. The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperat...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9169ae22-1a18-463c-b394-f21c9807608e
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,883
supabase-export-v2
40e1cd95e77bdc0b
addition Decimal('3.1416') >>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round Decimal('3.1415') >>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded Decimal('3.1416') Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
trusted_official_docs
CPython Docs
addition Decimal('3.1416') >>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round Decimal('3.1415') >>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded Decimal('3.1416') Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
addition Decimal('3.1416') >>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round Decimal('3.1415') >>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded Decimal('3.1416') Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
python, official-docs, cpython, P0
Local_Trusted_Corpus
91997fd6-e782-4d00-9310-72ae103c0bfb
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,836
supabase-export-v2
e41898c08e42fcdb
use the default values from *DefaultContext*. If the flag is true, new threads will start with a copy of context from the caller of :meth:`threading.Thread.start`. To control the defaults so that each thread will use the same values throughout the application, directly modify the *DefaultContext* object. This should be...
trusted_official_docs
CPython Docs
use the default values from *DefaultContext*. If the flag is true, new threads will start with a copy of context from the caller of :meth:`threading.Thread.start`. To control the defaults so that each thread will use the same values throughout the application, directly modify the *DefaultContext* object. This should be...
use the default values from *DefaultContext*. If the flag is true, new threads will start with a copy of context from the caller of :meth:`threading.Thread.start`. To control the defaults so that each thread will use the same values throughout the application, directly modify the *DefaultContext* object. This should be...
python, official-docs, cpython, P0
Local_Trusted_Corpus
934b196c-6b40-4de6-baf6-866b7215323d
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,751
supabase-export-v2
f4eff1667ab4f161
The following constants are only relevant for the C module. They are also included in the pure Python version for compatibility. +---------------------------------+---------------------+-------------------------------+ | | 32-bit | 64-bit | +=================================+=====================+======================...
trusted_official_docs
CPython Docs
The following constants are only relevant for the C module. They are also included in the pure Python version for compatibility. +---------------------------------+---------------------+-------------------------------+ | | 32-bit | 64-bit | +=================================+=====================+======================...
The following constants are only relevant for the C module. They are also included in the pure Python version for compatibility. +---------------------------------+---------------------+-------------------------------+ | | 32-bit | 64-bit | +=================================+=====================+======================...
python, official-docs, cpython, P0
Local_Trusted_Corpus
97ce1d5b-450c-4e28-805b-8e0b91f38224
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,497
supabase-export-v2
b6fb6a70c53eac5d
Used for producing canonical values of an equivalence class within either the current context or the specified context. This has the same semantics as the unary plus operation, except that if the final result is finite it is reduced to its simplest form, with all trailing zeros removed and its sign preserved. That is...
trusted_official_docs
CPython Docs
Used for producing canonical values of an equivalence class within either the current context or the specified context. This has the same semantics as the unary plus operation, except that if the final result is finite it is reduced to its simplest form, with all trailing zeros removed and its sign preserved. That is...
Used for producing canonical values of an equivalence class within either the current context or the specified context. This has the same semantics as the unary plus operation, except that if the final result is finite it is reduced to its simplest form, with all trailing zeros removed and its sign preserved. That is...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9842769d-f2e3-418a-949b-87dce527c2b5
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,310
supabase-export-v2
da47b8c264a573fc
.. import modules for testing inline doctests with the Sphinx doctest builder .. testsetup:: * import decimal import math from decimal import * # make sure each group gets a fresh context setcontext(Context())
trusted_official_docs
CPython Docs
.. import modules for testing inline doctests with the Sphinx doctest builder .. testsetup:: * import decimal import math from decimal import * # make sure each group gets a fresh context setcontext(Context())
.. import modules for testing inline doctests with the Sphinx doctest builder .. testsetup:: * import decimal import math from decimal import * # make sure each group gets a fresh context setcontext(Context())
python, official-docs, cpython, P0
Local_Trusted_Corpus
9a38866e-af92-4fef-bae2-713d89d89ad7
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,838
supabase-export-v2
7246566dab343fa2
# Set applicationwide defaults for all threads about to be launched DefaultContext.prec = 12 DefaultContext.rounding = ROUND_DOWN DefaultContext.traps = ExtendedContext.traps.copy() DefaultContext.traps[InvalidOperation] = 1 setcontext(DefaultContext) # Afterwards, the threads can be started t1.start() t2.start() t3...
trusted_official_docs
CPython Docs
# Set applicationwide defaults for all threads about to be launched DefaultContext.prec = 12 DefaultContext.rounding = ROUND_DOWN DefaultContext.traps = ExtendedContext.traps.copy() DefaultContext.traps[InvalidOperation] = 1 setcontext(DefaultContext) # Afterwards, the threads can be started t1.start() t2.start() t3...
# Set applicationwide defaults for all threads about to be launched DefaultContext.prec = 12 DefaultContext.rounding = ROUND_DOWN DefaultContext.traps = ExtendedContext.traps.copy() DefaultContext.traps[InvalidOperation] = 1 setcontext(DefaultContext) # Afterwards, the threads can be started t1.start() t2.start() t3...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9ac9725f-b8d5-4cf9-9b6f-ce7963ab4881
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,912
supabase-export-v2
7579088008f27e99
= Decimal(0).logical_invert() * 9 >>> sys.getsizeof(x) 524288112 >>> x + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.Inexact: [<class 'decimal.Inexact'>] In general (and especially on systems without overallocation), it is recommended to estimate even tighter bounds and set the :att...
trusted_official_docs
CPython Docs
= Decimal(0).logical_invert() * 9 >>> sys.getsizeof(x) 524288112 >>> x + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.Inexact: [<class 'decimal.Inexact'>] In general (and especially on systems without overallocation), it is recommended to estimate even tighter bounds and set the :att...
= Decimal(0).logical_invert() * 9 >>> sys.getsizeof(x) 524288112 >>> x + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.Inexact: [<class 'decimal.Inexact'>] In general (and especially on systems without overallocation), it is recommended to estimate even tighter bounds and set the :att...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9bee490e-3846-44f1-b3d2-0208f5d8d3fe
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,353
supabase-export-v2
fb468044e87114d6
>>> format(Decimal('2.675'), ".2f") '2.68' >>> f"{Decimal('2.675'):.2f}" '2.68' >>> format(Decimal('2.675'), ".2e") '2.68e+0' >>> with localcontext() as ctx: ... ctx.rounding = ROUND_DOWN ... print(format(Decimal('2.675'), ".2f")) ... 2.67 And some mathematical functions are also available to Decimal:
trusted_official_docs
CPython Docs
>>> format(Decimal('2.675'), ".2f") '2.68' >>> f"{Decimal('2.675'):.2f}" '2.68' >>> format(Decimal('2.675'), ".2e") '2.68e+0' >>> with localcontext() as ctx: ... ctx.rounding = ROUND_DOWN ... print(format(Decimal('2.675'), ".2f")) ... 2.67 And some mathematical functions are also available to Decimal:
>>> format(Decimal('2.675'), ".2f") '2.68' >>> f"{Decimal('2.675'):.2f}" '2.68' >>> format(Decimal('2.675'), ".2e") '2.68e+0' >>> with localcontext() as ctx: ... ctx.rounding = ROUND_DOWN ... print(format(Decimal('2.675'), ".2f")) ... 2.67 And some mathematical functions are also available to Decimal:
python, official-docs, cpython, P0
Local_Trusted_Corpus
9c5b6dd4-7c3b-4feb-987e-1646572f7207
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,492
supabase-export-v2
1f36905cab58eeb9
.. method:: next_plus(context=None) Return the smallest number representable in the given context (or in the current thread's context if no context is given) that is larger than the given operand.
trusted_official_docs
CPython Docs
.. method:: next_plus(context=None) Return the smallest number representable in the given context (or in the current thread's context if no context is given) that is larger than the given operand.
.. method:: next_plus(context=None) Return the smallest number representable in the given context (or in the current thread's context if no context is given) that is larger than the given operand.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9e336ca6-fc6c-48d5-973f-62a7b8aa8e7e
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,828
supabase-export-v2
24cf4ec7c15c1500
used to. For an eye accustomed to normalized floating-point representations, it is not immediately obvious that the following calculation returns a value equal to zero: >>> 1 / Decimal('Infinity') Decimal('0E-1000026')
trusted_official_docs
CPython Docs
used to. For an eye accustomed to normalized floating-point representations, it is not immediately obvious that the following calculation returns a value equal to zero: >>> 1 / Decimal('Infinity') Decimal('0E-1000026')
used to. For an eye accustomed to normalized floating-point representations, it is not immediately obvious that the following calculation returns a value equal to zero: >>> 1 / Decimal('Infinity') Decimal('0E-1000026')
python, official-docs, cpython, P0
Local_Trusted_Corpus
a0c91c52-d8da-48c7-bd6c-1c43b49459a6
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,359
supabase-export-v2
5410eb5c8ce47454
For more advanced work, it may be useful to create alternate contexts using the :meth:`Context` constructor. To make an alternate active, use the :func:`setcontext` function. In accordance with the standard, the :mod:`!decimal` module provides two ready to use standard contexts, :const:`BasicContext` and :const:`Extend...
trusted_official_docs
CPython Docs
For more advanced work, it may be useful to create alternate contexts using the :meth:`Context` constructor. To make an alternate active, use the :func:`setcontext` function. In accordance with the standard, the :mod:`!decimal` module provides two ready to use standard contexts, :const:`BasicContext` and :const:`Extend...
For more advanced work, it may be useful to create alternate contexts using the :meth:`Context` constructor. To make an alternate active, use the :func:`setcontext` function. In accordance with the standard, the :mod:`!decimal` module provides two ready to use standard contexts, :const:`BasicContext` and :const:`Extend...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a31fff4f-f205-4ffb-8eac-9c1034c0e605
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,367
supabase-export-v2
e13e93f759279f8a
to pi was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the :attr:`~Context.traps` attribute of a context:
trusted_official_docs
CPython Docs
to pi was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the :attr:`~Context.traps` attribute of a context:
to pi was rounded (digits beyond the context precision were thrown away) and that the result is inexact (some of the discarded digits were non-zero). Individual traps are set using the dictionary in the :attr:`~Context.traps` attribute of a context:
python, official-docs, cpython, P0
Local_Trusted_Corpus
a48a7edf-033e-43c7-a752-ff22d3481b46
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,560
supabase-export-v2
fd212479151210aa
no context is specified, a copy of the current context is used. The *kwargs* argument is used to set the attributes of the new context. For example, the following code sets the current decimal precision to 42 places, performs a calculation, and then automatically restores the previous context::
trusted_official_docs
CPython Docs
no context is specified, a copy of the current context is used. The *kwargs* argument is used to set the attributes of the new context. For example, the following code sets the current decimal precision to 42 places, performs a calculation, and then automatically restores the previous context::
no context is specified, a copy of the current context is used. The *kwargs* argument is used to set the attributes of the new context. For example, the following code sets the current decimal precision to 42 places, performs a calculation, and then automatically restores the previous context::
python, official-docs, cpython, P0
Local_Trusted_Corpus
a60ed7fc-b7e1-4d5e-8ef1-586a0bc6128a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,717
supabase-export-v2
334b624e3f1f2c93
must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits The value resulting from ``Context.power(x, y, modulo)`` is equal to the value that would be obtained by computing ``(x**y) % modulo`` with unbounded precision, but is computed more e...
trusted_official_docs
CPython Docs
must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits The value resulting from ``Context.power(x, y, modulo)`` is equal to the value that would be obtained by computing ``(x**y) % modulo`` with unbounded precision, but is computed more e...
must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits The value resulting from ``Context.power(x, y, modulo)`` is equal to the value that would be obtained by computing ``(x**y) % modulo`` with unbounded precision, but is computed more e...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a65f43c0-4aeb-4d80-a460-6942ecc9ff26
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,793
supabase-export-v2
bd5fcf9ab936590e
Rounding occurred though possibly no information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits.
trusted_official_docs
CPython Docs
Rounding occurred though possibly no information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits.
Rounding occurred though possibly no information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a953b25d-1d92-431e-ad82-4fee56e517ac
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,833
supabase-export-v2
daf120ae22af573e
a different :class:`Context` object for each thread. Having separate thread contexts means that threads may make changes (such as ``getcontext().prec=10``) without interfering with other threads. Likewise, the :func:`setcontext` function automatically assigns its target to the current thread.
trusted_official_docs
CPython Docs
a different :class:`Context` object for each thread. Having separate thread contexts means that threads may make changes (such as ``getcontext().prec=10``) without interfering with other threads. Likewise, the :func:`setcontext` function automatically assigns its target to the current thread.
a different :class:`Context` object for each thread. Having separate thread contexts means that threads may make changes (such as ``getcontext().prec=10``) without interfering with other threads. Likewise, the :func:`setcontext` function automatically assigns its target to the current thread.
python, official-docs, cpython, P0
Local_Trusted_Corpus
aa37e501-a872-4911-82b8-214d54774bbb
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,781
supabase-export-v2
576d0cfffaa5ca95
Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, returns ``Infinity`` or ``-Infinity`` with the sign determined by the inputs to the calculation.
trusted_official_docs
CPython Docs
Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, returns ``Infinity`` or ``-Infinity`` with the sign determined by the inputs to the calculation.
Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, returns ``Infinity`` or ``-Infinity`` with the sign determined by the inputs to the calculation.
python, official-docs, cpython, P0
Local_Trusted_Corpus
ab13fdc1-36d9-49d1-beec-6e9b9431ace7
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,521
supabase-export-v2
a03f10060c5af315
Test whether self and other have the same exponent or whether both are ``NaN``. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
trusted_official_docs
CPython Docs
Test whether self and other have the same exponent or whether both are ``NaN``. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
Test whether self and other have the same exponent or whether both are ``NaN``. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
python, official-docs, cpython, P0
Local_Trusted_Corpus
abf44b71-94d4-4856-a2c8-57dfc206ee75
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,531
supabase-export-v2
741293adbbb9cef5
can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``.
trusted_official_docs
CPython Docs
can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``.
can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
acf773a4-1da5-438d-acd7-9ff25cd503fb
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,825
supabase-export-v2
67674a4e0a9578e1
rather than remaining quiet after every operation. This is a useful return value when an invalid result needs to interrupt a calculation for special handling. The behavior of Python's comparison operators can be a little surprising where a ``NaN`` is involved. A test for equality where one of the operands is a quiet or...
trusted_official_docs
CPython Docs
rather than remaining quiet after every operation. This is a useful return value when an invalid result needs to interrupt a calculation for special handling. The behavior of Python's comparison operators can be a little surprising where a ``NaN`` is involved. A test for equality where one of the operands is a quiet or...
rather than remaining quiet after every operation. This is a useful return value when an invalid result needs to interrupt a calculation for special handling. The behavior of Python's comparison operators can be a little surprising where a ``NaN`` is involved. A test for equality where one of the operands is a quiet or...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b0abb4af-e6da-4c58-997d-184fd3860395
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,494
supabase-export-v2
f9a4d91106a7d308
.. method:: next_toward(other, context=None) If the two operands are unequal, return the number closest to the first operand in the direction of the second operand. If both operands are numerically equal, return a copy of the first operand with the sign set to be the same as the sign of the second operand.
trusted_official_docs
CPython Docs
.. method:: next_toward(other, context=None) If the two operands are unequal, return the number closest to the first operand in the direction of the second operand. If both operands are numerically equal, return a copy of the first operand with the sign set to be the same as the sign of the second operand.
.. method:: next_toward(other, context=None) If the two operands are unequal, return the number closest to the first operand in the direction of the second operand. If both operands are numerically equal, return a copy of the first operand with the sign set to be the same as the sign of the second operand.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b36e0c8c-15cd-48a9-b9d2-9e0c11c3a426
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,852
supabase-export-v2
ba25ff331c5681fd
s != lasts: lasts = s i += 1 fact *= i num *= x s += num / fact getcontext().prec -= 2 return +s def cos(x): """Return the cosine of x as measured in radians.
trusted_official_docs
CPython Docs
s != lasts: lasts = s i += 1 fact *= i num *= x s += num / fact getcontext().prec -= 2 return +s def cos(x): """Return the cosine of x as measured in radians.
s != lasts: lasts = s i += 1 fact *= i num *= x s += num / fact getcontext().prec -= 2 return +s def cos(x): """Return the cosine of x as measured in radians.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b3bca985-ad7d-4cf3-85c8-435e839b7eee
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,810
supabase-export-v2
52ac33470467a4ca
Mitigating round-off error with increased precision ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The use of decimal floating point eliminates decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fi...
trusted_official_docs
CPython Docs
Mitigating round-off error with increased precision ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The use of decimal floating point eliminates decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fi...
Mitigating round-off error with increased precision ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The use of decimal floating point eliminates decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b3c75b07-a1ae-4c8a-868d-2212e0bdcea6
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,322
supabase-export-v2
7bfc05386ef93582
programmer has full control over rounding and signal handling. This includes an option to enforce exact arithmetic by using exceptions to block any inexact operations. * The decimal module was designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and...
trusted_official_docs
CPython Docs
programmer has full control over rounding and signal handling. This includes an option to enforce exact arithmetic by using exceptions to block any inexact operations. * The decimal module was designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and...
programmer has full control over rounding and signal handling. This includes an option to enforce exact arithmetic by using exceptions to block any inexact operations. * The decimal module was designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ba230409-36de-4e6a-b624-e0f0a234b289
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,818
supabase-export-v2
cbf09dc618140839
.. doctest:: newcontext >>> getcontext().prec = 20 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.51111111') >>> u + (v + w) Decimal('9.51111111') >>> >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.0060000') >...
trusted_official_docs
CPython Docs
.. doctest:: newcontext >>> getcontext().prec = 20 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.51111111') >>> u + (v + w) Decimal('9.51111111') >>> >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.0060000') >...
.. doctest:: newcontext >>> getcontext().prec = 20 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.51111111') >>> u + (v + w) Decimal('9.51111111') >>> >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.0060000') >...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ba4e52de-7bcd-49e2-b29e-0785f17834a4
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,857
supabase-export-v2
ee939732aaafdcb5
def sin(x): """Return the sine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
trusted_official_docs
CPython Docs
def sin(x): """Return the sine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
def sin(x): """Return the sine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
python, official-docs, cpython, P0
Local_Trusted_Corpus
bb9bb7e6-5287-4222-896a-d9d35eef1ca6
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,356
supabase-export-v2
db10807270c177eb
method rounds a number to a fixed exponent. This method is useful for monetary applications that often round results to a fixed number of places: >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
trusted_official_docs
CPython Docs
method rounds a number to a fixed exponent. This method is useful for monetary applications that often round results to a fixed number of places: >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
method rounds a number to a fixed exponent. This method is useful for monetary applications that often round results to a fixed number of places: >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
python, official-docs, cpython, P0
Local_Trusted_Corpus
bbc1cf9c-f4c5-4381-a060-3ab1450da4c8
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,486
supabase-export-v2
bc8a430fda47d956
.. method:: min(other, context=None) Like ``min(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
trusted_official_docs
CPython Docs
.. method:: min(other, context=None) Like ``min(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
.. method:: min(other, context=None) Like ``min(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
python, official-docs, cpython, P0
Local_Trusted_Corpus
bc648c98-9941-44ee-ac5b-4dfcb4c97a16
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,315
supabase-export-v2
f1e349127ac4d7f7
The :mod:`!decimal` module provides support for fast correctly rounded decimal floating-point arithmetic. It offers several advantages over the :class:`float` datatype: * Decimal "is based on a `floating-point model <https://speleotrove.com/decimal/damodel.html#refnumber>`__ which was designed with people in mind, an...
trusted_official_docs
CPython Docs
The :mod:`!decimal` module provides support for fast correctly rounded decimal floating-point arithmetic. It offers several advantages over the :class:`float` datatype: * Decimal "is based on a `floating-point model <https://speleotrove.com/decimal/damodel.html#refnumber>`__ which was designed with people in mind, an...
The :mod:`!decimal` module provides support for fast correctly rounded decimal floating-point arithmetic. It offers several advantages over the :class:`float` datatype: * Decimal "is based on a `floating-point model <https://speleotrove.com/decimal/damodel.html#refnumber>`__ which was designed with people in mind, an...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bce08ced-e54d-4ec3-a772-5ffe5b8d3834
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,370
supabase-export-v2
27eaa2b7351615dd
getcontext().traps[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): File "<pyshell#112>", line 1, in -toplevel- Decimal(1) / Decimal(0) DivisionByZero: x / 0 Most programs adjust the current context only once, at the beginning of the program. And, in many applications, data is converte...
trusted_official_docs
CPython Docs
getcontext().traps[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): File "<pyshell#112>", line 1, in -toplevel- Decimal(1) / Decimal(0) DivisionByZero: x / 0 Most programs adjust the current context only once, at the beginning of the program. And, in many applications, data is converte...
getcontext().traps[DivisionByZero] = 1 >>> Decimal(1) / Decimal(0) Traceback (most recent call last): File "<pyshell#112>", line 1, in -toplevel- Decimal(1) / Decimal(0) DivisionByZero: x / 0 Most programs adjust the current context only once, at the beginning of the program. And, in many applications, data is converte...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bd659315-34a7-4449-8d60-ce44d96559d0
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,569
supabase-export-v2
011d880772678911
.. function:: IEEEContext(bits) Return a context object initialized to the proper values for one of the IEEE interchange formats. The argument must be a multiple of 32 and less than :const:`IEEE_CONTEXT_MAX_BITS`.
trusted_official_docs
CPython Docs
.. function:: IEEEContext(bits) Return a context object initialized to the proper values for one of the IEEE interchange formats. The argument must be a multiple of 32 and less than :const:`IEEE_CONTEXT_MAX_BITS`.
.. function:: IEEEContext(bits) Return a context object initialized to the proper values for one of the IEEE interchange formats. The argument must be a multiple of 32 and less than :const:`IEEE_CONTEXT_MAX_BITS`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
be562a62-6e60-4ba7-a4e7-aaee79f67ee0
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,815
supabase-export-v2
c4c73f9dce31c757
>>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10') >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
trusted_official_docs
CPython Docs
>>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10') >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
>>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10') >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
python, official-docs, cpython, P0
Local_Trusted_Corpus
bebc5b86-2ebb-4f28-9d64-43c39a2f58dc
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,365
supabase-export-v2
e7cded5cf8f45fd8
remain set until explicitly cleared, so it is best to clear the flags before each set of monitored computations by using the :meth:`~Context.clear_flags` method. :: >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, ...
trusted_official_docs
CPython Docs
remain set until explicitly cleared, so it is best to clear the flags before each set of monitored computations by using the :meth:`~Context.clear_flags` method. :: >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, ...
remain set until explicitly cleared, so it is best to clear the flags before each set of monitored computations by using the :meth:`~Context.clear_flags` method. :: >>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bf5e779f-ac55-4bf4-aad2-24a78972572c
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,344
supabase-export-v2
bde52d173be0463a
>>> getcontext().prec = 6 >>> Decimal('3.0') Decimal('3.0') >>> Decimal('3.1415926535') Decimal('3.1415926535') >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85987') >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85988') If the internal limits of...
trusted_official_docs
CPython Docs
>>> getcontext().prec = 6 >>> Decimal('3.0') Decimal('3.0') >>> Decimal('3.1415926535') Decimal('3.1415926535') >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85987') >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85988') If the internal limits of...
>>> getcontext().prec = 6 >>> Decimal('3.0') Decimal('3.0') >>> Decimal('3.1415926535') Decimal('3.1415926535') >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85987') >>> getcontext().rounding = ROUND_UP >>> Decimal('3.1415926535') + Decimal('2.7182818285') Decimal('5.85988') If the internal limits of...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c075bd9b-d783-40b9-8478-128e5fcd2756
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,504
supabase-export-v2
a0eabe8698dfe191
positive infinity. * ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number). * ``"sNaN"``, indicating that the operand is a signaling NaN. .. method:: quantize(exp, rounding=None, context=None)
trusted_official_docs
CPython Docs
positive infinity. * ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number). * ``"sNaN"``, indicating that the operand is a signaling NaN. .. method:: quantize(exp, rounding=None, context=None)
positive infinity. * ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number). * ``"sNaN"``, indicating that the operand is a signaling NaN. .. method:: quantize(exp, rounding=None, context=None)
python, official-docs, cpython, P0
Local_Trusted_Corpus
c300dee9-03d8-40e7-8d70-ed77ed0ce09b
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,366
supabase-export-v2
d4c83427692959a9
>>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[]) The *flags* entry shows that the rational approximation to p...
trusted_official_docs
CPython Docs
>>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[]) The *flags* entry shows that the rational approximation to p...
>>> setcontext(ExtendedContext) >>> getcontext().clear_flags() >>> Decimal(355) / Decimal(113) Decimal('3.14159292') >>> getcontext() Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[]) The *flags* entry shows that the rational approximation to p...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c5fb86be-189a-4114-86d5-dda6797c869c
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,381
supabase-export-v2
e12d2d222c433862
is losslessly converted to its exact decimal equivalent. This conversion can often require 53 or more digits of precision. For example, ``Decimal(float('1.1'))`` converts to ``Decimal('1.100000000000000088817841970012523233890533447265625')``. The *context* precision does not affect how many digits are stored. That is ...
trusted_official_docs
CPython Docs
is losslessly converted to its exact decimal equivalent. This conversion can often require 53 or more digits of precision. For example, ``Decimal(float('1.1'))`` converts to ``Decimal('1.100000000000000088817841970012523233890533447265625')``. The *context* precision does not affect how many digits are stored. That is ...
is losslessly converted to its exact decimal equivalent. This conversion can often require 53 or more digits of precision. For example, ``Decimal(float('1.1'))`` converts to ``Decimal('1.100000000000000088817841970012523233890533447265625')``. The *context* precision does not affect how many digits are stored. That is ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c8bbea33-11a6-4ce1-94d4-0c8914bc4303
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,879
supabase-export-v2
30596b1d315261c4
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single representative: >>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split()) >>> [v.normalize() for v in values] [Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')]
trusted_official_docs
CPython Docs
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single representative: >>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split()) >>> [v.normalize() for v in values] [Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')]
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single representative: >>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split()) >>> [v.normalize() for v in values] [Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')]
python, official-docs, cpython, P0
Local_Trusted_Corpus
ca629cde-5344-476e-b9eb-9badbc2ecfe1
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,842
supabase-export-v2
655a0e6145eb0400
Here are a few recipes that serve as utility functions and that demonstrate ways to work with the :class:`Decimal` class:: def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
trusted_official_docs
CPython Docs
Here are a few recipes that serve as utility functions and that demonstrate ways to work with the :class:`Decimal` class:: def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
Here are a few recipes that serve as utility functions and that demonstrate ways to work with the :class:`Decimal` class:: def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb3ef48f-b5e5-4d29-a8a7-2bcea1a26f50
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,881
supabase-export-v2
3cbe2f56e0f5e8ee
Q: When does rounding occur in a computation? A: It occurs *after* the computation. The philosophy of the decimal specification is that numbers are considered exact and are created independent of the current context. They can even have greater precision than current context. Computations process with those exact inputs...
trusted_official_docs
CPython Docs
Q: When does rounding occur in a computation? A: It occurs *after* the computation. The philosophy of the decimal specification is that numbers are considered exact and are created independent of the current context. They can even have greater precision than current context. Computations process with those exact inputs...
Q: When does rounding occur in a computation? A: It occurs *after* the computation. The philosophy of the decimal specification is that numbers are considered exact and are created independent of the current context. They can even have greater precision than current context. Computations process with those exact inputs...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbfc54e8-e49d-4c27-ab22-436ee40dcc53
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,893
supabase-export-v2
1d44ea98a24838e4
Q: Within a complex calculation, how can I make sure that I haven't gotten a spurious result because of insufficient precision or rounding anomalies. A: The decimal module makes it easy to test results. A best practice is to re-run calculations using greater precision and with various rounding modes. Widely differing r...
trusted_official_docs
CPython Docs
Q: Within a complex calculation, how can I make sure that I haven't gotten a spurious result because of insufficient precision or rounding anomalies. A: The decimal module makes it easy to test results. A best practice is to re-run calculations using greater precision and with various rounding modes. Widely differing r...
Q: Within a complex calculation, how can I make sure that I haven't gotten a spurious result because of insufficient precision or rounding anomalies. A: The decimal module makes it easy to test results. A best practice is to re-run calculations using greater precision and with various rounding modes. Widely differing r...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cfe7f137-2723-4a21-808a-0545588c0742
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,323
supabase-export-v2
95af456ba9d132a7
designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and rounded floating-point arithmetic." -- excerpt from the decimal arithmetic specification. The module design is centered around three concepts: the decimal number, the context for arithmetic, and...
trusted_official_docs
CPython Docs
designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and rounded floating-point arithmetic." -- excerpt from the decimal arithmetic specification. The module design is centered around three concepts: the decimal number, the context for arithmetic, and...
designed to support "without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and rounded floating-point arithmetic." -- excerpt from the decimal arithmetic specification. The module design is centered around three concepts: the decimal number, the context for arithmetic, and...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d1aba77a-dcde-47c4-84b1-6eb7459e7385
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,873
supabase-export-v2
de5e979c95c735ae
fixed point. Others operations, like division and non-integer multiplication, will change the number of decimal places and need to be followed-up with a :meth:`~Decimal.quantize` step: >>> a = Decimal('102.72') # Initial fixed-point values >>> b = Decimal('3.17') >>> a + b # Addition preserves fixed-point Decimal('1...
trusted_official_docs
CPython Docs
fixed point. Others operations, like division and non-integer multiplication, will change the number of decimal places and need to be followed-up with a :meth:`~Decimal.quantize` step: >>> a = Decimal('102.72') # Initial fixed-point values >>> b = Decimal('3.17') >>> a + b # Addition preserves fixed-point Decimal('1...
fixed point. Others operations, like division and non-integer multiplication, will change the number of decimal places and need to be followed-up with a :meth:`~Decimal.quantize` step: >>> a = Decimal('102.72') # Initial fixed-point values >>> b = Decimal('3.17') >>> a + b # Addition preserves fixed-point Decimal('1...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d1b6ba8c-4bdd-4156-92fd-54de99b95b79
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,325
supabase-export-v2
33290b3e07668d0d
coefficient digits do not truncate trailing zeros. Decimals also include special values such as ``Infinity``, ``-Infinity``, and ``NaN``. The standard also differentiates ``-0`` from ``+0``. The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags indicating the resu...
trusted_official_docs
CPython Docs
coefficient digits do not truncate trailing zeros. Decimals also include special values such as ``Infinity``, ``-Infinity``, and ``NaN``. The standard also differentiates ``-0`` from ``+0``. The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags indicating the resu...
coefficient digits do not truncate trailing zeros. Decimals also include special values such as ``Infinity``, ``-Infinity``, and ``NaN``. The standard also differentiates ``-0`` from ``+0``. The context for arithmetic is an environment specifying precision, rounding rules, limits on exponents, flags indicating the resu...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d2857643-9003-4c3b-9f0c-7d6a37e50674
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,387
supabase-export-v2
823ab542c89fac57
.. versionchanged:: 3.6 Underscores are allowed for grouping, as with integral and floating-point literals in code. Decimal floating-point objects share many properties with the other built-in numeric types such as :class:`float` and :class:`int`. All of the usual math operations and special methods apply. Likewise, ...
trusted_official_docs
CPython Docs
.. versionchanged:: 3.6 Underscores are allowed for grouping, as with integral and floating-point literals in code. Decimal floating-point objects share many properties with the other built-in numeric types such as :class:`float` and :class:`int`. All of the usual math operations and special methods apply. Likewise, ...
.. versionchanged:: 3.6 Underscores are allowed for grouping, as with integral and floating-point literals in code. Decimal floating-point objects share many properties with the other built-in numeric types such as :class:`float` and :class:`int`. All of the usual math operations and special methods apply. Likewise, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d468ab87-5a30-4ba2-951c-6b7b3f325e44
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,525
supabase-export-v2
bdb19813977159bc
.. method:: shift(other, context=None) Return the result of shifting the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to shift. If the seco...
trusted_official_docs
CPython Docs
.. method:: shift(other, context=None) Return the result of shifting the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to shift. If the seco...
.. method:: shift(other, context=None) Return the result of shifting the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to shift. If the seco...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d50492e4-3289-4ca0-b3fa-23b71d8ea7f9
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,909
supabase-export-v2
669be0aaafa9392f
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and the available memory will be insufficient:: >>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError
trusted_official_docs
CPython Docs
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and the available memory will be insufficient:: >>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and the available memory will be insufficient:: >>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError
python, official-docs, cpython, P0
Local_Trusted_Corpus
d63615cb-ec61-46af-914e-9075b0256e8b
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,859
supabase-export-v2
bac9b927d6e3036b
>>> print(sin(Decimal('0.5'))) 0.4794255386042030002732879352 >>> print(sin(0.5)) 0.479425538604 >>> print(sin(0.5+0j)) (0.479425538604+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * s...
trusted_official_docs
CPython Docs
>>> print(sin(Decimal('0.5'))) 0.4794255386042030002732879352 >>> print(sin(0.5)) 0.479425538604 >>> print(sin(0.5+0j)) (0.479425538604+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * s...
>>> print(sin(Decimal('0.5'))) 0.4794255386042030002732879352 >>> print(sin(0.5)) 0.479425538604 >>> print(sin(0.5+0j)) (0.479425538604+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d6427b2b-179a-44ca-9004-d84b011d5dd8
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,835
supabase-export-v2
9948c55b0341b992
then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data:`decimal.DefaultContext` object. The :data:`sys.flags.thread_inherit_context` flag affects the context for new threads. If the flag is false, new threads will start w...
trusted_official_docs
CPython Docs
then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data:`decimal.DefaultContext` object. The :data:`sys.flags.thread_inherit_context` flag affects the context for new threads. If the flag is false, new threads will start w...
then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data:`decimal.DefaultContext` object. The :data:`sys.flags.thread_inherit_context` flag affects the context for new threads. If the flag is false, new threads will start w...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d861e598-106a-4419-8632-f276eeabeae7
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,910
supabase-export-v2
24ade55bf88a4fb8
>>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError On systems with overallocation (e.g. Linux), a more sophisticated approach is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a...
trusted_official_docs
CPython Docs
>>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError On systems with overallocation (e.g. Linux), a more sophisticated approach is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a...
>>> Decimal(1) / 3 Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError On systems with overallocation (e.g. Linux), a more sophisticated approach is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d96187b5-ed45-4af1-97d0-a4c4b027f8a4
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,853
supabase-export-v2
42cbe63bbd5881cc
def cos(x): """Return the cosine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
trusted_official_docs
CPython Docs
def cos(x): """Return the cosine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
def cos(x): """Return the cosine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi).
python, official-docs, cpython, P0
Local_Trusted_Corpus
d9de3b8b-8487-4b6a-b3e4-b98035705201
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,321
supabase-export-v2
f5501a29ce68a0f1
>>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.1428571428571428571428571429') * Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type ex...
trusted_official_docs
CPython Docs
>>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.1428571428571428571428571429') * Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type ex...
>>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.1428571428571428571428571429') * Both binary and decimal floating point are implemented in terms of published standards. While the built-in float type ex...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d9e04367-db37-4247-88b3-6874efdf5f28
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,542
supabase-export-v2
27057f5f3d0eecf4
if the length of the coefficient after the quantize operation would be greater than the current context's precision. In other words, for the non-corner cases: * if *ndigits* is positive, return *number* rounded to *ndigits* decimal places; * if *ndigits* is zero, return *number* rounded to the nearest integer; * if ...
trusted_official_docs
CPython Docs
if the length of the coefficient after the quantize operation would be greater than the current context's precision. In other words, for the non-corner cases: * if *ndigits* is positive, return *number* rounded to *ndigits* decimal places; * if *ndigits* is zero, return *number* rounded to the nearest integer; * if ...
if the length of the coefficient after the quantize operation would be greater than the current context's precision. In other words, for the non-corner cases: * if *ndigits* is positive, return *number* rounded to *ndigits* decimal places; * if *ndigits* is zero, return *number* rounded to the nearest integer; * if ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
daf624b7-6411-4664-8b57-fccbbf288523
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,772
supabase-export-v2
8e620c19143bb381
Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. The context flag is set whenever the condition is encountered. After the computation, flags may be checked for informational purposes (for instance, to determine whether a computation was exact...
trusted_official_docs
CPython Docs
Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. The context flag is set whenever the condition is encountered. After the computation, flags may be checked for informational purposes (for instance, to determine whether a computation was exact...
Signals represent conditions that arise during computation. Each corresponds to one context flag and one context trap enabler. The context flag is set whenever the condition is encountered. After the computation, flags may be checked for informational purposes (for instance, to determine whether a computation was exact...
python, official-docs, cpython, P0
Local_Trusted_Corpus
db1d03c1-8f5f-4ef8-abf8-6cc06d1ec4b2
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,518
supabase-export-v2
ea68dec0f32c0242
.. method:: rotate(other, context=None) Return the result of rotating the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to rotate. If the se...
trusted_official_docs
CPython Docs
.. method:: rotate(other, context=None) Return the result of rotating the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to rotate. If the se...
.. method:: rotate(other, context=None) Return the result of rotating the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to rotate. If the se...
python, official-docs, cpython, P0
Local_Trusted_Corpus
db42d105-3ed8-4edf-bdec-11243881551a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,434
supabase-export-v2
ec4f6a7b358d7a83
Alternative constructor that only accepts instances of :class:`float` or :class:`int`. Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. Since 0.1 is not exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That...
trusted_official_docs
CPython Docs
Alternative constructor that only accepts instances of :class:`float` or :class:`int`. Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. Since 0.1 is not exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That...
Alternative constructor that only accepts instances of :class:`float` or :class:`int`. Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. Since 0.1 is not exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dca4824f-a1f0-4a3d-9899-1d9b0a77ecf8
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,788
supabase-export-v2
b18a0e6e725af2b2
Indicates that an operation was requested that does not make sense. If not trapped, returns ``NaN``. Possible causes include:: Infinity - Infinity 0 * Infinity Infinity / Infinity x % 0 Infinity % x sqrt(-x) and x > 0 0 ** 0 x ** (non-integer) x ** Infinity
trusted_official_docs
CPython Docs
Indicates that an operation was requested that does not make sense. If not trapped, returns ``NaN``. Possible causes include:: Infinity - Infinity 0 * Infinity Infinity / Infinity x % 0 Infinity % x sqrt(-x) and x > 0 0 ** 0 x ** (non-integer) x ** Infinity
Indicates that an operation was requested that does not make sense. If not trapped, returns ``NaN``. Possible causes include:: Infinity - Infinity 0 * Infinity Infinity / Infinity x % 0 Infinity % x sqrt(-x) and x > 0 0 ** 0 x ** (non-integer) x ** Infinity
python, official-docs, cpython, P0
Local_Trusted_Corpus
dcb7ddd4-432f-4be0-a24d-7661420aece9
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,898
supabase-export-v2
c0b445f7720f61a9
>>> getcontext().prec = 3 >>> Decimal('3.104') + Decimal('2.104') Decimal('5.21') >>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104') Decimal('5.20') The solution is either to increase precision or to force rounding of inputs using the unary plus operation:
trusted_official_docs
CPython Docs
>>> getcontext().prec = 3 >>> Decimal('3.104') + Decimal('2.104') Decimal('5.21') >>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104') Decimal('5.20') The solution is either to increase precision or to force rounding of inputs using the unary plus operation:
>>> getcontext().prec = 3 >>> Decimal('3.104') + Decimal('2.104') Decimal('5.21') >>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104') Decimal('5.20') The solution is either to increase precision or to force rounding of inputs using the unary plus operation:
python, official-docs, cpython, P0
Local_Trusted_Corpus
dcbe8b4c-ea2d-4b8d-aa9d-784217863ea3
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,610
supabase-export-v2
e888b973a95c28dc
.. method:: create_decimal(num='0', /) Creates a new Decimal instance from *num* but using *self* as context. Unlike the :class:`Decimal` constructor, the context precision, rounding method, flags, and traps are applied to the conversion.
trusted_official_docs
CPython Docs
.. method:: create_decimal(num='0', /) Creates a new Decimal instance from *num* but using *self* as context. Unlike the :class:`Decimal` constructor, the context precision, rounding method, flags, and traps are applied to the conversion.
.. method:: create_decimal(num='0', /) Creates a new Decimal instance from *num* but using *self* as context. Unlike the :class:`Decimal` constructor, the context precision, rounding method, flags, and traps are applied to the conversion.
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd1c2b67-f6fa-444e-9305-2e6920c5eae7
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,716
supabase-export-v2
b4c3de4d3074d666
With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold: - all three arguments must be integral - ``y`` must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits
trusted_official_docs
CPython Docs
With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold: - all three arguments must be integral - ``y`` must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits
With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold: - all three arguments must be integral - ``y`` must be nonnegative - at least one of ``x`` or ``y`` must be nonzero - ``modulo`` must be nonzero and have at most 'precision' digits
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd3c88a5-6397-40df-a756-7cf7950d959f
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,514
supabase-export-v2
1153e7c3c11b6940
.. method:: remainder_near(other, context=None) Return the remainder from dividing *self* by *other*. This differs from ``self % other`` in that the sign of the remainder is chosen so as to minimize its absolute value. More precisely, the return value is ``self - n * other`` where ``n`` is the integer nearest to the...
trusted_official_docs
CPython Docs
.. method:: remainder_near(other, context=None) Return the remainder from dividing *self* by *other*. This differs from ``self % other`` in that the sign of the remainder is chosen so as to minimize its absolute value. More precisely, the return value is ``self - n * other`` where ``n`` is the integer nearest to the...
.. method:: remainder_near(other, context=None) Return the remainder from dividing *self* by *other*. This differs from ``self % other`` in that the sign of the remainder is chosen so as to minimize its absolute value. More precisely, the return value is ``self - n * other`` where ``n`` is the integer nearest to the...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd81bee5-f0e2-424c-a129-d27506d5d9b9
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,577
supabase-export-v2
172906f5fd482150
is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). Because the traps are disabled, this context is useful for applications that prefer to have result value of ``NaN`` or ``Infinity`` instead of raising excep...
trusted_official_docs
CPython Docs
is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). Because the traps are disabled, this context is useful for applications that prefer to have result value of ``NaN`` or ``Infinity`` instead of raising excep...
is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). Because the traps are disabled, this context is useful for applications that prefer to have result value of ``NaN`` or ``Infinity`` instead of raising excep...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ddd5d890-70ac-45f1-9ed2-d565a12fcf80
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,712
supabase-export-v2
5824fd05863f1e4a
Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given. With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must be integral. The result will be inexact unless ``y`` is integral and the result is finite and can be expressed exactly in 'precision' digits. The rounding mode of the cont...
trusted_official_docs
CPython Docs
Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given. With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must be integral. The result will be inexact unless ``y`` is integral and the result is finite and can be expressed exactly in 'precision' digits. The rounding mode of the cont...
Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given. With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must be integral. The result will be inexact unless ``y`` is integral and the result is finite and can be expressed exactly in 'precision' digits. The rounding mode of the cont...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ddddcae5-f65a-47da-b5fd-882303c38719
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,547
supabase-export-v2
9741e29789ab162b
Logical operands ^^^^^^^^^^^^^^^^ The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their arguments to be *logical operands*. A *logical operand* is a :class:`Decimal` instance whose exponent and sign are both zero, and whose ...
trusted_official_docs
CPython Docs
Logical operands ^^^^^^^^^^^^^^^^ The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their arguments to be *logical operands*. A *logical operand* is a :class:`Decimal` instance whose exponent and sign are both zero, and whose ...
Logical operands ^^^^^^^^^^^^^^^^ The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their arguments to be *logical operands*. A *logical operand* is a :class:`Decimal` instance whose exponent and sign are both zero, and whose ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dfee00d7-60fa-4381-8f07-0340eb21a4ba
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,911
supabase-export-v2
50f60ab127e71d21
:attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a maximum of 500MB each:: >>> import sys >>> >>> # Maximum number of digits for a single operand using 500MB in 8-byte words >>> # with 19 digits per word (4-byte and 9 digits for the 32-b...
trusted_official_docs
CPython Docs
:attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a maximum of 500MB each:: >>> import sys >>> >>> # Maximum number of digits for a single operand using 500MB in 8-byte words >>> # with 19 digits per word (4-byte and 9 digits for the 32-b...
:attr:`~Context.prec` to the amount of available RAM. Suppose that you have 8GB of RAM and expect 10 simultaneous operands using a maximum of 500MB each:: >>> import sys >>> >>> # Maximum number of digits for a single operand using 500MB in 8-byte words >>> # with 19 digits per word (4-byte and 9 digits for the 32-b...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e01133fb-5c22-4f2e-a12f-198df9a3e6d0
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,327
supabase-export-v2
a9247e06925dadd9
ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: :const:`Clamped`, :const:`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:`Rounded`, :const:`Subnormal`, :const:`Overflow`, :const:`Underflow` and :const:`FloatOperation`. For each signal there is...
trusted_official_docs
CPython Docs
ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: :const:`Clamped`, :const:`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:`Rounded`, :const:`Subnormal`, :const:`Overflow`, :const:`Underflow` and :const:`FloatOperation`. For each signal there is...
ignored, considered as informational, or treated as exceptions. The signals in the decimal module are: :const:`Clamped`, :const:`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:`Rounded`, :const:`Subnormal`, :const:`Overflow`, :const:`Underflow` and :const:`FloatOperation`. For each signal there is...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e0eb86a7-1660-42d1-8e61-39d6df3e8d21
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,320
supabase-export-v2
576dad01b0ee5d31
floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: >>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.142...
trusted_official_docs
CPython Docs
floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: >>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.142...
floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem: >>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(1) / Decimal(7) Decimal('0.142857') >>> getcontext().prec = 28 >>> Decimal(1) / Decimal(7) Decimal('0.142...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e2035124-34f9-4219-975e-cc44fd420bfb
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,834
supabase-export-v2
dbf499c3245880c2
Likewise, the :func:`setcontext` function automatically assigns its target to the current thread. If :func:`setcontext` has not been called before :func:`getcontext`, then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data...
trusted_official_docs
CPython Docs
Likewise, the :func:`setcontext` function automatically assigns its target to the current thread. If :func:`setcontext` has not been called before :func:`getcontext`, then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data...
Likewise, the :func:`setcontext` function automatically assigns its target to the current thread. If :func:`setcontext` has not been called before :func:`getcontext`, then :func:`getcontext` will automatically create a new context for use in the current thread. New context objects have default values set from the :data...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e444f118-f43e-447f-8cda-c27a55c8837a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,845
supabase-export-v2
d2fd60d1c60f98e7
moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-') '1.234.568-' >>> moneyfmt(d, curr='$', neg='(', trailneg=')') '($1,234,567.89)' >>> moneyfmt(Decimal(123456789), sep=' ') '123 456 789.00' >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>') '<0.02>' """ q = Decimal(10) ** -places # 2 places --> '0.01' sig...
trusted_official_docs
CPython Docs
moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-') '1.234.568-' >>> moneyfmt(d, curr='$', neg='(', trailneg=')') '($1,234,567.89)' >>> moneyfmt(Decimal(123456789), sep=' ') '123 456 789.00' >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>') '<0.02>' """ q = Decimal(10) ** -places # 2 places --> '0.01' sig...
moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-') '1.234.568-' >>> moneyfmt(d, curr='$', neg='(', trailneg=')') '($1,234,567.89)' >>> moneyfmt(Decimal(123456789), sep=' ') '123 456 789.00' >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>') '<0.02>' """ q = Decimal(10) ** -places # 2 places --> '0.01' sig...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e59d1f2f-4c52-4e8a-a0a4-77d1d56f991d
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,583
supabase-export-v2
867226a36baf7710
The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`. In addition to the three supplied contexts, new contexts can be created with the :class:`Context` constructor.
trusted_official_docs
CPython Docs
The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`. In addition to the three supplied contexts, new contexts can be created with the :class:`Context` constructor.
The default values are :attr:`Context.prec`\ =\ ``28``, :attr:`Context.rounding`\ =\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`. In addition to the three supplied contexts, new contexts can be created with the :class:`Context` constructor.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e77f2990-ba5b-49a0-b11f-ca6f48b5e5d3
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,541
supabase-export-v2
563302d227a40013
ignoring the rounding mode of the :class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN. If *ndigits* is an :class:`int`, the context's rounding mode is respected and a :class:`Decimal` representing *number* rounded to the nearest mul...
trusted_official_docs
CPython Docs
ignoring the rounding mode of the :class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN. If *ndigits* is an :class:`int`, the context's rounding mode is respected and a :class:`Decimal` representing *number* rounded to the nearest mul...
ignoring the rounding mode of the :class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN. If *ndigits* is an :class:`int`, the context's rounding mode is respected and a :class:`Decimal` representing *number* rounded to the nearest mul...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e7b4af17-180a-4a4c-8161-4c9cd36c0a0d
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,715
supabase-export-v2
36e199fc1b733eea
The C module computes :meth:`power` in terms of the correctly rounded :meth:`exp` and :meth:`ln` functions. The result is well-defined but only "almost always correctly rounded". With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold:
trusted_official_docs
CPython Docs
The C module computes :meth:`power` in terms of the correctly rounded :meth:`exp` and :meth:`ln` functions. The result is well-defined but only "almost always correctly rounded". With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold:
The C module computes :meth:`power` in terms of the correctly rounded :meth:`exp` and :meth:`ln` functions. The result is well-defined but only "almost always correctly rounded". With three arguments, compute ``(x**y) % modulo``. For the three argument form, the following restrictions on the arguments hold:
python, official-docs, cpython, P0
Local_Trusted_Corpus
e88a4df8-9a56-4abe-8780-d1bf9dc54d3c
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,811
supabase-export-v2
8dc0e840b41f3c83
decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fixed precision. The effects of round-off error can be amplified by the addition or subtraction of nearly offsetting quantities resulting in loss of si...
trusted_official_docs
CPython Docs
decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fixed precision. The effects of round-off error can be amplified by the addition or subtraction of nearly offsetting quantities resulting in loss of si...
decimal representation error (making it possible to represent ``0.1`` exactly); however, some operations can still incur round-off error when non-zero digits exceed the fixed precision. The effects of round-off error can be amplified by the addition or subtraction of nearly offsetting quantities resulting in loss of si...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e9cc37e2-1e79-417b-bf49-8f241b00ad83
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,752
supabase-export-v2
665f6d05b5524618
``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MAX_EMAX | ``425000000`` | ``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MIN_EMIN | ``-425000000`` | ``-99999999...
trusted_official_docs
CPython Docs
``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MAX_EMAX | ``425000000`` | ``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MIN_EMIN | ``-425000000`` | ``-99999999...
``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MAX_EMAX | ``425000000`` | ``999999999999999999`` | +---------------------------------+---------------------+-------------------------------+ | .. data:: MIN_EMIN | ``-425000000`` | ``-99999999...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ea8a39a3-41c2-4288-9574-e435689d34c2
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,415
supabase-export-v2
7366d7756cfc1076
and ``Decimal('1')`` if the first operand is higher in the total order than the second operand. See the specification for details of the total order. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if th...
trusted_official_docs
CPython Docs
and ``Decimal('1')`` if the first operand is higher in the total order than the second operand. See the specification for details of the total order. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if th...
and ``Decimal('1')`` if the first operand is higher in the total order than the second operand. See the specification for details of the total order. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
eb16d877-df58-4972-bd49-c043f71b3eb0
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,600
supabase-export-v2
9be7be78bac12fa4
A *clamp* value of ``1`` allows compatibility with the fixed-width decimal interchange formats specified in IEEE 754. The :class:`Context` class defines several general purpose methods as well as a large number of methods for doing arithmetic directly in a given context. In addition, for each of the :class:`Decimal` m...
trusted_official_docs
CPython Docs
A *clamp* value of ``1`` allows compatibility with the fixed-width decimal interchange formats specified in IEEE 754. The :class:`Context` class defines several general purpose methods as well as a large number of methods for doing arithmetic directly in a given context. In addition, for each of the :class:`Decimal` m...
A *clamp* value of ``1`` allows compatibility with the fixed-width decimal interchange formats specified in IEEE 754. The :class:`Context` class defines several general purpose methods as well as a large number of methods for doing arithmetic directly in a given context. In addition, for each of the :class:`Decimal` m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
edf172ab-ccbc-42d1-80a5-710bdfed706a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,713
supabase-export-v2
71748393a9a4bb29
and can be expressed exactly in 'precision' digits. The rounding mode of the context is used. Results are always correctly rounded in the Python version. ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
trusted_official_docs
CPython Docs
and can be expressed exactly in 'precision' digits. The rounding mode of the context is used. Results are always correctly rounded in the Python version. ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
and can be expressed exactly in 'precision' digits. The rounding mode of the context is used. Results are always correctly rounded in the Python version. ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
eed5535d-adfe-47ca-95b9-ac00852d8e7c
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,337
supabase-export-v2
5a236ed238cf0316
of that integer or float. Decimal numbers include special values such as ``NaN`` which stands for "Not a number", positive and negative ``Infinity``, and ``-0``:: >>> getcontext().prec = 28 >>> Decimal(10) Decimal('10') >>> Decimal('3.14') Decimal('3.14') >>> Decimal(3.14) Decimal('3.14000000000000012434497875801...
trusted_official_docs
CPython Docs
of that integer or float. Decimal numbers include special values such as ``NaN`` which stands for "Not a number", positive and negative ``Infinity``, and ``-0``:: >>> getcontext().prec = 28 >>> Decimal(10) Decimal('10') >>> Decimal('3.14') Decimal('3.14') >>> Decimal(3.14) Decimal('3.14000000000000012434497875801...
of that integer or float. Decimal numbers include special values such as ``NaN`` which stands for "Not a number", positive and negative ``Infinity``, and ``-0``:: >>> getcontext().prec = 28 >>> Decimal(10) Decimal('10') >>> Decimal('3.14') Decimal('3.14') >>> Decimal(3.14) Decimal('3.14000000000000012434497875801...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f01a0858-e614-4424-be52-4400cfafb344
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,855
supabase-export-v2
7b6631e1c9b5912d
>>> print(cos(Decimal('0.5'))) 0.8775825618903727161162815826 >>> print(cos(0.5)) 0.87758256189 >>> print(cos(0.5+0j)) (0.87758256189+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sig...
trusted_official_docs
CPython Docs
>>> print(cos(Decimal('0.5'))) 0.8775825618903727161162815826 >>> print(cos(0.5)) 0.87758256189 >>> print(cos(0.5+0j)) (0.87758256189+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sig...
>>> print(cos(Decimal('0.5'))) 0.8775825618903727161162815826 >>> print(cos(0.5)) 0.87758256189 >>> print(cos(0.5+0j)) (0.87758256189+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sig...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f3e41c13-bb9f-42e2-8cc8-fc042a201b0a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,333
supabase-export-v2
37c6d845e2587ada
Quick-start tutorial -------------------- The usual start to using decimals is importing the module, viewing the current context with :func:`getcontext` and, if necessary, setting new values for precision, rounding, or enabled traps::
trusted_official_docs
CPython Docs
Quick-start tutorial -------------------- The usual start to using decimals is importing the module, viewing the current context with :func:`getcontext` and, if necessary, setting new values for precision, rounding, or enabled traps::
Quick-start tutorial -------------------- The usual start to using decimals is importing the module, viewing the current context with :func:`getcontext` and, if necessary, setting new values for precision, rounding, or enabled traps::
python, official-docs, cpython, P0
Local_Trusted_Corpus
f4199835-f34d-4cb7-8914-c0de58222fc9
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,616
supabase-export-v2
235fa4619f77943b
.. method:: create_decimal_from_float(f, /) Creates a new Decimal instance from a float *f* but rounding using *self* as the context. Unlike the :meth:`Decimal.from_float` class method, the context precision, rounding method, flags, and traps are applied to the conversion.
trusted_official_docs
CPython Docs
.. method:: create_decimal_from_float(f, /) Creates a new Decimal instance from a float *f* but rounding using *self* as the context. Unlike the :meth:`Decimal.from_float` class method, the context precision, rounding method, flags, and traps are applied to the conversion.
.. method:: create_decimal_from_float(f, /) Creates a new Decimal instance from a float *f* but rounding using *self* as the context. Unlike the :meth:`Decimal.from_float` class method, the context precision, rounding method, flags, and traps are applied to the conversion.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f58a5425-cd6b-4011-bf51-0b6209ccbc1e
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,848
supabase-export-v2
2943a3c5eab8e5f4
>>> print(pi()) 3.141592653589793238462643383 """ getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while s != lasts: lasts = s n, na = n+na, na+8 d, da = d+da, da+32 t = (t * n) / d s...
trusted_official_docs
CPython Docs
>>> print(pi()) 3.141592653589793238462643383 """ getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while s != lasts: lasts = s n, na = n+na, na+8 d, da = d+da, da+32 t = (t * n) / d s...
>>> print(pi()) 3.141592653589793238462643383 """ getcontext().prec += 2 # extra digits for intermediate steps three = Decimal(3) # substitute "three=3.0" for regular floats lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24 while s != lasts: lasts = s n, na = n+na, na+8 d, da = d+da, da+32 t = (t * n) / d s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f6854b87-1550-4738-9c63-2d1bee76d64b
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,814
supabase-export-v2
3ddb45900cce2b9b
# Examples from Seminumerical Algorithms, Section 4.2.2. >>> from decimal import Decimal, getcontext >>> getcontext().prec = 8 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10')
trusted_official_docs
CPython Docs
# Examples from Seminumerical Algorithms, Section 4.2.2. >>> from decimal import Decimal, getcontext >>> getcontext().prec = 8 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10')
# Examples from Seminumerical Algorithms, Section 4.2.2. >>> from decimal import Decimal, getcontext >>> getcontext().prec = 8 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') >>> (u + v) + w Decimal('9.5111111') >>> u + (v + w) Decimal('10')
python, official-docs, cpython, P0
Local_Trusted_Corpus
f6d7fe93-ba52-497b-abde-4947f2491b5a
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,905
supabase-export-v2
4fc63c6abef54f3a
precision correctly rounded decimal floating-point arithmetic [#]_. ``libmpdec`` uses `Karatsuba multiplication <https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_ for medium-sized numbers and the `Number Theoretic Transform <https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transfor...
trusted_official_docs
CPython Docs
precision correctly rounded decimal floating-point arithmetic [#]_. ``libmpdec`` uses `Karatsuba multiplication <https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_ for medium-sized numbers and the `Number Theoretic Transform <https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transfor...
precision correctly rounded decimal floating-point arithmetic [#]_. ``libmpdec`` uses `Karatsuba multiplication <https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_ for medium-sized numbers and the `Number Theoretic Transform <https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transfor...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f75711a1-95cc-4ba3-9d9a-87b8b78b4bba
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,507
supabase-export-v2
8042b69c57f0b5f2
>>> Decimal('1.41421356').quantize(Decimal('1.000')) Decimal('1.414') Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision, then an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent...
trusted_official_docs
CPython Docs
>>> Decimal('1.41421356').quantize(Decimal('1.000')) Decimal('1.414') Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision, then an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent...
>>> Decimal('1.41421356').quantize(Decimal('1.000')) Decimal('1.414') Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision, then an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f75e6848-0533-4b82-9e70-312e9b50a546
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,317
supabase-export-v2
2eaa28ae685b2e57
representations in binary floating point. End users typically would not expect ``1.1 + 2.2`` to display as ``3.3000000000000003`` as it does with binary floating point. * The exactness carries over into arithmetic. In decimal floating point, ``0.1 + 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating point,...
trusted_official_docs
CPython Docs
representations in binary floating point. End users typically would not expect ``1.1 + 2.2`` to display as ``3.3000000000000003`` as it does with binary floating point. * The exactness carries over into arithmetic. In decimal floating point, ``0.1 + 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating point,...
representations in binary floating point. End users typically would not expect ``1.1 + 2.2`` to display as ``3.3000000000000003`` as it does with binary floating point. * The exactness carries over into arithmetic. In decimal floating point, ``0.1 + 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating point,...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f8cf91db-cc2f-4321-b9f0-a670b4c9d806
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,576
supabase-export-v2
393be3e808296970
.. data:: ExtendedContext This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations).
trusted_official_docs
CPython Docs
.. data:: ExtendedContext This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations).
.. data:: ExtendedContext This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations).
python, official-docs, cpython, P0
Local_Trusted_Corpus
f964c7e6-bac5-46a2-9ed2-def09cabdeae
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,383
supabase-export-v2
224c6aeeb6ceeefd
is a malformed string. If the context traps :const:`InvalidOperation`, an exception is raised; otherwise, the constructor returns a new Decimal with the value of ``NaN``. Once constructed, :class:`Decimal` objects are immutable.
trusted_official_docs
CPython Docs
is a malformed string. If the context traps :const:`InvalidOperation`, an exception is raised; otherwise, the constructor returns a new Decimal with the value of ``NaN``. Once constructed, :class:`Decimal` objects are immutable.
is a malformed string. If the context traps :const:`InvalidOperation`, an exception is raised; otherwise, the constructor returns a new Decimal with the value of ``NaN``. Once constructed, :class:`Decimal` objects are immutable.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f9fd5934-e571-492b-951b-9fad92dfd279
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,428
supabase-export-v2
89d3f63ba1f8a2f2
>>> Decimal('2.3').copy_sign(Decimal('-1.5')) Decimal('-2.3') This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
trusted_official_docs
CPython Docs
>>> Decimal('2.3').copy_sign(Decimal('-1.5')) Decimal('-2.3') This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
>>> Decimal('2.3').copy_sign(Decimal('-1.5')) Decimal('-2.3') This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exactly.
python, official-docs, cpython, P0
Local_Trusted_Corpus
fb5cad69-8903-4f66-a00b-f1cc73c4cec9
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,913
supabase-export-v2
497806675c34e517
on systems without overallocation), it is recommended to estimate even tighter bounds and set the :attr:`Inexact` trap if all calculations are expected to be exact. .. [#] .. versionadded:: 3.3
trusted_official_docs
CPython Docs
on systems without overallocation), it is recommended to estimate even tighter bounds and set the :attr:`Inexact` trap if all calculations are expected to be exact. .. [#] .. versionadded:: 3.3
on systems without overallocation), it is recommended to estimate even tighter bounds and set the :attr:`Inexact` trap if all calculations are expected to be exact. .. [#] .. versionadded:: 3.3
python, official-docs, cpython, P0
Local_Trusted_Corpus
fb99cb81-7611-4968-93c7-fff20eb28b34
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,508
supabase-export-v2
3a8d5744afc72c0f
an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent is always equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
trusted_official_docs
CPython Docs
an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent is always equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
an :const:`InvalidOperation` is signaled. This guarantees that, unless there is an error condition, the quantized exponent is always equal to that of the right-hand operand. Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
python, official-docs, cpython, P0
Local_Trusted_Corpus
fc049668-0684-45c9-ba9d-7bc50e23d14b
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,394
supabase-export-v2
cf3337a5eb643357
comparison operators to compare a :class:`Decimal` instance ``x`` with another number ``y``. This avoids confusing results when doing equality comparisons between numbers of different types. .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully support...
trusted_official_docs
CPython Docs
comparison operators to compare a :class:`Decimal` instance ``x`` with another number ``y``. This avoids confusing results when doing equality comparisons between numbers of different types. .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully support...
comparison operators to compare a :class:`Decimal` instance ``x`` with another number ``y``. This avoids confusing results when doing equality comparisons between numbers of different types. .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully support...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fc28fbd9-40e0-4948-8643-406570b559e7
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,397
supabase-export-v2
37e93109b218dcd6
.. method:: adjusted() Return the adjusted exponent after shifting out the coefficient's rightmost digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` returns seven. Used for determining the position of the most significant digit with respect to the decimal point.
trusted_official_docs
CPython Docs
.. method:: adjusted() Return the adjusted exponent after shifting out the coefficient's rightmost digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` returns seven. Used for determining the position of the most significant digit with respect to the decimal point.
.. method:: adjusted() Return the adjusted exponent after shifting out the coefficient's rightmost digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` returns seven. Used for determining the position of the most significant digit with respect to the decimal point.
python, official-docs, cpython, P0
Local_Trusted_Corpus
fd834fdc-2c1c-44ec-bf44-9c269109463c
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,345
supabase-export-v2
7c0797c20dddf42a
If the internal limits of the C version are exceeded, constructing a decimal raises :class:`InvalidOperation`:: >>> Decimal("1e9999999999999999999") Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
trusted_official_docs
CPython Docs
If the internal limits of the C version are exceeded, constructing a decimal raises :class:`InvalidOperation`:: >>> Decimal("1e9999999999999999999") Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
If the internal limits of the C version are exceeded, constructing a decimal raises :class:`InvalidOperation`:: >>> Decimal("1e9999999999999999999") Traceback (most recent call last): File "<stdin>", line 1, in <module> decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]
python, official-docs, cpython, P0
Local_Trusted_Corpus
fdb3b93d-8c5a-4867-a6c0-7ae7476aca98
CPython Docs
file://datasets/cpython/Doc/library/decimal.rst
unknown
7faf20f8-9cc8-43f8-9c7b-724dffea11bf
46,482
supabase-export-v2
fd5c92e1582ebf90
.. method:: max(other, context=None) Like ``max(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
trusted_official_docs
CPython Docs
.. method:: max(other, context=None) Like ``max(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
.. method:: max(other, context=None) Like ``max(self, other)`` except that the context rounding rule is applied before returning and that ``NaN`` values are either signaled or ignored (depending on the context and whether they are signaling or quiet).
python, official-docs, cpython, P0
Local_Trusted_Corpus