pydicom.valuerep.DSdecimal¶
-
class
pydicom.valuerep.DSdecimal(val)[source]¶ Store value for an element with VR ‘DS’ as
decimal.Decimal.Notes
If constructed from an empty string, returns the empty string, not an instance of this class.
-
__init__(val)[source]¶ Store the original string if one given, for exact write-out of same value later. E.g. if set
'1.23e2',Decimalwould write'123', butDSwill use the original.
Methods
__init__(val)Store the original string if one given, for exact write-out of same value later.
adjustedReturn the adjusted exponent of the number.
as_integer_ratio()Return a pair of integers, whose ratio is exactly equal to the original Decimal and with a positive denominator.
as_tupleReturn a tuple representation of the number.
canonicalReturn the canonical encoding of the argument.
compareCompare self to other.
compare_signalIdentical to compare, except that all NaNs signal.
compare_totalCompare two operands using their abstract representation rather than their numerical value.
compare_total_magCompare two operands using their abstract representation rather than their value as in compare_total(), but ignoring the sign of each operand.
conjugateReturn self.
copy_absReturn the absolute value of the argument.
copy_negateReturn the negation of the argument.
copy_signReturn a copy of the first operand with the sign set to be the same as the sign of the second operand.
expReturn the value of the (natural) exponential function e**x at the given number.
fmaFused multiply-add.
from_floatClass method that converts a float to a decimal number, exactly.
is_canonicalReturn True if the argument is canonical and False otherwise.
is_finiteReturn True if the argument is a finite number, and False if the argument is infinite or a NaN.
is_infiniteReturn True if the argument is either positive or negative infinity and False otherwise.
is_nanReturn True if the argument is a (quiet or signaling) NaN and False otherwise.
is_normalReturn True if the argument is a normal finite non-zero number with an adjusted exponent greater than or equal to Emin.
is_qnanReturn True if the argument is a quiet NaN, and False otherwise.
is_signedReturn True if the argument has a negative sign and False otherwise.
is_snanReturn True if the argument is a signaling NaN and False otherwise.
is_subnormalReturn True if the argument is subnormal, and False otherwise.
is_zeroReturn True if the argument is a (positive or negative) zero and False otherwise.
lnReturn the natural (base e) logarithm of the operand.
log10Return the base ten logarithm of the operand.
logbFor a non-zero number, return the adjusted exponent of the operand as a Decimal instance.
logical_andReturn the digit-wise ‘and’ of the two (logical) operands.
logical_invertReturn the digit-wise inversion of the (logical) operand.
logical_orReturn the digit-wise ‘or’ of the two (logical) operands.
logical_xorReturn the digit-wise ‘exclusive or’ of the two (logical) operands.
maxMaximum of self and other.
max_magSimilar to the max() method, but the comparison is done using the absolute values of the operands.
minMinimum of self and other.
min_magSimilar to the min() method, but the comparison is done using the absolute values of the operands.
next_minusReturn the largest number representable in the given context (or in the current default context if no context is given) that is smaller than the given operand.
next_plusReturn the smallest number representable in the given context (or in the current default context if no context is given) that is larger than the given operand.
next_towardIf the two operands are unequal, return the number closest to the first operand in the direction of the second operand.
normalizeNormalize the number by stripping the rightmost trailing zeros and converting any result equal to Decimal(‘0’) to Decimal(‘0e0’).
number_classReturn a string describing the class of the operand.
quantizeReturn a value equal to the first operand after rounding and having the exponent of the second operand.
radixReturn Decimal(10), the radix (base) in which the Decimal class does all its arithmetic.
remainder_nearReturn the remainder from dividing self by other.
rotateReturn the result of rotating the digits of the first operand by an amount specified by the second operand.
same_quantumTest whether self and other have the same exponent or whether both are NaN.
scalebReturn the first operand with the exponent adjusted the second.
shiftReturn the result of shifting the digits of the first operand by an amount specified by the second operand.
sqrtReturn the square root of the argument to full precision.
to_eng_stringConvert to an engineering-type string.
to_integralIdentical to the to_integral_value() method.
to_integral_exactRound to the nearest integer, signaling Inexact or Rounded as appropriate if rounding occurs.
to_integral_valueRound to the nearest integer without signaling Inexact or Rounded.
Attributes
imagoriginal_stringreal-