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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1212f00d-e332-4f19-b1c2-a54780470535 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,363 | supabase-export-v2 | 14bb99086a6f5178 | >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[]) >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) Decimal('0.142857143') >>> Decimal(42) / Decimal(0) Decimal('Infinity')
>>> setcontext(BasicContext)
>>> Decimal(42) / Decimal(0)... | trusted_official_docs | CPython Docs | >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[]) >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) Decimal('0.142857143') >>> Decimal(42) / Decimal(0) Decimal('Infinity')
>>> setcontext(BasicContext)
>>> Decimal(42) / Decimal(0)... | >>> ExtendedContext Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[]) >>> setcontext(ExtendedContext) >>> Decimal(1) / Decimal(7) Decimal('0.142857143') >>> Decimal(42) / Decimal(0) Decimal('Infinity')
>>> setcontext(BasicContext)
>>> Decimal(42) / Decimal(0)... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
14698873-9775-43ad-89e0-b72a0b8cd85f | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,357 | supabase-export-v2 | f5b3b0763ea9aca7 | >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
As shown above, the :func:`getcontext` function accesses the current context and
allows the settings to be changed. This approach meets the needs of most
applic... | trusted_official_docs | CPython Docs | >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
As shown above, the :func:`getcontext` function accesses the current context and
allows the settings to be changed. This approach meets the needs of most
applic... | >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
As shown above, the :func:`getcontext` function accesses the current context and
allows the settings to be changed. This approach meets the needs of most
applic... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
165107cc-b77e-440f-b8d3-6dbdf22867c7 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,611 | supabase-export-v2 | 75e1055776abe988 | 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.
This is useful because constants are often given to a greater precision
than is needed by the application. Another benefit is that rounding
... | trusted_official_docs | CPython Docs | 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.
This is useful because constants are often given to a greater precision
than is needed by the application. Another benefit is that rounding
... | 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.
This is useful because constants are often given to a greater precision
than is needed by the application. Another benefit is that rounding
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16e5a7fb-d4b3-4df7-aef4-72aa6a1a2398 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,472 | supabase-export-v2 | c2add33f0e8cf0dc | .. method:: logb(context=None)
For a nonzero number, return the adjusted exponent of its operand as a
:class:`Decimal` instance. If the operand is a zero then
``Decimal('-Infinity')`` is returned and the :const:`DivisionByZero` flag
is raised. If the operand is an infinity then ``Decimal('Infinity')`` is
returned. | trusted_official_docs | CPython Docs | .. method:: logb(context=None)
For a nonzero number, return the adjusted exponent of its operand as a
:class:`Decimal` instance. If the operand is a zero then
``Decimal('-Infinity')`` is returned and the :const:`DivisionByZero` flag
is raised. If the operand is an infinity then ``Decimal('Infinity')`` is
returned. | .. method:: logb(context=None)
For a nonzero number, return the adjusted exponent of its operand as a
:class:`Decimal` instance. If the operand is a zero then
``Decimal('-Infinity')`` is returned and the :const:`DivisionByZero` flag
is raised. If the operand is an infinity then ``Decimal('Infinity')`` is
returned. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
17567bd9-a9f0-45cf-9b07-787e5cc7fff3 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,530 | supabase-export-v2 | 995713e82a1a364f | Convert to a string, using engineering notation if an exponent is needed.
Engineering notation has an exponent which is a multiple of 3. This
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. | trusted_official_docs | CPython Docs | Convert to a string, using engineering notation if an exponent is needed.
Engineering notation has an exponent which is a multiple of 3. This
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. | Convert to a string, using engineering notation if an exponent is needed.
Engineering notation has an exponent which is a multiple of 3. This
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. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1859f4bf-7647-4e5d-be8e-1d40b700bada | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,908 | supabase-export-v2 | 82fa889f294baed2 | >>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN)) >>> x = Decimal(2) ** 256 >>> x / 128 Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and
the available memory will be insufficient:: | trusted_official_docs | CPython Docs | >>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN)) >>> x = Decimal(2) ** 256 >>> x / 128 Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and
the available memory will be insufficient:: | >>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN)) >>> x = Decimal(2) ** 256 >>> x / 128 Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')
For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms and
the available memory will be insufficient:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
18eb80e3-b4cb-433f-b9c6-e2da54019371 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,490 | supabase-export-v2 | ea7c589052cbff0a | .. method:: next_minus(context=None)
Return the largest number representable in the given context (or in the
current thread's context if no context is given) that is smaller than the
given operand. | trusted_official_docs | CPython Docs | .. method:: next_minus(context=None)
Return the largest number representable in the given context (or in the
current thread's context if no context is given) that is smaller than the
given operand. | .. method:: next_minus(context=None)
Return the largest number representable in the given context (or in the
current thread's context if no context is given) that is smaller than the
given operand. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1931b8c4-9e89-4d7e-b65d-ae532008b29a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,360 | supabase-export-v2 | 27c7e85d8dd408cb | module provides two ready to use standard contexts, :const:`BasicContext` and :const:`ExtendedContext`. The former is especially useful for debugging because many of the traps are enabled:
.. doctest:: newcontext
:options: +NORMALIZE_WHITESPACE | trusted_official_docs | CPython Docs | module provides two ready to use standard contexts, :const:`BasicContext` and :const:`ExtendedContext`. The former is especially useful for debugging because many of the traps are enabled:
.. doctest:: newcontext
:options: +NORMALIZE_WHITESPACE | module provides two ready to use standard contexts, :const:`BasicContext` and :const:`ExtendedContext`. The former is especially useful for debugging because many of the traps are enabled:
.. doctest:: newcontext
:options: +NORMALIZE_WHITESPACE | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1aa7c4fa-6924-47a4-9ff5-64ca61e8c0e3 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,867 | supabase-export-v2 | f2445c2b1e00dca7 | A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If the :const:`Inexact` trap is set, it is also useful for validation:
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') | trusted_official_docs | CPython Docs | A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If the :const:`Inexact` trap is set, it is also useful for validation:
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') | A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If the :const:`Inexact` trap is set, it is also useful for validation:
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1b532356-af3f-4dca-9d2a-317a929c1c7c | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,884 | supabase-export-v2 | e032d30e21258338 | Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
A: For some values, exponential notation is the only way to express the number
of significant places in the coefficient. For example, expressing
``5.0E+3`` as ``5000`` keeps the value constant but cann... | trusted_official_docs | CPython Docs | Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
A: For some values, exponential notation is the only way to express the number
of significant places in the coefficient. For example, expressing
``5.0E+3`` as ``5000`` keeps the value constant but cann... | Q: Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?
A: For some values, exponential notation is the only way to express the number
of significant places in the coefficient. For example, expressing
``5.0E+3`` as ``5000`` keeps the value constant but cann... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1d2505eb-bdae-4c42-b318-447b9f51ea49 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,408 | supabase-export-v2 | 625f9b015a47d515 | Compare the values of two Decimal instances. :meth:`compare` returns a Decimal instance, and if either operand is a NaN then the result is a NaN::
a or b is a NaN ==> Decimal('NaN')
a < b ==> Decimal('-1')
a == b ==> Decimal('0')
a > b ==> Decimal('1') | trusted_official_docs | CPython Docs | Compare the values of two Decimal instances. :meth:`compare` returns a Decimal instance, and if either operand is a NaN then the result is a NaN::
a or b is a NaN ==> Decimal('NaN')
a < b ==> Decimal('-1')
a == b ==> Decimal('0')
a > b ==> Decimal('1') | Compare the values of two Decimal instances. :meth:`compare` returns a Decimal instance, and if either operand is a NaN then the result is a NaN::
a or b is a NaN ==> Decimal('NaN')
a < b ==> Decimal('-1')
a == b ==> Decimal('0')
a > b ==> Decimal('1') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1d846ca8-db7c-493b-a612-45de05b50196 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,756 | supabase-export-v2 | d14b89acc37f39a3 | .. data:: HAVE_CONTEXTVAR
The default value is ``True``. If Python is :option:`configured using
the --without-decimal-contextvar option <--without-decimal-contextvar>`,
the C version uses a thread-local rather than a coroutine-local context and the value
is ``False``. This is slightly faster in some nested context s... | trusted_official_docs | CPython Docs | .. data:: HAVE_CONTEXTVAR
The default value is ``True``. If Python is :option:`configured using
the --without-decimal-contextvar option <--without-decimal-contextvar>`,
the C version uses a thread-local rather than a coroutine-local context and the value
is ``False``. This is slightly faster in some nested context s... | .. data:: HAVE_CONTEXTVAR
The default value is ``True``. If Python is :option:`configured using
the --without-decimal-contextvar option <--without-decimal-contextvar>`,
the C version uses a thread-local rather than a coroutine-local context and the value
is ``False``. This is slightly faster in some nested context s... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1da3d56e-6a08-4667-8c6b-077b49b41edf | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,515 | supabase-export-v2 | e1ca0e89bede5394 | is the integer nearest to the exact value of ``self / other``, and if two integers are equally near then the even one is chosen.
If the result is zero then its sign will be the sign of *self*. | trusted_official_docs | CPython Docs | is the integer nearest to the exact value of ``self / other``, and if two integers are equally near then the even one is chosen.
If the result is zero then its sign will be the sign of *self*. | is the integer nearest to the exact value of ``self / other``, and if two integers are equally near then the even one is chosen.
If the result is zero then its sign will be the sign of *self*. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1e6c66f0-aaa3-4db3-b8c2-432c5f136f83 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,784 | supabase-export-v2 | 3d1f70083a56fa8c | Indicates that rounding occurred and the result is not exact.
Signals when non-zero digits were discarded during rounding. The rounded result
is returned. The signal flag or trap is used to detect when results are
inexact. | trusted_official_docs | CPython Docs | Indicates that rounding occurred and the result is not exact.
Signals when non-zero digits were discarded during rounding. The rounded result
is returned. The signal flag or trap is used to detect when results are
inexact. | Indicates that rounding occurred and the result is not exact.
Signals when non-zero digits were discarded during rounding. The rounded result
is returned. The signal flag or trap is used to detect when results are
inexact. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1f5dc06e-9769-48fd-af0d-9422385ac4e1 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,579 | supabase-export-v2 | 772fa6d9f5e02538 | .. data:: DefaultContext
This context is used by the :class:`Context` constructor as a prototype for new
contexts. Changing a field (such a precision) has the effect of changing the
default for new contexts created by the :class:`Context` constructor. | trusted_official_docs | CPython Docs | .. data:: DefaultContext
This context is used by the :class:`Context` constructor as a prototype for new
contexts. Changing a field (such a precision) has the effect of changing the
default for new contexts created by the :class:`Context` constructor. | .. data:: DefaultContext
This context is used by the :class:`Context` constructor as a prototype for new
contexts. Changing a field (such a precision) has the effect of changing the
default for new contexts created by the :class:`Context` constructor. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1f786a97-6049-4842-bd0c-668d1f84e506 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,339 | supabase-export-v2 | cd32d79c42dadc72 | If the :exc:`FloatOperation` signal is trapped, accidental mixing of decimals and floats in constructors or ordering comparisons raises an exception::
>>> c = getcontext()
>>> c.traps[FloatOperation] = True
>>> Decimal(3.14)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
decimal.FloatOperat... | trusted_official_docs | CPython Docs | If the :exc:`FloatOperation` signal is trapped, accidental mixing of decimals and floats in constructors or ordering comparisons raises an exception::
>>> c = getcontext()
>>> c.traps[FloatOperation] = True
>>> Decimal(3.14)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
decimal.FloatOperat... | If the :exc:`FloatOperation` signal is trapped, accidental mixing of decimals and floats in constructors or ordering comparisons raises an exception::
>>> c = getcontext()
>>> c.traps[FloatOperation] = True
>>> Decimal(3.14)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
decimal.FloatOperat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1fee2123-4507-4a57-8984-cf0e43876e16 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,410 | supabase-export-v2 | 9ce047e75ff167c6 | .. method:: compare_signal(other, context=None)
This operation is identical to the :meth:`compare` method, except that all
NaNs signal. That is, if neither operand is a signaling NaN then any
quiet NaN operand is treated as though it were a signaling NaN. | trusted_official_docs | CPython Docs | .. method:: compare_signal(other, context=None)
This operation is identical to the :meth:`compare` method, except that all
NaNs signal. That is, if neither operand is a signaling NaN then any
quiet NaN operand is treated as though it were a signaling NaN. | .. method:: compare_signal(other, context=None)
This operation is identical to the :meth:`compare` method, except that all
NaNs signal. That is, if neither operand is a signaling NaN then any
quiet NaN operand is treated as though it were a signaling NaN. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
233803a6-b8c7-4620-89d6-bb9b8bd90e36 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,355 | supabase-export-v2 | 52a030fb82edfc52 | >>> getcontext().prec = 28 >>> Decimal(2).sqrt() Decimal('1.414213562373095048801688724') >>> Decimal(1).exp() Decimal('2.718281828459045235360287471') >>> Decimal('10').ln() Decimal('2.302585092994045684017991455') >>> Decimal('10').log10() Decimal('1')
The :meth:`~Decimal.quantize` method rounds a number to a fixed e... | trusted_official_docs | CPython Docs | >>> getcontext().prec = 28 >>> Decimal(2).sqrt() Decimal('1.414213562373095048801688724') >>> Decimal(1).exp() Decimal('2.718281828459045235360287471') >>> Decimal('10').ln() Decimal('2.302585092994045684017991455') >>> Decimal('10').log10() Decimal('1')
The :meth:`~Decimal.quantize` method rounds a number to a fixed e... | >>> getcontext().prec = 28 >>> Decimal(2).sqrt() Decimal('1.414213562373095048801688724') >>> Decimal(1).exp() Decimal('2.718281828459045235360287471') >>> Decimal('10').ln() Decimal('2.302585092994045684017991455') >>> Decimal('10').log10() Decimal('1')
The :meth:`~Decimal.quantize` method rounds a number to a fixed e... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
246b001f-711d-4d34-89bc-2b11cdfd0ed5 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,821 | supabase-export-v2 | 1d1b5cbc99f8e522 | The number system for the :mod:`!decimal` module provides special values including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, ``+0`` and ``-0``.
Infinities can be constructed directly with: ``Decimal('Infinity')``. Also,
they can arise from dividing by zero when the :exc:`DivisionByZero` signal is
n... | trusted_official_docs | CPython Docs | The number system for the :mod:`!decimal` module provides special values including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, ``+0`` and ``-0``.
Infinities can be constructed directly with: ``Decimal('Infinity')``. Also,
they can arise from dividing by zero when the :exc:`DivisionByZero` signal is
n... | The number system for the :mod:`!decimal` module provides special values including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, ``+0`` and ``-0``.
Infinities can be constructed directly with: ``Decimal('Infinity')``. Also,
they can arise from dividing by zero when the :exc:`DivisionByZero` signal is
n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2499cc8c-110a-404e-8a0c-a7e908fa3ece | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,562 | supabase-export-v2 | 0f8b70ae484779a1 | from decimal import localcontext
with localcontext() as ctx:
ctx.prec = 42 # Perform a high precision calculation
s = calculate_something()
s = +s # Round the final result back to the default precision | trusted_official_docs | CPython Docs | from decimal import localcontext
with localcontext() as ctx:
ctx.prec = 42 # Perform a high precision calculation
s = calculate_something()
s = +s # Round the final result back to the default precision | from decimal import localcontext
with localcontext() as ctx:
ctx.prec = 42 # Perform a high precision calculation
s = calculate_something()
s = +s # Round the final result back to the default precision | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
253f538f-baa0-4e01-b2bd-da3e48d732a0 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,824 | supabase-export-v2 | 9b9281deb7985941 | be useful for a series of computations that occasionally have missing inputs --- it allows the calculation to proceed while flagging specific results as invalid.
A variant is ``sNaN`` which signals rather than remaining quiet after every
operation. This is a useful return value when an invalid result needs to
interrupt... | trusted_official_docs | CPython Docs | be useful for a series of computations that occasionally have missing inputs --- it allows the calculation to proceed while flagging specific results as invalid.
A variant is ``sNaN`` which signals rather than remaining quiet after every
operation. This is a useful return value when an invalid result needs to
interrupt... | be useful for a series of computations that occasionally have missing inputs --- it allows the calculation to proceed while flagging specific results as invalid.
A variant is ``sNaN`` which signals rather than remaining quiet after every
operation. This is a useful return value when an invalid result needs to
interrupt... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
268f5a62-e465-4988-9e94-dcab7819eb75 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,837 | supabase-export-v2 | d78c51f27d39624b | *DefaultContext* object. This should be done *before* any threads are started so that there won't be a race condition between threads calling :func:`getcontext`. For example::
# Set applicationwide defaults for all threads about to be launched
DefaultContext.prec = 12
DefaultContext.rounding = ROUND_DOWN
DefaultCont... | trusted_official_docs | CPython Docs | *DefaultContext* object. This should be done *before* any threads are started so that there won't be a race condition between threads calling :func:`getcontext`. For example::
# Set applicationwide defaults for all threads about to be launched
DefaultContext.prec = 12
DefaultContext.rounding = ROUND_DOWN
DefaultCont... | *DefaultContext* object. This should be done *before* any threads are started so that there won't be a race condition between threads calling :func:`getcontext`. For example::
# Set applicationwide defaults for all threads about to be launched
DefaultContext.prec = 12
DefaultContext.rounding = ROUND_DOWN
DefaultCont... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
27884ff4-bdfe-44eb-b5e9-dc8556e9e71b | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,726 | supabase-export-v2 | 2fed2756a0accf4f | .. method:: remainder_near(x, y, /)
Returns ``x - y * n``, where *n* is the integer nearest the exact value
of ``x / y`` (if the result is 0 then its sign will be the sign of *x*). | trusted_official_docs | CPython Docs | .. method:: remainder_near(x, y, /)
Returns ``x - y * n``, where *n* is the integer nearest the exact value
of ``x / y`` (if the result is 0 then its sign will be the sign of *x*). | .. method:: remainder_near(x, y, /)
Returns ``x - y * n``, where *n* is the integer nearest the exact value
of ``x / y`` (if the result is 0 then its sign will be the sign of *x*). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2790d560-3f77-4a5e-9d80-81ff0001b23b | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,540 | supabase-export-v2 | c8c0dcd086a9dcb1 | .. describe:: round(number) .. describe:: round(number, ndigits)
If *ndigits* is not given or ``None``,
returns the nearest :class:`int` to *number*,
rounding ties to even, and ignoring the rounding mode of the
:class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an
infinity or :exc:`ValueError` if ... | trusted_official_docs | CPython Docs | .. describe:: round(number) .. describe:: round(number, ndigits)
If *ndigits* is not given or ``None``,
returns the nearest :class:`int` to *number*,
rounding ties to even, and ignoring the rounding mode of the
:class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an
infinity or :exc:`ValueError` if ... | .. describe:: round(number) .. describe:: round(number, ndigits)
If *ndigits* is not given or ``None``,
returns the nearest :class:`int` to *number*,
rounding ties to even, and ignoring the rounding mode of the
:class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an
infinity or :exc:`ValueError` if ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
27b766bb-5a0b-4eca-85f4-299a7e2a71d1 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,773 | supabase-export-v2 | 3f8db9e8e3aa93bc | purposes (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation.
If the context's trap enabler is set for the signal, then the condition causes a
Python exception to be raised. For example, if the :class:`DivisionByZero` tr... | trusted_official_docs | CPython Docs | purposes (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation.
If the context's trap enabler is set for the signal, then the condition causes a
Python exception to be raised. For example, if the :class:`DivisionByZero` tr... | purposes (for instance, to determine whether a computation was exact). After checking the flags, be sure to clear all flags before starting the next computation.
If the context's trap enabler is set for the signal, then the condition causes a
Python exception to be raised. For example, if the :class:`DivisionByZero` tr... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
288cafa7-45c4-498d-a7b7-72da1a99eddc | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,718 | supabase-export-v2 | 01c4197fc6c33bb8 | is computed more efficiently. The exponent of the result is zero, regardless of the exponents of ``x``, ``y`` and ``modulo``. The result is always exact.
.. method:: quantize(x, y, /) | trusted_official_docs | CPython Docs | is computed more efficiently. The exponent of the result is zero, regardless of the exponents of ``x``, ``y`` and ``modulo``. The result is always exact.
.. method:: quantize(x, y, /) | is computed more efficiently. The exponent of the result is zero, regardless of the exponents of ``x``, ``y`` and ``modulo``. The result is always exact.
.. method:: quantize(x, y, /) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2943bbba-155a-47a3-84fb-5b07269e3d0a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,350 | supabase-export-v2 | 0ffb96ec5178d263 | >>> float(a) 1.34 >>> round(a, 1) Decimal('1.3') >>> int(a) 1 >>> a * 5 Decimal('6.70') >>> a * b Decimal('2.5058') >>> c % a Decimal('0.77')
Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) in
fixed-point or scientific notation, using the same formatting syntax (see
:ref:`formatspec`) as bu... | trusted_official_docs | CPython Docs | >>> float(a) 1.34 >>> round(a, 1) Decimal('1.3') >>> int(a) 1 >>> a * 5 Decimal('6.70') >>> a * b Decimal('2.5058') >>> c % a Decimal('0.77')
Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) in
fixed-point or scientific notation, using the same formatting syntax (see
:ref:`formatspec`) as bu... | >>> float(a) 1.34 >>> round(a, 1) Decimal('1.3') >>> int(a) 1 >>> a * 5 Decimal('6.70') >>> a * b Decimal('2.5058') >>> c % a Decimal('0.77')
Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) in
fixed-point or scientific notation, using the same formatting syntax (see
:ref:`formatspec`) as bu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2a1cc0d5-66db-4422-befb-2bf31ba18ae8 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,563 | supabase-export-v2 | e020ff364cf2af8d | ctx.prec = 42 # Perform a high precision calculation s = calculate_something() s = +s # Round the final result back to the default precision
Using keyword arguments, the code would be the following:: | trusted_official_docs | CPython Docs | ctx.prec = 42 # Perform a high precision calculation s = calculate_something() s = +s # Round the final result back to the default precision
Using keyword arguments, the code would be the following:: | ctx.prec = 42 # Perform a high precision calculation s = calculate_something() s = +s # Round the final result back to the default precision
Using keyword arguments, the code would be the following:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2d34d21e-6b22-422a-906a-0c276d3bce1a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,417 | supabase-export-v2 | 5b7a77b90031263f | .. method:: compare_total_mag(other, context=None)
Compare two operands using their abstract representation rather than their
value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to
``x.copy_abs().compare_total(y.copy_abs())``. | trusted_official_docs | CPython Docs | .. method:: compare_total_mag(other, context=None)
Compare two operands using their abstract representation rather than their
value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to
``x.copy_abs().compare_total(y.copy_abs())``. | .. method:: compare_total_mag(other, context=None)
Compare two operands using their abstract representation rather than their
value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to
``x.copy_abs().compare_total(y.copy_abs())``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2f35756d-22bf-4401-9727-4a99d7468798 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,503 | supabase-export-v2 | f1f5084ff3752e67 | Return a string describing the *class* of the operand. The returned value is one of the following ten strings.
* ``"-Infinity"``, indicating that the operand is negative infinity. * ``"-Normal"``, indicating that the operand is a negative normal number. * ``"-Subnormal"``, indicating that the operand is negative and su... | trusted_official_docs | CPython Docs | Return a string describing the *class* of the operand. The returned value is one of the following ten strings.
* ``"-Infinity"``, indicating that the operand is negative infinity. * ``"-Normal"``, indicating that the operand is a negative normal number. * ``"-Subnormal"``, indicating that the operand is negative and su... | Return a string describing the *class* of the operand. The returned value is one of the following ten strings.
* ``"-Infinity"``, indicating that the operand is negative infinity. * ``"-Normal"``, indicating that the operand is a negative normal number. * ``"-Subnormal"``, indicating that the operand is negative and su... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
300e0c31-7e38-481f-a030-6d38ea123e6d | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,856 | supabase-export-v2 | b002c8ebd3b67328 | fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sign getcontext().prec -= 2 return +s
def sin(x):
"""Return the sine of x as measured in radians. | trusted_official_docs | CPython Docs | fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sign getcontext().prec -= 2 return +s
def sin(x):
"""Return the sine of x as measured in radians. | fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sign getcontext().prec -= 2 return +s
def sin(x):
"""Return the sine of x as measured in radians. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3059f472-c0bc-44b0-a97e-021ec011f9f4 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,581 | supabase-export-v2 | 01e536bb6e887739 | effect of setting system-wide defaults. Changing the fields after threads have started is not recommended as it would require thread synchronization to prevent race conditions.
In single threaded environments, it is preferable to not use this context at
all. Instead, simply create contexts explicitly as described belo... | trusted_official_docs | CPython Docs | effect of setting system-wide defaults. Changing the fields after threads have started is not recommended as it would require thread synchronization to prevent race conditions.
In single threaded environments, it is preferable to not use this context at
all. Instead, simply create contexts explicitly as described belo... | effect of setting system-wide defaults. Changing the fields after threads have started is not recommended as it would require thread synchronization to prevent race conditions.
In single threaded environments, it is preferable to not use this context at
all. Instead, simply create contexts explicitly as described belo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
31c8ad39-ac25-499e-af4a-0a8a9a747803 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,377 | supabase-export-v2 | 15936d21ef06d786 | is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters, as well as underscores throughout, are removed::
sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
indicator ::= 'e' | 'E'
digits ::= digit [digit]... decimal-par... | trusted_official_docs | CPython Docs | is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters, as well as underscores throughout, are removed::
sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
indicator ::= 'e' | 'E'
digits ::= digit [digit]... decimal-par... | is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters, as well as underscores throughout, are removed::
sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
indicator ::= 'e' | 'E'
digits ::= digit [digit]... decimal-par... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
331d829e-2484-4263-ac0c-526b362c9cf4 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,326 | supabase-export-v2 | fc3fd5bd4310c6b5 | of operations, and trap enablers which determine whether signals are treated as exceptions. Rounding options include :const:`ROUND_CEILING`, :const:`ROUND_DOWN`, :const:`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:`ROUND_HALF_UP`, :const:`ROUND_UP`, and :const:`ROUND_05UP`.
Signals are grou... | trusted_official_docs | CPython Docs | of operations, and trap enablers which determine whether signals are treated as exceptions. Rounding options include :const:`ROUND_CEILING`, :const:`ROUND_DOWN`, :const:`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:`ROUND_HALF_UP`, :const:`ROUND_UP`, and :const:`ROUND_05UP`.
Signals are grou... | of operations, and trap enablers which determine whether signals are treated as exceptions. Rounding options include :const:`ROUND_CEILING`, :const:`ROUND_DOWN`, :const:`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:`ROUND_HALF_UP`, :const:`ROUND_UP`, and :const:`ROUND_05UP`.
Signals are grou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
33a963ff-2086-4453-a108-4ec1bbb83b04 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,388 | supabase-export-v2 | b190f61f1c57be68 | can be copied, pickled, printed, used as dictionary keys, used as set elements, compared, sorted, and coerced to another type (such as :class:`float` or :class:`int`).
There are some small differences between arithmetic on Decimal objects and
arithmetic on integers and floats. When the remainder operator ``%`` is
app... | trusted_official_docs | CPython Docs | can be copied, pickled, printed, used as dictionary keys, used as set elements, compared, sorted, and coerced to another type (such as :class:`float` or :class:`int`).
There are some small differences between arithmetic on Decimal objects and
arithmetic on integers and floats. When the remainder operator ``%`` is
app... | can be copied, pickled, printed, used as dictionary keys, used as set elements, compared, sorted, and coerced to another type (such as :class:`float` or :class:`int`).
There are some small differences between arithmetic on Decimal objects and
arithmetic on integers and floats. When the remainder operator ``%`` is
app... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
374a2028-1043-4488-83fb-80721fa8898a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,614 | supabase-export-v2 | fcb0fa2d283de5dc | >>> getcontext().prec = 3 >>> Decimal('3.4445') + Decimal('1.0023') Decimal('4.45') >>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023') Decimal('4.44')
This method implements the to-number operation of the IBM specification. If the argument is a string, no leading or trailing whitespace or
underscores are permitted... | trusted_official_docs | CPython Docs | >>> getcontext().prec = 3 >>> Decimal('3.4445') + Decimal('1.0023') Decimal('4.45') >>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023') Decimal('4.44')
This method implements the to-number operation of the IBM specification. If the argument is a string, no leading or trailing whitespace or
underscores are permitted... | >>> getcontext().prec = 3 >>> Decimal('3.4445') + Decimal('1.0023') Decimal('4.45') >>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023') Decimal('4.44')
This method implements the to-number operation of the IBM specification. If the argument is a string, no leading or trailing whitespace or
underscores are permitted... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
37b0d52e-698f-476b-a6d0-7f4761b65f3b | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,435 | supabase-export-v2 | 810816f64a315259 | exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That equivalent value in decimal is ``0.1000000000000000055511151231257827021181583404541015625``.
.. note:: From Python 3.2 onwards, a :class:`Decimal` instance
can also be constru... | trusted_official_docs | CPython Docs | exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That equivalent value in decimal is ``0.1000000000000000055511151231257827021181583404541015625``.
.. note:: From Python 3.2 onwards, a :class:`Decimal` instance
can also be constru... | exactly representable in binary floating point, the value is stored as the nearest representable value which is ``0x1.999999999999ap-4``. That equivalent value in decimal is ``0.1000000000000000055511151231257827021181583404541015625``.
.. note:: From Python 3.2 onwards, a :class:`Decimal` instance
can also be constru... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3960bd49-6340-4db9-9c37-a27a83838353 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,875 | supabase-export-v2 | 9245823a9c27d703 | In developing fixed-point applications, it is convenient to define functions to handle the :meth:`~Decimal.quantize` step:
>>> def mul(x, y, fp=TWOPLACES):
... return (x * y).quantize(fp)
... >>> def div(x, y, fp=TWOPLACES):
... return (x / y).quantize(fp) | trusted_official_docs | CPython Docs | In developing fixed-point applications, it is convenient to define functions to handle the :meth:`~Decimal.quantize` step:
>>> def mul(x, y, fp=TWOPLACES):
... return (x * y).quantize(fp)
... >>> def div(x, y, fp=TWOPLACES):
... return (x / y).quantize(fp) | In developing fixed-point applications, it is convenient to define functions to handle the :meth:`~Decimal.quantize` step:
>>> def mul(x, y, fp=TWOPLACES):
... return (x * y).quantize(fp)
... >>> def div(x, y, fp=TWOPLACES):
... return (x / y).quantize(fp) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3987347f-4351-431d-b17f-d5954b1ef17f | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,389 | supabase-export-v2 | 9cca5a436a8ede57 | operator ``%`` is applied to Decimal objects, the sign of the result is the sign of the *dividend* rather than the sign of the divisor::
>>> (-7) % 4
1
>>> Decimal(-7) % Decimal(4)
Decimal('-3') | trusted_official_docs | CPython Docs | operator ``%`` is applied to Decimal objects, the sign of the result is the sign of the *dividend* rather than the sign of the divisor::
>>> (-7) % 4
1
>>> Decimal(-7) % Decimal(4)
Decimal('-3') | operator ``%`` is applied to Decimal objects, the sign of the result is the sign of the *dividend* rather than the sign of the divisor::
>>> (-7) % 4
1
>>> Decimal(-7) % Decimal(4)
Decimal('-3') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ceb47d6-fa58-4e5c-9f77-f86f6078e820 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,851 | supabase-export-v2 | 9c6fcc9ad7b5bc30 | >>> print(exp(Decimal(1))) 2.718281828459045235360287471 >>> print(exp(Decimal(2))) 7.389056098930650227230427461 >>> print(exp(2.0)) 7.38905609893 >>> print(exp(2+0j)) (7.38905609893+0j)
"""
getcontext().prec += 2
i, lasts, s, fact, num = 0, 0, 1, 1, 1
while s != lasts:
lasts = s
i += 1
fact *= i
num *= x
s +=... | trusted_official_docs | CPython Docs | >>> print(exp(Decimal(1))) 2.718281828459045235360287471 >>> print(exp(Decimal(2))) 7.389056098930650227230427461 >>> print(exp(2.0)) 7.38905609893 >>> print(exp(2+0j)) (7.38905609893+0j)
"""
getcontext().prec += 2
i, lasts, s, fact, num = 0, 0, 1, 1, 1
while s != lasts:
lasts = s
i += 1
fact *= i
num *= x
s +=... | >>> print(exp(Decimal(1))) 2.718281828459045235360287471 >>> print(exp(Decimal(2))) 7.389056098930650227230427461 >>> print(exp(2.0)) 7.38905609893 >>> print(exp(2+0j)) (7.38905609893+0j)
"""
getcontext().prec += 2
i, lasts, s, fact, num = 0, 0, 1, 1, 1
while s != lasts:
lasts = s
i += 1
fact *= i
num *= x
s +=... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4147b5c7-aae6-47ce-961d-8a7e0407a5a7 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,324 | supabase-export-v2 | 79647f79349b39bf | The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals.
A decimal number is immutable. It has a sign, coefficient digits, and an
exponent. To preserve significance, the coefficient digits do not truncate
trailing zeros. Decimals also include special values such ... | trusted_official_docs | CPython Docs | The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals.
A decimal number is immutable. It has a sign, coefficient digits, and an
exponent. To preserve significance, the coefficient digits do not truncate
trailing zeros. Decimals also include special values such ... | The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals.
A decimal number is immutable. It has a sign, coefficient digits, and an
exponent. To preserve significance, the coefficient digits do not truncate
trailing zeros. Decimals also include special values such ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
41a16c85-6e5d-46bd-b708-31da04ee7571 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,827 | supabase-export-v2 | a7f18623bd96ef8b | been carried out to greater precision. Since their magnitude is zero, both positive and negative zeros are treated as equal and their sign is informational.
In addition to the two signed zeros which are distinct yet equal, there are
various representations of zero with differing precisions yet equivalent in
value. This... | trusted_official_docs | CPython Docs | been carried out to greater precision. Since their magnitude is zero, both positive and negative zeros are treated as equal and their sign is informational.
In addition to the two signed zeros which are distinct yet equal, there are
various representations of zero with differing precisions yet equivalent in
value. This... | been carried out to greater precision. Since their magnitude is zero, both positive and negative zeros are treated as equal and their sign is informational.
In addition to the two signed zeros which are distinct yet equal, there are
various representations of zero with differing precisions yet equivalent in
value. This... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4226e92c-8baf-421b-8901-79ca105e5d36 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,380 | supabase-export-v2 | 46a8ed19d5cbdab0 | (``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))`` returns ``Decimal('1.414')``.
If *value* is a :class:`float`, the binary floating-point value is losslessly
converted to its exact decimal equivalent. This conversion can oft... | trusted_official_docs | CPython Docs | (``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))`` returns ``Decimal('1.414')``.
If *value* is a :class:`float`, the binary floating-point value is losslessly
converted to its exact decimal equivalent. This conversion can oft... | (``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))`` returns ``Decimal('1.414')``.
If *value* is a :class:`float`, the binary floating-point value is losslessly
converted to its exact decimal equivalent. This conversion can oft... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4395cab7-1c7b-4cc6-a0ea-bb01a00574ba | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,823 | supabase-export-v2 | 160899c3cf6c9382 | be used in arithmetic operations where they get treated as very large, indeterminate numbers. For instance, adding a constant to infinity gives another infinite result.
Some operations are indeterminate and return ``NaN``, or if the
:exc:`InvalidOperation` signal is trapped, raise an exception. For example,
``0/0`` ret... | trusted_official_docs | CPython Docs | be used in arithmetic operations where they get treated as very large, indeterminate numbers. For instance, adding a constant to infinity gives another infinite result.
Some operations are indeterminate and return ``NaN``, or if the
:exc:`InvalidOperation` signal is trapped, raise an exception. For example,
``0/0`` ret... | be used in arithmetic operations where they get treated as very large, indeterminate numbers. For instance, adding a constant to infinity gives another infinite result.
Some operations are indeterminate and return ``NaN``, or if the
:exc:`InvalidOperation` signal is trapped, raise an exception. For example,
``0/0`` ret... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
44e58bbb-17c2-4235-989e-dd96010da5bf | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,391 | supabase-export-v2 | 181d2946a2543495 | (truncating towards zero) rather than its floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::
>>> -7 // 4
-2
>>> Decimal(-7) // Decimal(4)
Decimal('-1') | trusted_official_docs | CPython Docs | (truncating towards zero) rather than its floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::
>>> -7 // 4
-2
>>> Decimal(-7) // Decimal(4)
Decimal('-1') | (truncating towards zero) rather than its floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::
>>> -7 // 4
-2
>>> Decimal(-7) // Decimal(4)
Decimal('-1') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
451cb0d5-d61a-486e-81ba-1dcbd8c21895 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,376 | supabase-export-v2 | a3ae05d7838f1611 | Construct a new :class:`Decimal` object based from *value*.
*value* can be an integer, string, tuple, :class:`float`, or another :class:`Decimal`
object. If no *value* is given, returns ``Decimal('0')``. If *value* is a
string, it should conform to the decimal numeric string syntax after leading
and trailing whitesp... | trusted_official_docs | CPython Docs | Construct a new :class:`Decimal` object based from *value*.
*value* can be an integer, string, tuple, :class:`float`, or another :class:`Decimal`
object. If no *value* is given, returns ``Decimal('0')``. If *value* is a
string, it should conform to the decimal numeric string syntax after leading
and trailing whitesp... | Construct a new :class:`Decimal` object based from *value*.
*value* can be an integer, string, tuple, :class:`float`, or another :class:`Decimal`
object. If no *value* is given, returns ``Decimal('0')``. If *value* is a
string, it should conform to the decimal numeric string syntax after leading
and trailing whitesp... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
45bc7cb8-0d83-48be-8971-30cfba6228e4 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,379 | supabase-export-v2 | e0cae13f662903e1 | the fullwidth digits ``'\uff10'`` through ``'\uff19'``. Case is not significant, so, for example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable spellings for positive infinity.
If *value* is a :class:`tuple`, it should have three components, a sign
(``0`` for positive or ``1`` for negative), a :c... | trusted_official_docs | CPython Docs | the fullwidth digits ``'\uff10'`` through ``'\uff19'``. Case is not significant, so, for example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable spellings for positive infinity.
If *value* is a :class:`tuple`, it should have three components, a sign
(``0`` for positive or ``1`` for negative), a :c... | the fullwidth digits ``'\uff10'`` through ``'\uff19'``. Case is not significant, so, for example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable spellings for positive infinity.
If *value* is a :class:`tuple`, it should have three components, a sign
(``0`` for positive or ``1`` for negative), a :c... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
472ff0e1-820e-4702-b4d1-49165286e428 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,623 | supabase-export-v2 | 8e2ba4d0b3b2e1f0 | Returns a value equal to ``Emax - prec + 1``.
The usual approach to working with decimals is to create :class:`Decimal`
instances and then apply arithmetic operations which take place within the
current context for the active thread. An alternative approach is to use
context methods for calculating within a specific... | trusted_official_docs | CPython Docs | Returns a value equal to ``Emax - prec + 1``.
The usual approach to working with decimals is to create :class:`Decimal`
instances and then apply arithmetic operations which take place within the
current context for the active thread. An alternative approach is to use
context methods for calculating within a specific... | Returns a value equal to ``Emax - prec + 1``.
The usual approach to working with decimals is to create :class:`Decimal`
instances and then apply arithmetic operations which take place within the
current context for the active thread. An alternative approach is to use
context methods for calculating within a specific... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4935a03d-551e-4412-ab4e-a87a73c5d61c | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,816 | supabase-export-v2 | ab9ebf63398ced0c | >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
The :mod:`!decimal` module makes it possible to restore the identities by
expanding the precision sufficiently to avoid loss of significance: | trusted_official_docs | CPython Docs | >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
The :mod:`!decimal` module makes it possible to restore the identities by
expanding the precision sufficiently to avoid loss of significance: | >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') >>> (u*v) + (u*w) Decimal('0.01') >>> u * (v+w) Decimal('0.0060000')
The :mod:`!decimal` module makes it possible to restore the identities by
expanding the precision sufficiently to avoid loss of significance: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4a476c20-d2db-4460-924b-3a2e5091ba4e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,776 | supabase-export-v2 | 55700de9434a7adb | Altered an exponent to fit representation constraints.
Typically, clamping occurs when an exponent falls outside the context's
:attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the exponent is reduced to
fit by adding zeros to the coefficient. | trusted_official_docs | CPython Docs | Altered an exponent to fit representation constraints.
Typically, clamping occurs when an exponent falls outside the context's
:attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the exponent is reduced to
fit by adding zeros to the coefficient. | Altered an exponent to fit representation constraints.
Typically, clamping occurs when an exponent falls outside the context's
:attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the exponent is reduced to
fit by adding zeros to the coefficient. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4a8a1d1d-3572-4a7e-9356-0c35d31abd81 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,878 | supabase-export-v2 | 62fdbce2dd6fdd9e | ``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various precisions. Is there a way to transform them to a single recognizable canonical value?
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single
representative: | trusted_official_docs | CPython Docs | ``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various precisions. Is there a way to transform them to a single recognizable canonical value?
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single
representative: | ``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various precisions. Is there a way to transform them to a single recognizable canonical value?
A: The :meth:`~Decimal.normalize` method maps all equivalent values to a single
representative: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4bc5eb6c-2b89-40c2-8874-6945bcb780cd | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,573 | supabase-export-v2 | 956d19f807ca5cf4 | .. data:: BasicContext
This is a standard context defined by the General Decimal Arithmetic
Specification. Precision is set to nine. Rounding is set to
:const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated
as exceptions) except :const:`Inexact`, :const:`Rounded`, and
:const:`Subnormal`. | trusted_official_docs | CPython Docs | .. data:: BasicContext
This is a standard context defined by the General Decimal Arithmetic
Specification. Precision is set to nine. Rounding is set to
:const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated
as exceptions) except :const:`Inexact`, :const:`Rounded`, and
:const:`Subnormal`. | .. data:: BasicContext
This is a standard context defined by the General Decimal Arithmetic
Specification. Precision is set to nine. Rounding is set to
:const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated
as exceptions) except :const:`Inexact`, :const:`Rounded`, and
:const:`Subnormal`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4c81bc19-3378-4f01-a3d7-36dba3266e58 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,418 | supabase-export-v2 | 6de812cb09ad626a | two operands using their abstract representation rather than their value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to ``x.copy_abs().compare_total(y.copy_abs())``.
This operation is unaffected by context and is quiet: no flags are changed
and no roundi... | trusted_official_docs | CPython Docs | two operands using their abstract representation rather than their value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to ``x.copy_abs().compare_total(y.copy_abs())``.
This operation is unaffected by context and is quiet: no flags are changed
and no roundi... | two operands using their abstract representation rather than their value as in :meth:`compare_total`, but ignoring the sign of each operand. ``x.compare_total_mag(y)`` is equivalent to ``x.copy_abs().compare_total(y.copy_abs())``.
This operation is unaffected by context and is quiet: no flags are changed
and no roundi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
508592f6-d370-49eb-8bb2-11740d2b70d5 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,849 | supabase-export-v2 | 4448a46da2341a2d | = d+da, da+32 t = (t * n) / d s += t getcontext().prec -= 2 return +s # unary plus applies the new precision
def exp(x):
"""Return e raised to the power of x. Result type matches input type. | trusted_official_docs | CPython Docs | = d+da, da+32 t = (t * n) / d s += t getcontext().prec -= 2 return +s # unary plus applies the new precision
def exp(x):
"""Return e raised to the power of x. Result type matches input type. | = d+da, da+32 t = (t * n) / d s += t getcontext().prec -= 2 return +s # unary plus applies the new precision
def exp(x):
"""Return e raised to the power of x. Result type matches input type. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
512090d1-60be-4d11-ba62-8fc0ab97476e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,876 | supabase-export-v2 | 9b7d9b0fba436eb4 | >>> def mul(x, y, fp=TWOPLACES): ... return (x * y).quantize(fp) ... >>> def div(x, y, fp=TWOPLACES): ... return (x / y).quantize(fp)
>>> mul(a, b) # Automatically preserve fixed-point
Decimal('325.62')
>>> div(b, a)
Decimal('0.03') | trusted_official_docs | CPython Docs | >>> def mul(x, y, fp=TWOPLACES): ... return (x * y).quantize(fp) ... >>> def div(x, y, fp=TWOPLACES): ... return (x / y).quantize(fp)
>>> mul(a, b) # Automatically preserve fixed-point
Decimal('325.62')
>>> div(b, a)
Decimal('0.03') | >>> def mul(x, y, fp=TWOPLACES): ... return (x * y).quantize(fp) ... >>> def div(x, y, fp=TWOPLACES): ... return (x / y).quantize(fp)
>>> mul(a, b) # Automatically preserve fixed-point
Decimal('325.62')
>>> div(b, a)
Decimal('0.03') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
52d5f3a6-a1c4-4d2d-bac3-9d7f54eb0d77 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,510 | supabase-export-v2 | e12bdaac30731544 | ``rounding`` argument if given, else by the given ``context`` argument; if neither argument is given the rounding mode of the current thread's context is used.
An error is returned whenever the resulting exponent is greater than
:attr:`~Context.Emax` or less than :meth:`~Context.Etiny`. | trusted_official_docs | CPython Docs | ``rounding`` argument if given, else by the given ``context`` argument; if neither argument is given the rounding mode of the current thread's context is used.
An error is returned whenever the resulting exponent is greater than
:attr:`~Context.Emax` or less than :meth:`~Context.Etiny`. | ``rounding`` argument if given, else by the given ``context`` argument; if neither argument is given the rounding mode of the current thread's context is used.
An error is returned whenever the resulting exponent is greater than
:attr:`~Context.Emax` or less than :meth:`~Context.Etiny`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
541d2ee5-ec0e-4c31-8150-c84fd3cf05a4 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,872 | supabase-export-v2 | 13a67061e7570e7d | Q: Once I have valid two place inputs, how do I maintain that invariant throughout an application?
A: Some operations like addition, subtraction, and multiplication by an integer
will automatically preserve fixed point. Others operations, like division and
non-integer multiplication, will change the number of decimal p... | trusted_official_docs | CPython Docs | Q: Once I have valid two place inputs, how do I maintain that invariant throughout an application?
A: Some operations like addition, subtraction, and multiplication by an integer
will automatically preserve fixed point. Others operations, like division and
non-integer multiplication, will change the number of decimal p... | Q: Once I have valid two place inputs, how do I maintain that invariant throughout an application?
A: Some operations like addition, subtraction, and multiplication by an integer
will automatically preserve fixed point. Others operations, like division and
non-integer multiplication, will change the number of decimal p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
551e0e99-23f5-4290-a248-96b50b29cc2f | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,352 | supabase-export-v2 | 82c165e53dc4f7ec | .. doctest::
>>> format(Decimal('2.675'), "f")
'2.675'
>>> 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 | trusted_official_docs | CPython Docs | .. doctest::
>>> format(Decimal('2.675'), "f")
'2.675'
>>> 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 | .. doctest::
>>> format(Decimal('2.675'), "f")
'2.675'
>>> 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 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
59f57410-ea7e-4411-8da7-31ea987fd20a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,802 | supabase-export-v2 | 1fad2d996cfd9002 | Enable stricter semantics for mixing floats and Decimals.
If the signal is not trapped (default), mixing floats and Decimals is
permitted in the :class:`~decimal.Decimal` constructor,
:meth:`~decimal.Context.create_decimal` and all comparison operators. Both conversion and comparisons are exact. Any occurrence of a m... | trusted_official_docs | CPython Docs | Enable stricter semantics for mixing floats and Decimals.
If the signal is not trapped (default), mixing floats and Decimals is
permitted in the :class:`~decimal.Decimal` constructor,
:meth:`~decimal.Context.create_decimal` and all comparison operators. Both conversion and comparisons are exact. Any occurrence of a m... | Enable stricter semantics for mixing floats and Decimals.
If the signal is not trapped (default), mixing floats and Decimals is
permitted in the :class:`~decimal.Decimal` constructor,
:meth:`~decimal.Context.create_decimal` and all comparison operators. Both conversion and comparisons are exact. Any occurrence of a m... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5abffb8c-be47-48e8-87cd-24a0096a6755 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,386 | supabase-export-v2 | d64b799aaa6a1b30 | .. versionchanged:: 3.3 :class:`float` arguments raise an exception if the :exc:`FloatOperation` trap is set. By default the trap is off.
.. versionchanged:: 3.6
Underscores are allowed for grouping, as with integral and floating-point
literals in code. | trusted_official_docs | CPython Docs | .. versionchanged:: 3.3 :class:`float` arguments raise an exception if the :exc:`FloatOperation` trap is set. By default the trap is off.
.. versionchanged:: 3.6
Underscores are allowed for grouping, as with integral and floating-point
literals in code. | .. versionchanged:: 3.3 :class:`float` arguments raise an exception if the :exc:`FloatOperation` trap is set. By default the trap is off.
.. versionchanged:: 3.6
Underscores are allowed for grouping, as with integral and floating-point
literals in code. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5c032ddc-f1dc-47a6-abc8-09311b255a61 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,574 | supabase-export-v2 | 2ea9471e6c90591f | is set to nine. Rounding is set to :const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated as exceptions) except :const:`Inexact`, :const:`Rounded`, and :const:`Subnormal`.
Because many of the traps are enabled, this context is useful for debugging. | trusted_official_docs | CPython Docs | is set to nine. Rounding is set to :const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated as exceptions) except :const:`Inexact`, :const:`Rounded`, and :const:`Subnormal`.
Because many of the traps are enabled, this context is useful for debugging. | is set to nine. Rounding is set to :const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated as exceptions) except :const:`Inexact`, :const:`Rounded`, and :const:`Subnormal`.
Because many of the traps are enabled, this context is useful for debugging. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5caad391-8380-4b2e-8137-4ae02e585f98 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,585 | supabase-export-v2 | 0372e5a6b93e3892 | .. class:: Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None)
Creates a new context. If a field is not specified or is :const:`None`, the
default values are copied from the :const:`DefaultContext`. If the *flags*
field is not specified or is :const:`None`, all f... | trusted_official_docs | CPython Docs | .. class:: Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None)
Creates a new context. If a field is not specified or is :const:`None`, the
default values are copied from the :const:`DefaultContext`. If the *flags*
field is not specified or is :const:`None`, all f... | .. class:: Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None)
Creates a new context. If a field is not specified or is :const:`None`, the
default values are copied from the :const:`DefaultContext`. If the *flags*
field is not specified or is :const:`None`, all f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5cba1bab-7e41-4322-beee-dbda78c38e9e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,319 | supabase-export-v2 | e87a26e9186628e1 | For multiplication, the "schoolbook" approach uses all the figures in the multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 * 1.20`` gives ``1.5600``.
* Unlike hardware based binary floating point, the decimal module has a user
alterable precision (defaulting to 28 places) which can be as large as... | trusted_official_docs | CPython Docs | For multiplication, the "schoolbook" approach uses all the figures in the multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 * 1.20`` gives ``1.5600``.
* Unlike hardware based binary floating point, the decimal module has a user
alterable precision (defaulting to 28 places) which can be as large as... | For multiplication, the "schoolbook" approach uses all the figures in the multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 * 1.20`` gives ``1.5600``.
* Unlike hardware based binary floating point, the decimal module has a user
alterable precision (defaulting to 28 places) which can be as large as... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5fed5f5d-fd20-463f-b21d-049f9cbc401e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,364 | supabase-export-v2 | 08ed1cf538275bf3 | >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) Traceback (most recent call last): File "<pyshell#143>", line 1, in -toplevel- Decimal(42) / Decimal(0) DivisionByZero: x / 0
Contexts also have signal flags for monitoring exceptional conditions
encountered during computations. The flags remain set until explic... | trusted_official_docs | CPython Docs | >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) Traceback (most recent call last): File "<pyshell#143>", line 1, in -toplevel- Decimal(42) / Decimal(0) DivisionByZero: x / 0
Contexts also have signal flags for monitoring exceptional conditions
encountered during computations. The flags remain set until explic... | >>> setcontext(BasicContext) >>> Decimal(42) / Decimal(0) Traceback (most recent call last): File "<pyshell#143>", line 1, in -toplevel- Decimal(42) / Decimal(0) DivisionByZero: x / 0
Contexts also have signal flags for monitoring exceptional conditions
encountered during computations. The flags remain set until explic... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
602ffca1-2a5f-450d-9b28-714ceb26b4f9 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,316 | supabase-export-v2 | f4a49b81ef423d65 | must provide an arithmetic that works in the same way as the arithmetic that people learn at school." -- excerpt from the decimal arithmetic specification.
* Decimal numbers can be represented exactly. In contrast, numbers like
``1.1`` and ``2.2`` do not have exact representations in binary
floating point. End users ... | trusted_official_docs | CPython Docs | must provide an arithmetic that works in the same way as the arithmetic that people learn at school." -- excerpt from the decimal arithmetic specification.
* Decimal numbers can be represented exactly. In contrast, numbers like
``1.1`` and ``2.2`` do not have exact representations in binary
floating point. End users ... | must provide an arithmetic that works in the same way as the arithmetic that people learn at school." -- excerpt from the decimal arithmetic specification.
* Decimal numbers can be represented exactly. In contrast, numbers like
``1.1`` and ``2.2`` do not have exact representations in binary
floating point. End users ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
60b1a362-9fdd-451e-9371-99373359dda6 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,832 | supabase-export-v2 | 281912031d0dea1b | Working with threads --------------------
The :func:`getcontext` function accesses 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. | trusted_official_docs | CPython Docs | Working with threads --------------------
The :func:`getcontext` function accesses 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. | Working with threads --------------------
The :func:`getcontext` function accesses 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. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
61743be0-1981-47fd-ad14-06e6b6984b0f | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,895 | supabase-export-v2 | a79af161f682ccd8 | is applied to the results of operations but not to the inputs. Is there anything to watch out for when mixing values of different precisions?
A: Yes. The principle is that all values are considered to be exact and so is
the arithmetic on those values. Only the results are rounded. The advantage
for inputs is that "what... | trusted_official_docs | CPython Docs | is applied to the results of operations but not to the inputs. Is there anything to watch out for when mixing values of different precisions?
A: Yes. The principle is that all values are considered to be exact and so is
the arithmetic on those values. Only the results are rounded. The advantage
for inputs is that "what... | is applied to the results of operations but not to the inputs. Is there anything to watch out for when mixing values of different precisions?
A: Yes. The principle is that all values are considered to be exact and so is
the arithmetic on those values. Only the results are rounded. The advantage
for inputs is that "what... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6272c143-8aa0-4a16-aa1a-b6c959fb533a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,544 | supabase-export-v2 | 8ee08e5b20da2309 | For example::
>>> from decimal import Decimal, getcontext, ROUND_DOWN
>>> getcontext().rounding = ROUND_DOWN
>>> round(Decimal('3.75')) # context rounding ignored
4
>>> round(Decimal('3.5')) # round-ties-to-even
4
>>> round(Decimal('3.75'), 0) # uses the context rounding
Decimal('3')
>>> round(Decimal('3.75'), ... | trusted_official_docs | CPython Docs | For example::
>>> from decimal import Decimal, getcontext, ROUND_DOWN
>>> getcontext().rounding = ROUND_DOWN
>>> round(Decimal('3.75')) # context rounding ignored
4
>>> round(Decimal('3.5')) # round-ties-to-even
4
>>> round(Decimal('3.75'), 0) # uses the context rounding
Decimal('3')
>>> round(Decimal('3.75'), ... | For example::
>>> from decimal import Decimal, getcontext, ROUND_DOWN
>>> getcontext().rounding = ROUND_DOWN
>>> round(Decimal('3.75')) # context rounding ignored
4
>>> round(Decimal('3.5')) # round-ties-to-even
4
>>> round(Decimal('3.75'), 0) # uses the context rounding
Decimal('3')
>>> round(Decimal('3.75'), ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
63956c7f-59ae-4a1d-b40f-a1d80545e595 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,509 | supabase-export-v2 | 22de030d1d85126b | Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
If the exponent of the second operand is larger than that of the first
then rounding may be necessary. In this case, the rounding mode is
determined by the ``rounding`` argument if given, else by the given
``... | trusted_official_docs | CPython Docs | Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
If the exponent of the second operand is larger than that of the first
then rounding may be necessary. In this case, the rounding mode is
determined by the ``rounding`` argument if given, else by the given
``... | Also unlike other operations, quantize never signals Underflow, even if the result is subnormal and inexact.
If the exponent of the second operand is larger than that of the first
then rounding may be necessary. In this case, the rounding mode is
determined by the ``rounding`` argument if given, else by the given
``... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
64337700-d078-4135-b2f4-5e7544666bb8 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,538 | supabase-export-v2 | 552d36968c24ddab | nearest integer without signaling :const:`Inexact` or :const:`Rounded`. If given, applies *rounding*; otherwise, uses the rounding method in either the supplied *context* or the current context.
Decimal numbers can be rounded using the :func:`.round` function: | trusted_official_docs | CPython Docs | nearest integer without signaling :const:`Inexact` or :const:`Rounded`. If given, applies *rounding*; otherwise, uses the rounding method in either the supplied *context* or the current context.
Decimal numbers can be rounded using the :func:`.round` function: | nearest integer without signaling :const:`Inexact` or :const:`Rounded`. If given, applies *rounding*; otherwise, uses the rounding method in either the supplied *context* or the current context.
Decimal numbers can be rounded using the :func:`.round` function: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
68d3d8d4-8a06-499c-b83a-147b20f36c63 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,598 | supabase-export-v2 | f3cb8e88696cb70a | its coefficient, in order to fit the exponent constraints; this preserves the value of the number but loses information about significant trailing zeros. For example::
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
Decimal('1.23000E+999') | trusted_official_docs | CPython Docs | its coefficient, in order to fit the exponent constraints; this preserves the value of the number but loses information about significant trailing zeros. For example::
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
Decimal('1.23000E+999') | its coefficient, in order to fit the exponent constraints; this preserves the value of the number but loses information about significant trailing zeros. For example::
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
Decimal('1.23000E+999') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6a0e20ff-8691-47e0-8959-39feec37cfb8 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,620 | supabase-export-v2 | 4d903548e300363e | .. method:: Etiny()
Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent
value for subnormal results. When underflow occurs, the exponent is set
to :const:`Etiny`. | trusted_official_docs | CPython Docs | .. method:: Etiny()
Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent
value for subnormal results. When underflow occurs, the exponent is set
to :const:`Etiny`. | .. method:: Etiny()
Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent
value for subnormal results. When underflow occurs, the exponent is set
to :const:`Etiny`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6b293ce6-0782-4c57-be0a-76ee1f754ace | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,844 | supabase-export-v2 | c76c01ca95374e31 | numbers: '+', space or blank neg: optional sign for negative numbers: '-', '(', space or blank trailneg:optional trailing minus indicator: '-', ')', space or blank
>>> d = Decimal('-1234567.8901')
>>> moneyfmt(d, curr='$')
'-$1,234,567.89'
>>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
'1.234.568-'... | trusted_official_docs | CPython Docs | numbers: '+', space or blank neg: optional sign for negative numbers: '-', '(', space or blank trailneg:optional trailing minus indicator: '-', ')', space or blank
>>> d = Decimal('-1234567.8901')
>>> moneyfmt(d, curr='$')
'-$1,234,567.89'
>>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
'1.234.568-'... | numbers: '+', space or blank neg: optional sign for negative numbers: '-', '(', space or blank trailneg:optional trailing minus indicator: '-', ')', space or blank
>>> d = Decimal('-1234567.8901')
>>> moneyfmt(d, curr='$')
'-$1,234,567.89'
>>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
'1.234.568-'... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ba91ac7-7b68-4dd3-b765-10789bc65569 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,393 | supabase-export-v2 | d9453f2ec02acaf5 | The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-integer`` operations (respectively) as described in the specification.
Decimal objects cannot generally be combined with floats or
instances of :class:`fractions.Fraction` in arithmetic operations:
an attempt to add a :class:`Decimal` to a :class... | trusted_official_docs | CPython Docs | The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-integer`` operations (respectively) as described in the specification.
Decimal objects cannot generally be combined with floats or
instances of :class:`fractions.Fraction` in arithmetic operations:
an attempt to add a :class:`Decimal` to a :class... | The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-integer`` operations (respectively) as described in the specification.
Decimal objects cannot generally be combined with floats or
instances of :class:`fractions.Fraction` in arithmetic operations:
an attempt to add a :class:`Decimal` to a :class... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6bebe167-f3c6-4ce2-a991-57bdd9d27c0d | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,559 | supabase-export-v2 | daeacabdeded0fde | .. function:: localcontext(ctx=None, **kwargs)
Return a context manager that will set the current context for the active thread
to a copy of *ctx* on entry to the with-statement and restore the previous context
when exiting the with-statement. If no context is specified, a copy of the
current context is used. The *k... | trusted_official_docs | CPython Docs | .. function:: localcontext(ctx=None, **kwargs)
Return a context manager that will set the current context for the active thread
to a copy of *ctx* on entry to the with-statement and restore the previous context
when exiting the with-statement. If no context is specified, a copy of the
current context is used. The *k... | .. function:: localcontext(ctx=None, **kwargs)
Return a context manager that will set the current context for the active thread
to a copy of *ctx* on entry to the with-statement and restore the previous context
when exiting the with-statement. If no context is specified, a copy of the
current context is used. The *k... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c5b4e97-f6de-4f08-9db1-4b2109983d04 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,385 | supabase-export-v2 | 3b157c96aa463b38 | .. versionchanged:: 3.2 The argument to the constructor is now permitted to be a :class:`float` instance.
.. versionchanged:: 3.3
:class:`float` arguments raise an exception if the :exc:`FloatOperation`
trap is set. By default the trap is off. | trusted_official_docs | CPython Docs | .. versionchanged:: 3.2 The argument to the constructor is now permitted to be a :class:`float` instance.
.. versionchanged:: 3.3
:class:`float` arguments raise an exception if the :exc:`FloatOperation`
trap is set. By default the trap is off. | .. versionchanged:: 3.2 The argument to the constructor is now permitted to be a :class:`float` instance.
.. versionchanged:: 3.3
:class:`float` arguments raise an exception if the :exc:`FloatOperation`
trap is set. By default the trap is off. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c8643d7-6e39-4a30-bdaf-cde0aeacebf2 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,866 | supabase-export-v2 | 47250deda1a5ac47 | many places and need to be rounded. Others are not supposed to have excess digits and need to be validated. What methods should be used?
A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If
the :const:`Inexact` trap is set, it is also useful for validation: | trusted_official_docs | CPython Docs | many places and need to be rounded. Others are not supposed to have excess digits and need to be validated. What methods should be used?
A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If
the :const:`Inexact` trap is set, it is also useful for validation: | many places and need to be rounded. Others are not supposed to have excess digits and need to be validated. What methods should be used?
A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal places. If
the :const:`Inexact` trap is set, it is also useful for validation: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c907d8a-732b-40df-87ba-8f1d5da42d6d | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,334 | supabase-export-v2 | 51dcb64fc4658ba6 | 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::
>>> from decimal import *
>>> getcontext()
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=... | trusted_official_docs | CPython Docs | 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::
>>> from decimal import *
>>> getcontext()
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=... | 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::
>>> from decimal import *
>>> getcontext()
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6d6e22b3-32ab-459b-9e0a-5089ba5efc16 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,904 | supabase-export-v2 | 405999c0a583ef9a | Q: Is the CPython implementation fast for large numbers?
A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
the decimal module integrate the high speed `libmpdec
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
arbitrary precision correctly rounded decimal floating-point ... | trusted_official_docs | CPython Docs | Q: Is the CPython implementation fast for large numbers?
A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
the decimal module integrate the high speed `libmpdec
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
arbitrary precision correctly rounded decimal floating-point ... | Q: Is the CPython implementation fast for large numbers?
A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
the decimal module integrate the high speed `libmpdec
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
arbitrary precision correctly rounded decimal floating-point ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6e837abb-2f30-44ff-b365-c003a300473b | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,395 | supabase-export-v2 | 5bc40511e255a4d1 | .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully supported.
In addition to the standard numeric properties, decimal floating-point
objects also have a number of specialized methods: | trusted_official_docs | CPython Docs | .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully supported.
In addition to the standard numeric properties, decimal floating-point
objects also have a number of specialized methods: | .. versionchanged:: 3.2 Mixed-type comparisons between :class:`Decimal` instances and other numeric types are now fully supported.
In addition to the standard numeric properties, decimal floating-point
objects also have a number of specialized methods: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ef2d882-8610-48c0-b62f-1338b44af1d1 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,567 | supabase-export-v2 | 24e3dff5d0443105 | Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an invalid value for an attribute.
.. versionchanged:: 3.11
:meth:`localcontext` now supports setting context attributes through the use of keyword a... | trusted_official_docs | CPython Docs | Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an invalid value for an attribute.
.. versionchanged:: 3.11
:meth:`localcontext` now supports setting context attributes through the use of keyword a... | Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an invalid value for an attribute.
.. versionchanged:: 3.11
:meth:`localcontext` now supports setting context attributes through the use of keyword a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
705013b6-1e69-4c07-bd65-180d77644851 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,580 | supabase-export-v2 | 0b1574fd81e3fe08 | prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts created by the :class:`Context` constructor.
This context is most useful in multi-threaded environments. Changing one of the
fields before threads are started has the effect of setting system-wide
d... | trusted_official_docs | CPython Docs | prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts created by the :class:`Context` constructor.
This context is most useful in multi-threaded environments. Changing one of the
fields before threads are started has the effect of setting system-wide
d... | prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts created by the :class:`Context` constructor.
This context is most useful in multi-threaded environments. Changing one of the
fields before threads are started has the effect of setting system-wide
d... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7116e543-7f80-47fb-a1fd-84a81902067e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,369 | supabase-export-v2 | 03e4d8450295d7d2 | .. doctest:: newcontext
>>> setcontext(ExtendedContext)
>>> Decimal(1) / Decimal(0)
Decimal('Infinity')
>>> 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 | trusted_official_docs | CPython Docs | .. doctest:: newcontext
>>> setcontext(ExtendedContext)
>>> Decimal(1) / Decimal(0)
Decimal('Infinity')
>>> 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 | .. doctest:: newcontext
>>> setcontext(ExtendedContext)
>>> Decimal(1) / Decimal(0)
Decimal('Infinity')
>>> 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 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
71b5c8ae-2a51-42dc-bb9b-0c13937b02e4 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,907 | supabase-export-v2 | 957df6cfcc610e74 | The easiest approach for trying out bignum arithmetic is to use the maximum value for :attr:`~Context.prec` as well [#]_::
>>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))
>>> x = Decimal(2) ** 256
>>> x / 128
Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312') | trusted_official_docs | CPython Docs | The easiest approach for trying out bignum arithmetic is to use the maximum value for :attr:`~Context.prec` as well [#]_::
>>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))
>>> x = Decimal(2) ** 256
>>> x / 128
Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312') | The easiest approach for trying out bignum arithmetic is to use the maximum value for :attr:`~Context.prec` as well [#]_::
>>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))
>>> x = Decimal(2) ** 256
>>> x / 128
Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
72e1ee9d-8d0f-4b33-bc02-d009410201e6 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,362 | supabase-export-v2 | 3ab095cc57f896e7 | >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal('0.142857142857142857142857142857142857142857142857142857142857')
>>> ExtendedContext
Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=[], t... | trusted_official_docs | CPython Docs | >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal('0.142857142857142857142857142857142857142857142857142857142857')
>>> ExtendedContext
Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=[], t... | >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN) >>> setcontext(myothercontext) >>> Decimal(1) / Decimal(7) Decimal('0.142857142857142857142857142857142857142857142857142857142857')
>>> ExtendedContext
Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
capitals=1, clamp=0, flags=[], t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
737e8d72-4c8a-4065-82ae-27f734d564f2 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,535 | supabase-export-v2 | 6d39062ab9f7c1bc | .. method:: to_integral_exact(rounding=None, context=None)
Round to the nearest integer, signaling :const:`Inexact` or
:const:`Rounded` as appropriate if rounding occurs. The rounding mode is
determined by the ``rounding`` parameter if given, else by the given
``context``. If neither parameter is given then the roun... | trusted_official_docs | CPython Docs | .. method:: to_integral_exact(rounding=None, context=None)
Round to the nearest integer, signaling :const:`Inexact` or
:const:`Rounded` as appropriate if rounding occurs. The rounding mode is
determined by the ``rounding`` parameter if given, else by the given
``context``. If neither parameter is given then the roun... | .. method:: to_integral_exact(rounding=None, context=None)
Round to the nearest integer, signaling :const:`Inexact` or
:const:`Rounded` as appropriate if rounding occurs. The rounding mode is
determined by the ``rounding`` parameter if given, else by the given
``context``. If neither parameter is given then the roun... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
77b9ec0a-a88e-4df1-80ef-ec55ef306418 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,727 | supabase-export-v2 | e73c645dced7d33a | is the integer nearest the exact value of ``x / y`` (if the result is 0 then its sign will be the sign of *x*).
.. method:: rotate(x, y, /) | trusted_official_docs | CPython Docs | is the integer nearest the exact value of ``x / y`` (if the result is 0 then its sign will be the sign of *x*).
.. method:: rotate(x, y, /) | is the integer nearest the exact value of ``x / y`` (if the result is 0 then its sign will be the sign of *x*).
.. method:: rotate(x, y, /) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7894dd88-ee75-4024-9d46-6c6192473960 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,863 | supabase-export-v2 | 82aa9885ab89f466 | Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to minimize typing when using the interactive interpreter?
A: Some users abbreviate the constructor to just a single letter: | trusted_official_docs | CPython Docs | Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to minimize typing when using the interactive interpreter?
A: Some users abbreviate the constructor to just a single letter: | Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way to minimize typing when using the interactive interpreter?
A: Some users abbreviate the constructor to just a single letter: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
790cd0c6-a9e2-48b1-9881-cecf47d25250 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,537 | supabase-export-v2 | 1fe3bee6d90b24c6 | .. method:: to_integral_value(rounding=None, context=None)
Round to the nearest integer without signaling :const:`Inexact` or
:const:`Rounded`. If given, applies *rounding*; otherwise, uses the
rounding method in either the supplied *context* or the current context. | trusted_official_docs | CPython Docs | .. method:: to_integral_value(rounding=None, context=None)
Round to the nearest integer without signaling :const:`Inexact` or
:const:`Rounded`. If given, applies *rounding*; otherwise, uses the
rounding method in either the supplied *context* or the current context. | .. method:: to_integral_value(rounding=None, context=None)
Round to the nearest integer without signaling :const:`Inexact` or
:const:`Rounded`. If given, applies *rounding*; otherwise, uses the
rounding method in either the supplied *context* or the current context. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7c58ea88-392d-4069-8bfd-93dfa174cf1a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,714 | supabase-export-v2 | bab9cfdeae6c79af | ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
.. versionchanged:: 3.3
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... | trusted_official_docs | CPython Docs | ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
.. versionchanged:: 3.3
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... | ``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``.
.. versionchanged:: 3.3
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... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7f8da625-f931-4bf2-b1c6-9c538d02138c | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,552 | supabase-export-v2 | a9c8d29a7a62139d | are environments for arithmetic operations. They govern precision, set rules for rounding, determine which signals are treated as exceptions, and limit the range for exponents.
Each thread has its own current context which is accessed or changed using the
:func:`getcontext` and :func:`setcontext` functions: | trusted_official_docs | CPython Docs | are environments for arithmetic operations. They govern precision, set rules for rounding, determine which signals are treated as exceptions, and limit the range for exponents.
Each thread has its own current context which is accessed or changed using the
:func:`getcontext` and :func:`setcontext` functions: | are environments for arithmetic operations. They govern precision, set rules for rounding, determine which signals are treated as exceptions, and limit the range for exponents.
Each thread has its own current context which is accessed or changed using the
:func:`getcontext` and :func:`setcontext` functions: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7f983d65-197c-4820-b428-3feac4bb4c1c | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,843 | supabase-export-v2 | b9fdbfda090ce4d7 | def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
places: required number of places after the decimal point
curr: optional currency symbol before the sign (may be blank)
sep: optional grouping separator (comma, period, space, or blan... | trusted_official_docs | CPython Docs | def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
places: required number of places after the decimal point
curr: optional currency symbol before the sign (may be blank)
sep: optional grouping separator (comma, period, space, or blan... | def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''): """Convert Decimal to a money formatted string.
places: required number of places after the decimal point
curr: optional currency symbol before the sign (may be blank)
sep: optional grouping separator (comma, period, space, or blan... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
81274c59-bc1c-4419-b416-f61527c9eb2c | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,566 | supabase-export-v2 | 3cc3cf9cf4ef525b | with localcontext(prec=42) as ctx: s = calculate_something() s = +s
Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't
support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an
invalid value for an attribute. | trusted_official_docs | CPython Docs | with localcontext(prec=42) as ctx: s = calculate_something() s = +s
Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't
support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an
invalid value for an attribute. | with localcontext(prec=42) as ctx: s = calculate_something() s = +s
Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't
support. Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an
invalid value for an attribute. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
818f9016-4c5b-4ff3-aea2-63709d3f5c28 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,790 | supabase-export-v2 | 0d183af956883b8f | Numerical overflow.
Indicates the exponent is larger than :attr:`Context.Emax` after rounding has
occurred. If not trapped, the result depends on the rounding mode, either
pulling inward to the largest representable finite number or rounding outward
to ``Infinity``. In either case, :class:`Inexact` and :class:`Round... | trusted_official_docs | CPython Docs | Numerical overflow.
Indicates the exponent is larger than :attr:`Context.Emax` after rounding has
occurred. If not trapped, the result depends on the rounding mode, either
pulling inward to the largest representable finite number or rounding outward
to ``Infinity``. In either case, :class:`Inexact` and :class:`Round... | Numerical overflow.
Indicates the exponent is larger than :attr:`Context.Emax` after rounding has
occurred. If not trapped, the result depends on the rounding mode, either
pulling inward to the largest representable finite number or rounding outward
to ``Infinity``. In either case, :class:`Inexact` and :class:`Round... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
834de3e4-7ad1-4b1c-8896-6093c12e125a | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,894 | supabase-export-v2 | f892f316ce186308 | calculations using greater precision and with various rounding modes. Widely differing results indicate insufficient precision, rounding mode issues, ill-conditioned inputs, or a numerically unstable algorithm.
Q: I noticed that context precision is applied to the results of operations but
not to the inputs. Is there a... | trusted_official_docs | CPython Docs | calculations using greater precision and with various rounding modes. Widely differing results indicate insufficient precision, rounding mode issues, ill-conditioned inputs, or a numerically unstable algorithm.
Q: I noticed that context precision is applied to the results of operations but
not to the inputs. Is there a... | calculations using greater precision and with various rounding modes. Widely differing results indicate insufficient precision, rounding mode issues, ill-conditioned inputs, or a numerically unstable algorithm.
Q: I noticed that context precision is applied to the results of operations but
not to the inputs. Is there a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
87ca89dd-ac1e-4397-8f3e-2bc53cbd324b | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,336 | supabase-export-v2 | 01524237984635c5 | >>> getcontext().prec = 7 # Set a new precision
Decimal instances can be constructed from integers, strings, floats, or tuples. Construction from an integer or a float performs an exact conversion of the
value of that integer or float. Decimal numbers include special values such as
``NaN`` which stands for "Not a numbe... | trusted_official_docs | CPython Docs | >>> getcontext().prec = 7 # Set a new precision
Decimal instances can be constructed from integers, strings, floats, or tuples. Construction from an integer or a float performs an exact conversion of the
value of that integer or float. Decimal numbers include special values such as
``NaN`` which stands for "Not a numbe... | >>> getcontext().prec = 7 # Set a new precision
Decimal instances can be constructed from integers, strings, floats, or tuples. Construction from an integer or a float performs an exact conversion of the
value of that integer or float. Decimal numbers include special values such as
``NaN`` which stands for "Not a numbe... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a52727f-d1df-4b4c-8f93-b591ffcc51bd | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,414 | supabase-export-v2 | b12d38e21dc2031b | >>> Decimal('12.0').compare_total(Decimal('12')) Decimal('-1')
Quiet and signaling NaNs are also included in the total ordering. The
result of this function is ``Decimal('0')`` if both operands have the same
representation, ``Decimal('-1')`` if the first operand is lower in the
total order than the second, and ``Dec... | trusted_official_docs | CPython Docs | >>> Decimal('12.0').compare_total(Decimal('12')) Decimal('-1')
Quiet and signaling NaNs are also included in the total ordering. The
result of this function is ``Decimal('0')`` if both operands have the same
representation, ``Decimal('-1')`` if the first operand is lower in the
total order than the second, and ``Dec... | >>> Decimal('12.0').compare_total(Decimal('12')) Decimal('-1')
Quiet and signaling NaNs are also included in the total ordering. The
result of this function is ``Decimal('0')`` if both operands have the same
representation, ``Decimal('-1')`` if the first operand is lower in the
total order than the second, and ``Dec... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8b457007-ec6c-4f5a-b1e3-a33e346c77dd | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,822 | supabase-export-v2 | 1a8e88323049d4e1 | signal is not trapped. Likewise, when the :exc:`Overflow` signal is not trapped, infinity can result from rounding beyond the limits of the largest representable number.
The infinities are signed (affine) and can be used in arithmetic operations
where they get treated as very large, indeterminate numbers. For instance,... | trusted_official_docs | CPython Docs | signal is not trapped. Likewise, when the :exc:`Overflow` signal is not trapped, infinity can result from rounding beyond the limits of the largest representable number.
The infinities are signed (affine) and can be used in arithmetic operations
where they get treated as very large, indeterminate numbers. For instance,... | signal is not trapped. Likewise, when the :exc:`Overflow` signal is not trapped, infinity can result from rounding beyond the limits of the largest representable number.
The infinities are signed (affine) and can be used in arithmetic operations
where they get treated as very large, indeterminate numbers. For instance,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8b981d70-d55c-40cf-9050-63ed5a35a4f2 | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,846 | supabase-export-v2 | 2bd621ca8b582bf1 | 0 while digits: build(next()) i += 1 if i == 3 and digits: i = 0 build(sep) build(curr) build(neg if sign else pos) return ''.join(reversed(result))
def pi():
"""Compute Pi to the current precision. | trusted_official_docs | CPython Docs | 0 while digits: build(next()) i += 1 if i == 3 and digits: i = 0 build(sep) build(curr) build(neg if sign else pos) return ''.join(reversed(result))
def pi():
"""Compute Pi to the current precision. | 0 while digits: build(next()) i += 1 if i == 3 and digits: i = 0 build(sep) build(curr) build(neg if sign else pos) return ''.join(reversed(result))
def pi():
"""Compute Pi to the current precision. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8beed9f5-809c-40d0-8fd9-7bb81a5bd10e | CPython Docs | file://datasets/cpython/Doc/library/decimal.rst | unknown | 7faf20f8-9cc8-43f8-9c7b-724dffea11bf | 46,358 | supabase-export-v2 | d4abcad01217f213 | As shown above, the :func:`getcontext` function accesses the current context and allows the settings to be changed. This approach meets the needs of most applications.
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:... | trusted_official_docs | CPython Docs | As shown above, the :func:`getcontext` function accesses the current context and allows the settings to be changed. This approach meets the needs of most applications.
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:... | As shown above, the :func:`getcontext` function accesses the current context and allows the settings to be changed. This approach meets the needs of most applications.
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:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.