diff options
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); } |