[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue-common/src external/README formatting/GDat...
From: |
James Thompson |
Subject: |
gnue-common/src external/README formatting/GDat... |
Date: |
Mon, 15 Sep 2003 15:02:50 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue-common
Branch:
Changes by: James Thompson <address@hidden> 03/09/15 15:02:50
Modified files:
src/external : README
src/formatting : GDataFormatter.py
Added files:
src/external : README.fixedpoint fixedpoint.py
Log message:
added fixedpoint python module to gnue
changed the numeric formatter to use FixedPoint old code was making
"20.06" print as "20.05"
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/external/README.fixedpoint?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/external/fixedpoint.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/external/README.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/formatting/GDataFormatter.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gnue-common/src/external/README
diff -c gnue-common/src/external/README:1.1 gnue-common/src/external/README:1.2
*** gnue-common/src/external/README:1.1 Wed Nov 13 18:56:24 2002
--- gnue-common/src/external/README Mon Sep 15 15:02:49 2003
***************
*** 15,18 ****
--- 15,23 ----
License: Python Software Foundation License
------------------------------------------------------
+ fixedpoint.py
+
+ URL: http://fixedpoint.sourceforge.net/
+ License: Python Software Foundation License
+ ------------------------------------------------------
Index: gnue-common/src/formatting/GDataFormatter.py
diff -c gnue-common/src/formatting/GDataFormatter.py:1.10
gnue-common/src/formatting/GDataFormatter.py:1.11
*** gnue-common/src/formatting/GDataFormatter.py:1.10 Fri Aug 1 10:34:54 2003
--- gnue-common/src/formatting/GDataFormatter.py Mon Sep 15 15:02:50 2003
***************
*** 30,35 ****
--- 30,38 ----
#
from types import *
+ from gnue.common.external.fixedpoint import FixedPoint, addHalfAndChop
+ FixedPoint.round = addHalfAndChop
+
def applyFormatting (value, mask):
# This obviously doesn't do anything with the mask yet
***************
*** 59,69 ****
else:
rv = ""
! push = 10 ** dec
!
! fract = int(abs(int(value * push) - int(value) * push) + 0.5)
whole = int(value)
-
wstr = str(whole)
if comma:
--- 62,71 ----
else:
rv = ""
! value = FixedPoint(value,dec)
! fract = "%s" % value.frac()
! fract = fract.split('.')[1]
whole = int(value)
wstr = str(whole)
if comma:
***************
*** 78,86 ****
for i in range(commas):
rv += ',' + wstr[:3]
wstr = wstr[3:]
!
if dec:
! rv += '.' + ("%%0%sd" % dec) % fract
return rv
return "%s" % value
--- 80,88 ----
for i in range(commas):
rv += ',' + wstr[:3]
wstr = wstr[3:]
!
if dec:
! rv += ".%s" % fract
return rv
return "%s" % value
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue-common/src external/README formatting/GDat...,
James Thompson <=