Open In App

Python | Decimal radix() method

Last Updated : 09 Sep, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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



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
Article Tags :
Practice Tags :