> Displaying FixedPoints: > > Python 2.2.1 (#34, Jul 16 2002, 16:25:42) [MSC 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > Alternative ReadLine 1.5 -- Copyright 2001, Chris Gonnerman > >>> from fixedpoint import * > >>> a = FixedPoint(2.135) > >>> print '%d' % (a) > 2 > >>> print '%4d' % (a) > 2 > >>> print '%e' % (a) > 2.130000e+000 > >>> print '%f' % (a) > 2.130000 > >>> print '%2f' % (a) > 2.130000 > >>> print '%.2d' % (a) > 02 > >>> print '%s' % (a) > 2.13 > >>> a.set_precision(4) > >>> print '%s' % (a) > 2.1300 > > I naively expected the %d to produce 2.315 Eh? In C as well as Python, %d means decimal *integer*. The format specifier to use fixed point notation is %f. Please don't change this! --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4