J
Jeremy Moles
I think you answered your own question.
x = 0.12345678
y = "%.4f something here" % x
x = 0.12345678
y = "%.4f something here" % x
Tuvas said: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 converting the number to a string? Thanks!
I would like to limit a floating variable to 4 signifigant digits, when
running thorugh a str command.
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 converting the number to a string?
Tuvas said: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 converting the number to a string? Thanks!
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?
Grant said:Sorry, that's not possible.
Technically, it is.
Tuvas said: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
Tuvas said: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 converting the number to a string? Thanks!
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.