how transform this “mess”:

2.1437855561458217e-25

in 0.00 ?

something like:

x = 2.1437855561458217e-25

print(x.clean(2)) #>>>> 0.00

:rolleyes:

thanks

how transform this “mess”:

2.1437855561458217e-25

in 0.00 ?

something like:

x = 2.1437855561458217e-25

print(x.clean(2)) #>>>> 0.00

:rolleyes:

thanks

I’ve been wondering this too, like a custom float to x decimal places.

Assuming x == 2.1437855561458217e-25. If you’re doing maths with it you can use round(x, n), where n is the number of digits to round to (by default n=0). If you’re just printing it that you can use formatting: print("%.2f" % x), where the number denotes the amount of decimal places.

yes this make the right work

print("%.2f" % x)

thanks

if I want get the value , this is the right way?

y=float("%.4f"%x)

or there a way to make float->float without using text ?

You could do, but that’s not a pretty solution. Better to use: y = round(x, 4). Or just not bother rounding at all. If you’re not going to see the result then you might as well keep it as accurate as possible - unless you have a good reason for rounding it off.

ah sorry …

I had tried before with “round()” , but with wrong value .(my error)

this work fine , instead

yes, I want just use this for read the value .

thanks!