diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2013-09-19 02:05:00 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2013-09-19 02:05:00 +0000 |
| commit | f6e99d7d1b76dd7a7933f55ba095bdcb534f81b3 (patch) | |
| tree | cbee5d1eec2e1afe8c3f8033d528cab4504c3c49 /src/svg/round.cpp | |
| parent | Encapsulate the shared memory hack for Cairo and GdkPixbuf in a class (diff) | |
| parent | Added gpl notice (diff) | |
| download | inkscape-f6e99d7d1b76dd7a7933f55ba095bdcb534f81b3.tar.gz inkscape-f6e99d7d1b76dd7a7933f55ba095bdcb534f81b3.zip | |
Merge C++ification of the SP tree by Markus Engel
(bzr r12532)
Diffstat (limited to 'src/svg/round.cpp')
| -rw-r--r-- | src/svg/round.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/svg/round.cpp b/src/svg/round.cpp deleted file mode 100644 index 0a4ca9d05..000000000 --- a/src/svg/round.cpp +++ /dev/null @@ -1,48 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// ftos.cc -// -// Copyright (c) 1996-2003 Bryce W. Harrington [bryce at osdl dot org] -// -//----------------------------------------------------------------------- -// License: This code may be used by anyone for any purpose -// so long as the copyright notices and this license -// statement remains attached. -//----------------------------------------------------------------------- -// This routine rounds a double using the "rounding rule", as expressed -// in _Advanced Engineering Mathematics_ by Erwin Kreyszig, 6th ed., -// John Wiley & Sons, Inc., 1988, page 945. -// -// Discard the (k+1)th and all subsequent decimals. -// (a) If the number thus discarded is less than half a unit in the -// kth place, leave the kth decimal unchanged ("rounding down") -// (b) If it is greater than half a unit in the kth place, add one -// to the kth decimal ("rounding up") -// (c) If it is exactly half a unit, round off to the nearest *even* -// decimal. -// Example: Rounding off 3.45 and 3.55 by one decimal gives 3.4 and -// 3.6, respectively. -// Rule (c) is to ensure that in discarding exactly half a decimal, -// rounding up and rounding down happens about equally often, -// on the average. -/////////////////////////////////////////////////////////////////////// -#include <math.h> -#include "../io/ftos.h" /* own include */ /* note - why in different dirs? */ - -double rround(double x) -{ - double xlow = floor(x); - if (x - xlow != 0.5000) - return floor(x + 0.5000); - else if ( floor(x/2.0) == xlow/2.0) - return xlow; - else - return xlow++; -} - -// This version allows rounding to a specific digit -double rround(double x, int k) -{ - if (k==0) return rround(x); - else return rround(x*pow(10,k)) / pow(10,k); -} - |
