Open In App

Python | Decimal radix() method

Last Updated : 09 Sep, 2019
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Decimal#radix() : radix() is a Decimal class method which returns the radix value 10, as this is Decimal.

Syntax: Decimal.radix()

Parameter: Decimal values

Return: the radix value 10, as this is Decimal.

Code #1 : Example for radix() method




# Python Program explaining 
# radix() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal(-1)
  
b = Decimal('0.142857')
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.radix() method
print ("\n\nDecimal a with radix() method : ", a.radix())
  
print ("Decimal b with radix() method : ", b.radix())


Output :

Decimal value a :  -1
Decimal value b :  0.142857


Decimal a with radix() method :  10
Decimal b with radix() method :  10

Code #2 : Example for radix() method




# Python Program explaining 
# radix() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal('-3.14545454')
  
b = Decimal('321e + 5')
  
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.radix() method
print ("\n\nDecimal a with radix() method : ", a.radix())
  
print ("Decimal b with radix() method : ", b.radix())


Output :

Decimal value a :  -3.14545454
Decimal value b :  3.21E+7


Decimal a with radix() method :  10
Decimal b with radix() method :  10



Next Article

Similar Reads

Python | Decimal compare() method
Decimal#compare() : compare() is a Decimal class method which compares the two Decimal values. Syntax: Decimal.compare() Parameter: Decimal values Return: 1 - if a > b -1 - if a < b 0 - if a = b Code #1 : Example for compare() method # Python Program explaining # compare() method # loading decimal library from decimal import * # Initializing
2 min read
Python | Decimal is_subnormal() method
Decimal#is_subnormal() : is_subnormal() is a Decimal class method which checks whether the Decimal value is subnormal. Syntax: Decimal.is_subnormal() Parameter: Decimal values Return: true - if the Decimal value is subnormal otherwise false Code #1 : Example for is_subnormal() method # Python Program explaining # is_subnormal() method # loading dec
2 min read
Python | Decimal logb() method
Decimal#logb() : logb() is a Decimal class method which returns the adjusted exponent of the Decimal value. Syntax: Decimal.logb() Parameter: Decimal values Return: the adjusted exponent of the Decimal value. Code #1 : Example for logb() method # Python Program explaining # logb() method # loading decimal library from decimal import * # Initializin
2 min read
Python | Decimal conjugate() method
Decimal#conjugate() : conjugate() is a Decimal class method which returns the self, this method is only to comply with the Decimal Specification Syntax: Decimal.conjugate() Parameter: Decimal values Return: the self Decimal value Code #1 : Example for conjugate() method # Python Program explaining # conjugate() method # loading decimal library from
2 min read
Python | Decimal copy_sign() method
Decimal#copy_sign() : copy_sign() is a Decimal class method which returns the copy of the first Decimal value with the sign set to be the same as the sign of the second Decimal value. Syntax: Decimal.copy_sign() Parameter: Decimal values Return: the copy of the first Decimal value with the sign set to be the same as the sign of the second Decimal v
2 min read
Python | Decimal compare_total() method
Decimal#compare_total() : compare_total() is a Decimal class method which compares the two Decimal values using their abstract representation rather than their numerical value. Syntax: Decimal.compare_total() Parameter: Decimal values Return: 1 - if a > b -1 - if a < b 0 - if a = b Code #1 : Example for compare_total() method # Python Program
2 min read
Python | Decimal compare_total_mag() method
Decimal#compare_total_mag() : compare_total_mag() is a Decimal class method which compares the two Decimal values by using their abstract representation rather than their value, but ignoring the sign of each operand. Syntax: Decimal.compare_total_mag() Parameter: Decimal values Return: 1 - if a > b -1 - if a < b 0 - if a = b Code #1 : Example
2 min read
Python | Decimal is_signed() method
Decimal#is_signed() : is_signed() is a Decimal class method which checks whether the sign of Decimal value is negative Syntax: Decimal.is_signed() Parameter: Decimal values Return: true - if the sign of Decimal value is negative; otherwise false Code #1 : Example for is_signed() method # Python Program explaining # is_signed() method # loading deci
2 min read
Python | Decimal is_normal() method
Decimal#is_normal() : is_normal() is a Decimal class method which checks whether the Decimal value is a normal finite number. Syntax: Decimal.is_normal() Parameter: Decimal values Return: true - if the Decimal value is a normal finite number; otherwise false Code #1 : Example for is_normal() method # Python Program explaining # is_normal() method #
2 min read
Python | Decimal adjusted() method
Decimal#adjusted() : adjusted() is a Decimal class method which returns the adjusted exponent after shifting out the coefficient’s rightmost digits until only the lead digit remains Syntax: Decimal.adjusted() Parameter: Decimal values Return: the adjusted exponent after shifting out the coefficient’s rightmost digits until only the lead digit remai
2 min read
Python | Decimal as_integer_ratio() method
Decimal#as_integer_ratio() : as_integer_ratio() is a Decimal class method which returns the exponent after shifting out the coefficient’s rightmost digits until only the lead digit remains : as a pair (n, d) Syntax: Decimal.as_integer_ratio() Parameter: Decimal values Return: the exponent after shifting out the coefficient’s rightmost digits until
2 min read
Python | Decimal is_qnan() method
Decimal#is_qnan() : is_qnan() is a Decimal class method which checks whether the Decimal value is quite NaN value. Syntax: Decimal.is_qnan() Parameter: Decimal values Return: true - if the Decimal value is quite NaN value; otherwise false Code #1 : Example for is_qnan() method # Python Program explaining # is_qnan() method # loading decimal library
2 min read
Python | Decimal as_tuple() method
Decimal#as_tuple() : as_tuple() is a Decimal class method which returns named tuple representation of the Decimal value. Syntax: Decimal.as_tuple() Parameter: Decimal values Return: tuple with values - sign - digits - exponent Code #1 : Example for as_tuple() method # Python Program explaining # as_tuple() method # loading decimal library from deci
2 min read
Python | Decimal compare_signal() method
Decimal#compare_signal() : compare_signal() is a Decimal class method which compares th two Decimal values, except for the NaN values. Syntax: Decimal.compare_signal()Parameter: Decimal valuesReturn: 1 - if a > b -1 - if a < b 0 - if a = b Code #1 : Example for compare_signal() method C/C++ Code # Python Program explaining # compare_signal()
2 min read
Python | Decimal canonical() method
Decimal#canonical() : canonical() is a Decimal class method which returns the canonical encoding of the Decimal value. Syntax: Decimal.canonical() Parameter: Decimal values Return: the canonical encoding of the Decimal value. Code #1 : Example for canonical() method # Python Program explaining # canonical() method # loading decimal library from dec
2 min read
Python | Decimal is_nan() method
Decimal#is_nan() : is_nan() is a Decimal class method which checks whether the Decimal value is NaN value. Syntax: Decimal.is_nan() Parameter: Decimal values Return: true - if the Decimal value is NaN value; otherwise false Code #1 : Example for is_nan() method # Python Program explaining # is_nan() method # loading decimal library from decimal imp
2 min read
Python | Decimal is_infinite() method
Decimal#is_infinite() : is_infinite() is a Decimal class method which checks whether the Decimal value is infinite value. Syntax: Decimal.is_infinite() Parameter: Decimal values Return: true - if the Decimal value is infinite value; otherwise false Code #1 : Example for is_infinite() method # Python Program explaining # is_infinite() method # loadi
2 min read
Python | Decimal is_finite() method
Decimal#is_finite() : is_finite() is a Decimal class method which checks whether the Decimal value is finite value. Syntax: Decimal.is_finite() Parameter: Decimal values Return: true - if the Decimal value is finite value; otherwise false Code #1 : Example for is_finite() method # Python Program explaining # is_finite() method # loading decimal lib
2 min read
Python | Decimal logical_invert() method
Decimal#logical_invert() : logical_invert() is a Decimal class method which returns the digit-wise inversion of the Decimal values. Syntax: Decimal.logical_invert() Parameter: Decimal values Return: the digit-wise inversion of the Decimal values. Code #1 : Example for logical_invert() method # Python Program explaining # logical_invert() method # l
2 min read
Python | Decimal logical_xor() method
Decimal#logical_xor() : logical_xor() is a Decimal class method which returns the digit-wise exclusive or of the two Decimal values. Syntax: Decimal.logical_xor() Parameter: Decimal values Return: the digit-wise and of the two (logical) Decimal values. Code #1 : Example for logical_xor() method # Python Program explaining # logical_xor() method # l
2 min read
Python | Decimal is_canonical() method
Decimal#is_canonical() : is_canonical() is a Decimal class method which checks whether the Decimal value is canonical. Syntax: Decimal.is_canonical() Parameter: Decimal values Return: true - if the Decimal value is canonical; otherwise false Code #1 : Example for is_canonical() method # Python Program explaining # is_canonical() method # loading de
2 min read
Python | Decimal from_float() method
Decimal#from_float() : from_float() is a Decimal class method which converts a float to a decimal number, exactly. Syntax: Decimal.from_float() Parameter: Decimal values Return: converts a float to a decimal number, exactly. Code #1 : Example for from_float() method C/C++ Code # Python Program explaining # from_float() method # loading decimal libr
2 min read
Python | Decimal copy_negate() method
Decimal#copy_negate() : copy_negate() is a Decimal class method which returns the negation of Decimal value. Syntax: Decimal.copy_negate() Parameter: Decimal values Return: the negation of Decimal value Code #1 : Example for copy_negate() method # Python Program explaining # copy_negate() method # loading decimal library from decimal import * # Ini
2 min read
Python | Decimal exp() method
Decimal#exp() : exp() is a Decimal class method which returns the value of the (natural) exponential function e**x at the given number Syntax: Decimal.exp() Parameter: Decimal values Return: the value of the (natural) exponential function e**x at the given number Code #1 : Example for exp() method # Python Program explaining # exp() method # loadin
2 min read
Python | Decimal copy_abs() method
Decimal#copy_abs() : copy_abs() is a Decimal class method which returns the absolute Decimal value. Syntax: Decimal.copy_abs() Parameter: Decimal values Return: the absolute Decimal value Code #1 : Example for copy_abs() method # Python Program explaining # copy_abs() method # loading decimal library from decimal import * # Initializing a decimal v
2 min read
Python | Decimal is_snan() method
Decimal#is_snan() : is_snan() is a Decimal class method which checks whether the Decimal value is a signaling NaN Syntax: Decimal.is_snan() Parameter: Decimal values Return: true - if the Decimal value is a signaling NaN; otherwise false Code #1 : Example for is_snan() method # Python Program explaining # is_snan() method # loading decimal library
2 min read
Python | Decimal logical_or() method
Decimal#logical_or() : logical_or() is a Decimal class method which returns the digit-wise or of the two Decimal values. Syntax: Decimal.logical_or() Parameter: Decimal values Return: the digit-wise or of the two (logical) of the Decimal values. Code #1 : Example for logical_or() method # Python Program explaining # logical_or() method # loading de
2 min read
Python | Decimal logical_and() method
Decimal#logical_and() : logical_and() is a Decimal class method which returns the digit-wise and of the two (logical) Decimal values. Syntax: Decimal.logical_and() Parameter: Decimal values Return: the digit-wise and of the two (logical) Decimal values. Code #1 : Example for logical_and() method # Python Program explaining # logical_and() method #
2 min read
Python | Decimal log10() method
Decimal#log10() : log10() is a Decimal class method which returns the base ten logarithm of the Decimal value. Syntax: Decimal.log10() Parameter: Decimal values Return: the base ten logarithm of the Decimal value. Code #1 : Example for log10() method # Python Program explaining # log10() method # loading decimal library from decimal import * # Init
2 min read
Python | Decimal ln() method
Decimal#ln() : ln() is a Decimal class method which returns the natural (base e) logarithm of the Decimal value. Syntax: Decimal.ln() Parameter: Decimal values Return: the natural (base e) logarithm of the Decimal value. Code #1 : Example for ln() method # Python Program explaining # ln() method # loading decimal library from decimal import * # Ini
2 min read
Article Tags :
Practice Tags :
  翻译: