"Tuvas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I would like to limit a floating variable to 4 signifigant digits, when
> running thorugh a str command. Ei,
>
>
> x=.13241414515
> y=str(x)+" something here"
>
> But somehow limiting that to 4 sign. digits. I know that if you us
Tuvas wrote:
> Wait, one more question. If the number is something like:
>
> 1.32042
>
> It is like
> "1.32 stuff"
>
> I would like it's size to remain constant. Any way around this?
s/%g/%f
>>> print "%.4f stuff" % 1.3241414515
1.3241 stuff
>>> print "%.4f stuff" % 1.32042
1.3204 stuff
>>>
On 2005-11-10, Dan Bishop <[EMAIL PROTECTED]> wrote:
> Grant Edwards wrote:
>> On 2005-11-09, Tuvas <[EMAIL PROTECTED]> wrote:
>>
>> > I would like to limit a floating variable to 4 signifigant digits, when
>> > running thorugh a str command.
>>
>> Sorry, that's not possible.
>
> Technically, it is
Grant Edwards wrote:
> On 2005-11-09, Tuvas <[EMAIL PROTECTED]> wrote:
>
> > I would like to limit a floating variable to 4 signifigant digits, when
> > running thorugh a str command.
>
> Sorry, that's not possible.
Technically, it is.
>>> class Float4(float):
...def __str__(self):
...
On 2005-11-09, Tuvas <[EMAIL PROTECTED]> wrote:
> Wait, one more question. If the number is something like:
>
> 1.32042
>
> It is like
> "1.32 stuff"
>
> I would like it's size to remain constant. Any way around this?
http://www.python.org/doc/current/lib/typesseq-strings.html#l2h-211
--
Grant E
"Tuvas" <[EMAIL PROTECTED]> wrote:
>I would like to limit a floating variable to 4 signifigant digits, when
> running thorugh a str command. Ei,
>
> x=.13241414515
> y=str(x)+" something here"
>
> But somehow limiting that to 4 sign. digits. I know that if you use the
> print statement, you can do
Wait, one more question. If the number is something like:
1.32042
It is like
"1.32 stuff"
I would like it's size to remain constant. Any way around this?
--
http://mail.python.org/mailman/listinfo/python-list
On 2005-11-09, Tuvas <[EMAIL PROTECTED]> wrote:
> I would like to limit a floating variable to 4 signifigant digits, when
> running thorugh a str command.
Sorry, that's not possible.
> x=.13241414515
> y=str(x)+" something here"
>
> But somehow limiting that to 4 sign. digits. I know that if
> y
Yep, I was thinking in C, not python. Thanks for the help!
--
http://mail.python.org/mailman/listinfo/python-list
I think you answered your own question. :)
x = 0.12345678
y = "%.4f something here" % x
On Wed, 2005-11-09 at 11:52 -0800, Tuvas wrote:
> I would like to limit a floating variable to 4 signifigant digits, when
> running thorugh a str command. Ei,
>
>
> x=.13241414515
> y=str(x)+" something here
Tuvas wrote:
> I would like to limit a floating variable to 4 signifigant digits, when
> running thorugh a str command. Ei,
>
>
> x=.13241414515
> y=str(x)+" something here"
>
> But somehow limiting that to 4 sign. digits. I know that if you use the
> print statement, you can do something like %
I would like to limit a floating variable to 4 signifigant digits, when
running thorugh a str command. Ei,
x=.13241414515
y=str(x)+" something here"
But somehow limiting that to 4 sign. digits. I know that if you use the
print statement, you can do something like %.4d, but how can I do this
with
12 matches
Mail list logo