Remember that:
Python "int"s are typically machine/C longs.
Python "longs" are really "bignums" represented by multiple machine words.
'%' operator format strings bascially map into C printf formats.
+ 'C' has no multi-word integer data types.
-----------------------------------------------------------------------------
??? You can probably add it up NOW :-)
print "%d" % int(a)
will work, of course, until a grows large enough to yield:
"ValueError: long int too long to convert" from 'int(a)'.
BTW: did you know notice that '%' operator will take a tuple as the
second operand if the format string has more than one '%"
substitution?
>>> print "sqrt(%d)=%f" % ( 32, math.sqrt(32) )
sqrt(32)=5.656854
I didn't notice if this was in the manual, but the above reasoning
led me to try it, and it worked!
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics