[Tutor] Binary Real to Decimal

John Fouhy john at fouhy.net
Mon Mar 30 06:25:37 CEST 2009

2009/3/30 Chris Castillo <ctcast at gmail.com>:
> yeah that function would help but how would I join both sides again to get a
> decimal real(float) to round?
> for example myfloat = decnum1, ".", decnum2 doesn't work because the string
> "." isn't a valid int type. how would I join those to be a float again?

The easiest way would be to convert decnum1 and decnum2 into strings,
join them together, and then call float() on the result.


myfloat = float('%s.%s' % (decnum1, decnum2))


More information about the Tutor mailing list