Am 03.05.2015 um 10:48 schrieb Ben Finney:
> That's not as clear as it could be. Better is to be explicit about
> choosing “exponential” format::
>
> >>> foo = 5.223701009526849e-05
> >>> "{foo:5.0e}".format(foo=foo)
> '5e-05'
>
Or even better the "general" format, which also works f
On 05/03/2015 05:22 AM, Cecil Westerhof wrote:
Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney:
Cecil Westerhof writes:
When I have a value like 5.223701009526849e-05 in most cases I am
not interested in all the digest after the dot.
What type of value is it?
If the absolute value is
On Sun, May 3, 2015 at 8:02 PM, Cecil Westerhof wrote:
>>> If the absolute value is bigger as 0 and smaller as 1, it should be
>>> a float. ;-)
>>
>> Or maybe a fractions.Fraction, or a decimal.Decimal, or a complex,
>> or maybe a RXSTRING or a Gmp.mpf! There's more than one way to store
>> a numb
Op Sunday 3 May 2015 11:51 CEST schreef Chris Angelico:
> On Sun, May 3, 2015 at 7:22 PM, Cecil Westerhof wrote:
>> Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney:
>>
>>> Cecil Westerhof writes:
>>>
When I have a value like 5.223701009526849e-05 in most cases I am
not interested in
On Sun, May 3, 2015 at 7:22 PM, Cecil Westerhof wrote:
> Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney:
>
>> Cecil Westerhof writes:
>>
>>> When I have a value like 5.223701009526849e-05 in most cases I am
>>> not interested in all the digest after the dot.
>>
>> What type of value is it?
>
Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney:
> Cecil Westerhof writes:
>
>> When I have a value like 5.223701009526849e-05 in most cases I am
>> not interested in all the digest after the dot.
>
> What type of value is it?
If the absolute value is bigger as 0 and smaller as 1, it should b
Ben Finney writes:
> Assuming we're talking about a ‘float’ value::
>
> >>> foo = 5.223701009526849e-05
> >>> "{foo:5.1}".format(foo=foo)
> '5e-05'
That's not as clear as it could be. Better is to be explicit about
choosing “exponential” format::
>>> foo = 5.223701009526849e-05
Cecil Westerhof writes:
> When I have a value like 5.223701009526849e-05 in most cases I am not
> interested in all the digest after the dot.
What type of value is it?
A ‘float’ value has many different textual representations, most of them
inaccurate. So talking about the digits of a ‘float’ v
When I have a value like 5.223701009526849e-05 in most cases I am not
interested in all the digest after the dot. Is there a simple way to
convert it to a string like '5e-05'?
I could do something like:
def format_small_number(n):
abs_n = abs(n)
assert (abs_n < 1) and (abs_n > 0