File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -571,9 +571,10 @@ Decimal objects
571
571
>>> Decimal(321 ).exp()
572
572
Decimal('2.561702493119680037517373933E+139')
573
573
574
- .. method :: from_float(f)
574
+ .. classmethod :: from_float(f)
575
575
576
- Classmethod that converts a float to a decimal number, exactly.
576
+ Alternative constructor that only accepts instances of :class: `float ` or
577
+ :class: `int `.
577
578
578
579
Note `Decimal.from_float(0.1) ` is not the same as `Decimal('0.1') `.
579
580
Since 0.1 is not exactly representable in binary floating point, the
Original file line number Diff line number Diff line change @@ -105,10 +105,10 @@ another rational number, or from a string.
105
105
106
106
.. versionadded :: 3.8
107
107
108
- .. method :: from_float(flt)
108
+ .. classmethod :: from_float(flt)
109
109
110
- This class method constructs a :class: ` Fraction ` representing the exact
111
- value of * flt *, which must be a :class: `float `. Beware that
110
+ Alternative constructor which only accepts instances of
111
+ :class: ` float ` or :class: `numbers.Integral `. Beware that
112
112
``Fraction.from_float(0.3) `` is not the same value as ``Fraction(3, 10) ``.
113
113
114
114
.. note ::
@@ -117,10 +117,10 @@ another rational number, or from a string.
117
117
:class: `Fraction ` instance directly from a :class: `float `.
118
118
119
119
120
- .. method :: from_decimal(dec)
120
+ .. classmethod :: from_decimal(dec)
121
121
122
- This class method constructs a :class: ` Fraction ` representing the exact
123
- value of * dec *, which must be a :class: `decimal.Decimal ` instance .
122
+ Alternative constructor which only accepts instances of
123
+ :class: `decimal.Decimal ` or :class: ` numbers.Integral ` .
124
124
125
125
.. note ::
126
126
You can’t perform that action at this time.
0 commit comments