summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortorset2009-02-25 13:38:56 +0000
committertorset2009-02-25 13:38:56 +0000
commitd90147469af33a3a97a139e99bedeb50a5287f2e (patch)
tree89cf9a4e68483c5d5f9dd6eed8108de348dfd991
parent23dcaa3991980f3938aa8ca42d2593522cdebff9 (diff)
downloadscilab2c-d90147469af33a3a97a139e99bedeb50a5287f2e.tar.gz
scilab2c-d90147469af33a3a97a139e99bedeb50a5287f2e.tar.bz2
scilab2c-d90147469af33a3a97a139e99bedeb50a5287f2e.zip
Add round files
-rw-r--r--scilab2c/src/elementaryFunctions/round/crounds.c12
-rw-r--r--scilab2c/src/elementaryFunctions/round/drounds.c5
-rw-r--r--scilab2c/src/elementaryFunctions/round/srounds.c6
-rw-r--r--scilab2c/src/elementaryFunctions/round/zrounds.c12
4 files changed, 29 insertions, 6 deletions
diff --git a/scilab2c/src/elementaryFunctions/round/crounds.c b/scilab2c/src/elementaryFunctions/round/crounds.c
index dbf20c83..598fd16b 100644
--- a/scilab2c/src/elementaryFunctions/round/crounds.c
+++ b/scilab2c/src/elementaryFunctions/round/crounds.c
@@ -14,8 +14,16 @@
#include "round.h"
floatComplex crounds(floatComplex x) {
- int roundReal = (int)creals(x);
- int roundImag = (int)cimags(x);
+ int roundReal;
+ int roundImag;
+
+ if (creals(x)>=0) roundReal = (int)(creals(x)+0.5);
+ else roundReal = (int)(creals(x)-0.5);
+
+
+
+ if (cimags(x)>=0) roundImag = (int)(cimags(x)+0.5);
+ else roundImag = (int)(cimags(x)-0.5);
return FloatComplex((float)roundReal, (float)roundImag);
}
diff --git a/scilab2c/src/elementaryFunctions/round/drounds.c b/scilab2c/src/elementaryFunctions/round/drounds.c
index 1dc6e855..5cc46429 100644
--- a/scilab2c/src/elementaryFunctions/round/drounds.c
+++ b/scilab2c/src/elementaryFunctions/round/drounds.c
@@ -14,6 +14,9 @@
#include "round.h"
double drounds(double x) {
- int result = (int)(x+0.5);
+ int result;
+ if(x>=0) result = (int)(x+0.5);
+ else result = (int)(x-0.5);
+
return (double)result;
}
diff --git a/scilab2c/src/elementaryFunctions/round/srounds.c b/scilab2c/src/elementaryFunctions/round/srounds.c
index 97a486ae..17ae537d 100644
--- a/scilab2c/src/elementaryFunctions/round/srounds.c
+++ b/scilab2c/src/elementaryFunctions/round/srounds.c
@@ -14,6 +14,10 @@
#include "round.h"
float srounds(float x) {
- int result = (int)(x+0.5);
+ int result;
+
+ if(x>=0) result = (int)(x+0.5);
+ else result = (int)(x-0.5);
+
return (float)result;
}
diff --git a/scilab2c/src/elementaryFunctions/round/zrounds.c b/scilab2c/src/elementaryFunctions/round/zrounds.c
index de6c7c2c..3f723adf 100644
--- a/scilab2c/src/elementaryFunctions/round/zrounds.c
+++ b/scilab2c/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);
}