diff options
author | torset | 2009-02-25 13:38:56 +0000 |
---|---|---|
committer | torset | 2009-02-25 13:38:56 +0000 |
commit | 0972fda53894a22215a30f8aa83da5c7de3d129e (patch) | |
tree | b58540fe2c05202684f8ef059b28a9e07b2cd8bf /src/elementaryFunctions/round/zrounds.c | |
parent | 0a9569e577e3faf3ff87b0c4994e17281d194377 (diff) | |
download | scilab2c-0972fda53894a22215a30f8aa83da5c7de3d129e.tar.gz scilab2c-0972fda53894a22215a30f8aa83da5c7de3d129e.tar.bz2 scilab2c-0972fda53894a22215a30f8aa83da5c7de3d129e.zip |
Add round files
Diffstat (limited to 'src/elementaryFunctions/round/zrounds.c')
-rw-r--r-- | src/elementaryFunctions/round/zrounds.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/elementaryFunctions/round/zrounds.c b/src/elementaryFunctions/round/zrounds.c index de6c7c2c..3f723adf 100644 --- a/src/elementaryFunctions/round/zrounds.c +++ b/src/elementaryFunctions/round/zrounds.c @@ -14,8 +14,16 @@ #include "round.h" doubleComplex zrounds(doubleComplex x) { - int roundReal = (int)zreals(x); - int roundImag = (int)zimags(x); + int roundReal; + int roundImag; + + if (zreals(x)>=0) roundReal = (int)(zreals(x)+0.5); + else roundReal = (int)(zreals(x)-0.5); + + + + if (zimags(x)>=0) roundImag = (int)(zimags(x)+0.5); + else roundImag = (int)(zimags(x)-0.5); return DoubleComplex((double)roundReal, (double)roundImag); } |