Get precise decimal string representation of Python Decimal?
If I've got a Python Decimal
, how can I reliably get the precise decimal string (ie, not scientific notation) representation of the number without trailing zeros?
For example, if I have:
>>> d = Decimal('1e-14')
I would like:
>>> get_decimal_string(d)
'0.00000000000001'
However:
- The
Decimal
class doesn't have anyto_decimal_string
method, or even anyto_radix_string(radix)
(cf: https://docs.python.org/3/library/decimal.html#decimal.Context.to_eng_string) - The
%f
formatter either defaults to rounding to 6 decimal places -'%f' %(d, ) ==> '0.000000'
- or requires a precise number of decimal places. - The
{:f}.format(...)
formatter appears to work -'{:f}'.format(d)
- however I'm reluctant to trust that, as this actually runs counter to the documentation, which says "
==> '0.00000000000001''f'
… Displays the number as a fixed-point number. The default precision is 6"
Decimal.__repr__
andDecimal.__str__
sometimes return scientific notation:repr(d) ==> "Decimal('1E-14')"
So, is there any way to get a decimal string from a Python Decimal
? Or do I need to roll my own using Decimal.as_tuple()
?
python decimal
add a comment |
If I've got a Python Decimal
, how can I reliably get the precise decimal string (ie, not scientific notation) representation of the number without trailing zeros?
For example, if I have:
>>> d = Decimal('1e-14')
I would like:
>>> get_decimal_string(d)
'0.00000000000001'
However:
- The
Decimal
class doesn't have anyto_decimal_string
method, or even anyto_radix_string(radix)
(cf: https://docs.python.org/3/library/decimal.html#decimal.Context.to_eng_string) - The
%f
formatter either defaults to rounding to 6 decimal places -'%f' %(d, ) ==> '0.000000'
- or requires a precise number of decimal places. - The
{:f}.format(...)
formatter appears to work -'{:f}'.format(d)
- however I'm reluctant to trust that, as this actually runs counter to the documentation, which says "
==> '0.00000000000001''f'
… Displays the number as a fixed-point number. The default precision is 6"
Decimal.__repr__
andDecimal.__str__
sometimes return scientific notation:repr(d) ==> "Decimal('1E-14')"
So, is there any way to get a decimal string from a Python Decimal
? Or do I need to roll my own using Decimal.as_tuple()
?
python decimal
add a comment |
If I've got a Python Decimal
, how can I reliably get the precise decimal string (ie, not scientific notation) representation of the number without trailing zeros?
For example, if I have:
>>> d = Decimal('1e-14')
I would like:
>>> get_decimal_string(d)
'0.00000000000001'
However:
- The
Decimal
class doesn't have anyto_decimal_string
method, or even anyto_radix_string(radix)
(cf: https://docs.python.org/3/library/decimal.html#decimal.Context.to_eng_string) - The
%f
formatter either defaults to rounding to 6 decimal places -'%f' %(d, ) ==> '0.000000'
- or requires a precise number of decimal places. - The
{:f}.format(...)
formatter appears to work -'{:f}'.format(d)
- however I'm reluctant to trust that, as this actually runs counter to the documentation, which says "
==> '0.00000000000001''f'
… Displays the number as a fixed-point number. The default precision is 6"
Decimal.__repr__
andDecimal.__str__
sometimes return scientific notation:repr(d) ==> "Decimal('1E-14')"
So, is there any way to get a decimal string from a Python Decimal
? Or do I need to roll my own using Decimal.as_tuple()
?
python decimal
If I've got a Python Decimal
, how can I reliably get the precise decimal string (ie, not scientific notation) representation of the number without trailing zeros?
For example, if I have:
>>> d = Decimal('1e-14')
I would like:
>>> get_decimal_string(d)
'0.00000000000001'
However:
- The
Decimal
class doesn't have anyto_decimal_string
method, or even anyto_radix_string(radix)
(cf: https://docs.python.org/3/library/decimal.html#decimal.Context.to_eng_string) - The
%f
formatter either defaults to rounding to 6 decimal places -'%f' %(d, ) ==> '0.000000'
- or requires a precise number of decimal places. - The
{:f}.format(...)
formatter appears to work -'{:f}'.format(d)
- however I'm reluctant to trust that, as this actually runs counter to the documentation, which says "
==> '0.00000000000001''f'
… Displays the number as a fixed-point number. The default precision is 6"
Decimal.__repr__
andDecimal.__str__
sometimes return scientific notation:repr(d) ==> "Decimal('1E-14')"
So, is there any way to get a decimal string from a Python Decimal
? Or do I need to roll my own using Decimal.as_tuple()
?
python decimal
python decimal
asked Jan 2 at 21:48
David WoleverDavid Wolever
77.2k60264426
77.2k60264426
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Short answer:
>>> d
Decimal('1E-14')
>>> '{:f}'.format(d)
'0.00000000000001'
Long answer:
As @BrandonRhodes pointed out PEP 3101 (which is the string format PEP) states:
The syntax for format specifiers is open-ended, since a class can
override the standard format specifiers. In such cases, the
str.format() method merely passes all of the characters between the
first colon and the matching brace to the relevant underlying
formatting method.
And thus, the Decimal.__format__
method is what python's string format will utilize to generate the str
representation of the Decimal
value. Basically Decimal
overrides the formatting to be "smart" but will default to whatever values the format string sets (ie {:.4f}
will truncate the decimal to 4 places).
Here's why you can trust it (snippet from decimal.py:Decimal.__format__
):
# PEP 3101 support. the _localeconv keyword argument should be
# considered private: it's provided for ease of testing only.
def __format__(self, specifier, context=None, _localeconv=None):
#
# ...implementation snipped.
#
# figure out placement of the decimal point
leftdigits = self._exp + len(self._int)
if spec['type'] in 'eE':
if not self and precision is not None:
dotplace = 1 - precision
else:
dotplace = 1
elif spec['type'] in 'fF%':
dotplace = leftdigits
elif spec['type'] in 'gG':
if self._exp <= 0 and leftdigits > -6:
dotplace = leftdigits
else:
dotplace = 1
# find digits before and after decimal point, and get exponent
if dotplace < 0:
intpart = '0'
fracpart = '0'*(-dotplace) + self._int
elif dotplace > len(self._int):
intpart = self._int + '0'*(dotplace-len(self._int))
fracpart = ''
else:
intpart = self._int[:dotplace] or '0'
fracpart = self._int[dotplace:]
exp = leftdigits-dotplace
# done with the decimal-specific stuff; hand over the rest
# of the formatting to the _format_number function
return _format_number(self._sign, intpart, fracpart, exp, spec)
Long story short, the Decimal.__format__
method will calculate the necessary padding to represent the number before and after the decimal based upon exponentiation provided from Decimal._exp
(in your example, 14 significant digits).
>>> d._exp
-14
The documentation you quoted only deals with the internal representation, not whatformat
is going to produce.
– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what thestring.format
documentation says about the behavior of'f'
, so I'm reluctant to trust it.
– David Wolever
Jan 2 at 22:22
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of theDecimal.__format__
methods implementation.
– Julian
Jan 2 at 22:25
1
Remember thatstring.format
has no control over what format operators actually do any more — it's now deferred to__format__()
methods.
– Brandon Rhodes
Jan 3 at 0:17
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013614%2fget-precise-decimal-string-representation-of-python-decimal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Short answer:
>>> d
Decimal('1E-14')
>>> '{:f}'.format(d)
'0.00000000000001'
Long answer:
As @BrandonRhodes pointed out PEP 3101 (which is the string format PEP) states:
The syntax for format specifiers is open-ended, since a class can
override the standard format specifiers. In such cases, the
str.format() method merely passes all of the characters between the
first colon and the matching brace to the relevant underlying
formatting method.
And thus, the Decimal.__format__
method is what python's string format will utilize to generate the str
representation of the Decimal
value. Basically Decimal
overrides the formatting to be "smart" but will default to whatever values the format string sets (ie {:.4f}
will truncate the decimal to 4 places).
Here's why you can trust it (snippet from decimal.py:Decimal.__format__
):
# PEP 3101 support. the _localeconv keyword argument should be
# considered private: it's provided for ease of testing only.
def __format__(self, specifier, context=None, _localeconv=None):
#
# ...implementation snipped.
#
# figure out placement of the decimal point
leftdigits = self._exp + len(self._int)
if spec['type'] in 'eE':
if not self and precision is not None:
dotplace = 1 - precision
else:
dotplace = 1
elif spec['type'] in 'fF%':
dotplace = leftdigits
elif spec['type'] in 'gG':
if self._exp <= 0 and leftdigits > -6:
dotplace = leftdigits
else:
dotplace = 1
# find digits before and after decimal point, and get exponent
if dotplace < 0:
intpart = '0'
fracpart = '0'*(-dotplace) + self._int
elif dotplace > len(self._int):
intpart = self._int + '0'*(dotplace-len(self._int))
fracpart = ''
else:
intpart = self._int[:dotplace] or '0'
fracpart = self._int[dotplace:]
exp = leftdigits-dotplace
# done with the decimal-specific stuff; hand over the rest
# of the formatting to the _format_number function
return _format_number(self._sign, intpart, fracpart, exp, spec)
Long story short, the Decimal.__format__
method will calculate the necessary padding to represent the number before and after the decimal based upon exponentiation provided from Decimal._exp
(in your example, 14 significant digits).
>>> d._exp
-14
The documentation you quoted only deals with the internal representation, not whatformat
is going to produce.
– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what thestring.format
documentation says about the behavior of'f'
, so I'm reluctant to trust it.
– David Wolever
Jan 2 at 22:22
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of theDecimal.__format__
methods implementation.
– Julian
Jan 2 at 22:25
1
Remember thatstring.format
has no control over what format operators actually do any more — it's now deferred to__format__()
methods.
– Brandon Rhodes
Jan 3 at 0:17
|
show 2 more comments
Short answer:
>>> d
Decimal('1E-14')
>>> '{:f}'.format(d)
'0.00000000000001'
Long answer:
As @BrandonRhodes pointed out PEP 3101 (which is the string format PEP) states:
The syntax for format specifiers is open-ended, since a class can
override the standard format specifiers. In such cases, the
str.format() method merely passes all of the characters between the
first colon and the matching brace to the relevant underlying
formatting method.
And thus, the Decimal.__format__
method is what python's string format will utilize to generate the str
representation of the Decimal
value. Basically Decimal
overrides the formatting to be "smart" but will default to whatever values the format string sets (ie {:.4f}
will truncate the decimal to 4 places).
Here's why you can trust it (snippet from decimal.py:Decimal.__format__
):
# PEP 3101 support. the _localeconv keyword argument should be
# considered private: it's provided for ease of testing only.
def __format__(self, specifier, context=None, _localeconv=None):
#
# ...implementation snipped.
#
# figure out placement of the decimal point
leftdigits = self._exp + len(self._int)
if spec['type'] in 'eE':
if not self and precision is not None:
dotplace = 1 - precision
else:
dotplace = 1
elif spec['type'] in 'fF%':
dotplace = leftdigits
elif spec['type'] in 'gG':
if self._exp <= 0 and leftdigits > -6:
dotplace = leftdigits
else:
dotplace = 1
# find digits before and after decimal point, and get exponent
if dotplace < 0:
intpart = '0'
fracpart = '0'*(-dotplace) + self._int
elif dotplace > len(self._int):
intpart = self._int + '0'*(dotplace-len(self._int))
fracpart = ''
else:
intpart = self._int[:dotplace] or '0'
fracpart = self._int[dotplace:]
exp = leftdigits-dotplace
# done with the decimal-specific stuff; hand over the rest
# of the formatting to the _format_number function
return _format_number(self._sign, intpart, fracpart, exp, spec)
Long story short, the Decimal.__format__
method will calculate the necessary padding to represent the number before and after the decimal based upon exponentiation provided from Decimal._exp
(in your example, 14 significant digits).
>>> d._exp
-14
The documentation you quoted only deals with the internal representation, not whatformat
is going to produce.
– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what thestring.format
documentation says about the behavior of'f'
, so I'm reluctant to trust it.
– David Wolever
Jan 2 at 22:22
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of theDecimal.__format__
methods implementation.
– Julian
Jan 2 at 22:25
1
Remember thatstring.format
has no control over what format operators actually do any more — it's now deferred to__format__()
methods.
– Brandon Rhodes
Jan 3 at 0:17
|
show 2 more comments
Short answer:
>>> d
Decimal('1E-14')
>>> '{:f}'.format(d)
'0.00000000000001'
Long answer:
As @BrandonRhodes pointed out PEP 3101 (which is the string format PEP) states:
The syntax for format specifiers is open-ended, since a class can
override the standard format specifiers. In such cases, the
str.format() method merely passes all of the characters between the
first colon and the matching brace to the relevant underlying
formatting method.
And thus, the Decimal.__format__
method is what python's string format will utilize to generate the str
representation of the Decimal
value. Basically Decimal
overrides the formatting to be "smart" but will default to whatever values the format string sets (ie {:.4f}
will truncate the decimal to 4 places).
Here's why you can trust it (snippet from decimal.py:Decimal.__format__
):
# PEP 3101 support. the _localeconv keyword argument should be
# considered private: it's provided for ease of testing only.
def __format__(self, specifier, context=None, _localeconv=None):
#
# ...implementation snipped.
#
# figure out placement of the decimal point
leftdigits = self._exp + len(self._int)
if spec['type'] in 'eE':
if not self and precision is not None:
dotplace = 1 - precision
else:
dotplace = 1
elif spec['type'] in 'fF%':
dotplace = leftdigits
elif spec['type'] in 'gG':
if self._exp <= 0 and leftdigits > -6:
dotplace = leftdigits
else:
dotplace = 1
# find digits before and after decimal point, and get exponent
if dotplace < 0:
intpart = '0'
fracpart = '0'*(-dotplace) + self._int
elif dotplace > len(self._int):
intpart = self._int + '0'*(dotplace-len(self._int))
fracpart = ''
else:
intpart = self._int[:dotplace] or '0'
fracpart = self._int[dotplace:]
exp = leftdigits-dotplace
# done with the decimal-specific stuff; hand over the rest
# of the formatting to the _format_number function
return _format_number(self._sign, intpart, fracpart, exp, spec)
Long story short, the Decimal.__format__
method will calculate the necessary padding to represent the number before and after the decimal based upon exponentiation provided from Decimal._exp
(in your example, 14 significant digits).
>>> d._exp
-14
Short answer:
>>> d
Decimal('1E-14')
>>> '{:f}'.format(d)
'0.00000000000001'
Long answer:
As @BrandonRhodes pointed out PEP 3101 (which is the string format PEP) states:
The syntax for format specifiers is open-ended, since a class can
override the standard format specifiers. In such cases, the
str.format() method merely passes all of the characters between the
first colon and the matching brace to the relevant underlying
formatting method.
And thus, the Decimal.__format__
method is what python's string format will utilize to generate the str
representation of the Decimal
value. Basically Decimal
overrides the formatting to be "smart" but will default to whatever values the format string sets (ie {:.4f}
will truncate the decimal to 4 places).
Here's why you can trust it (snippet from decimal.py:Decimal.__format__
):
# PEP 3101 support. the _localeconv keyword argument should be
# considered private: it's provided for ease of testing only.
def __format__(self, specifier, context=None, _localeconv=None):
#
# ...implementation snipped.
#
# figure out placement of the decimal point
leftdigits = self._exp + len(self._int)
if spec['type'] in 'eE':
if not self and precision is not None:
dotplace = 1 - precision
else:
dotplace = 1
elif spec['type'] in 'fF%':
dotplace = leftdigits
elif spec['type'] in 'gG':
if self._exp <= 0 and leftdigits > -6:
dotplace = leftdigits
else:
dotplace = 1
# find digits before and after decimal point, and get exponent
if dotplace < 0:
intpart = '0'
fracpart = '0'*(-dotplace) + self._int
elif dotplace > len(self._int):
intpart = self._int + '0'*(dotplace-len(self._int))
fracpart = ''
else:
intpart = self._int[:dotplace] or '0'
fracpart = self._int[dotplace:]
exp = leftdigits-dotplace
# done with the decimal-specific stuff; hand over the rest
# of the formatting to the _format_number function
return _format_number(self._sign, intpart, fracpart, exp, spec)
Long story short, the Decimal.__format__
method will calculate the necessary padding to represent the number before and after the decimal based upon exponentiation provided from Decimal._exp
(in your example, 14 significant digits).
>>> d._exp
-14
edited Jan 3 at 18:37
answered Jan 2 at 22:05
JulianJulian
866413
866413
The documentation you quoted only deals with the internal representation, not whatformat
is going to produce.
– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what thestring.format
documentation says about the behavior of'f'
, so I'm reluctant to trust it.
– David Wolever
Jan 2 at 22:22
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of theDecimal.__format__
methods implementation.
– Julian
Jan 2 at 22:25
1
Remember thatstring.format
has no control over what format operators actually do any more — it's now deferred to__format__()
methods.
– Brandon Rhodes
Jan 3 at 0:17
|
show 2 more comments
The documentation you quoted only deals with the internal representation, not whatformat
is going to produce.
– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what thestring.format
documentation says about the behavior of'f'
, so I'm reluctant to trust it.
– David Wolever
Jan 2 at 22:22
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of theDecimal.__format__
methods implementation.
– Julian
Jan 2 at 22:25
1
Remember thatstring.format
has no control over what format operators actually do any more — it's now deferred to__format__()
methods.
– Brandon Rhodes
Jan 3 at 0:17
The documentation you quoted only deals with the internal representation, not what
format
is going to produce.– Mark Ransom
Jan 2 at 22:12
The documentation you quoted only deals with the internal representation, not what
format
is going to produce.– Mark Ransom
Jan 2 at 22:12
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
Right, which is why I said it wasn't clear. It only implies through the examples that the formatting will work as expected. There is no explicit discussion of interaction with string's .format method. I will continue looking, and post if I find anything. Another interesting part of those docs: "Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem:" but this value doesn't seem to affect the string formatting.
– Julian
Jan 2 at 22:13
See my point 3, above: this appears to work, but it contradicts what the
string.format
documentation says about the behavior of 'f'
, so I'm reluctant to trust it.– David Wolever
Jan 2 at 22:22
See my point 3, above: this appears to work, but it contradicts what the
string.format
documentation says about the behavior of 'f'
, so I'm reluctant to trust it.– David Wolever
Jan 2 at 22:22
2
2
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of the
Decimal.__format__
methods implementation.– Julian
Jan 2 at 22:25
When in doubt: use the source, haha. I'll update the answer, but basically you can trust it because of the
Decimal.__format__
methods implementation.– Julian
Jan 2 at 22:25
1
1
Remember that
string.format
has no control over what format operators actually do any more — it's now deferred to __format__()
methods.– Brandon Rhodes
Jan 3 at 0:17
Remember that
string.format
has no control over what format operators actually do any more — it's now deferred to __format__()
methods.– Brandon Rhodes
Jan 3 at 0:17
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013614%2fget-precise-decimal-string-representation-of-python-decimal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown