Python‎ > ‎decimal‎ > ‎

Decimal.logb()


Definition
For a non-zero number, return the adjusted exponent
of the operand as a Decimal instance.

Syntax
Decimal(x).logb()->Decimal(x)

Parameters
x=Decimal value

Examples
The returned as:
 >>> Decimal(1.233).logb()
Decimal('0')
>>> Decimal(-1.11).logb()
Decimal('0')

int(Decimal)
The method computed the int(value) of the decimal and then run loop through range() function.

from decimal import Decimal


a=int(Decimal(1.1).log10()+Decimal(1.233).logb()- Decimal(1.1).log10()%Decimal(.49).sqrt())


for i in range(a,10):
print(i)
print(i/Decimal(1.1).log10())

>>>
0
0E+29
1
24.15885792809678504023429545
2
48.31771585619357008046859090
3
72.47657378429035512070288634
4
96.63543171238714016093718179
5
120.7942896404839252011714772
6
144.9531475685807102414057727
7
169.1120054966774952816400681
8
193.2708634247742803218743636
9
217.4297213528710653621086590
>>>




Comments