summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/elementaryFunctions/discrete_mathematics
diff options
context:
space:
mode:
authorsiddhu89902017-05-22 15:13:54 +0530
committersiddhu89902017-05-22 15:13:54 +0530
commit02a004ea1500c403ac1a18a52aaf79aaeb7280ed (patch)
tree5e55f872e363922a21ad91165628e68e16fea8a3 /2.3-1/src/c/elementaryFunctions/discrete_mathematics
parent5f17dffbfa6d84aee23f7946cfa95e9e5c9995b7 (diff)
parentde82d12658979cd70439f977742f80fac9f6521f (diff)
downloadScilab2C-02a004ea1500c403ac1a18a52aaf79aaeb7280ed.tar.gz
Scilab2C-02a004ea1500c403ac1a18a52aaf79aaeb7280ed.tar.bz2
Scilab2C-02a004ea1500c403ac1a18a52aaf79aaeb7280ed.zip
Bugs fixed for Scilab 6.0
Diffstat (limited to '2.3-1/src/c/elementaryFunctions/discrete_mathematics')
-rw-r--r--2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c9
-rw-r--r--2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c13
2 files changed, 8 insertions, 14 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c
index 98019431..9ac76b5a 100644
--- a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c
+++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c
@@ -18,17 +18,15 @@ void dfactors(double in,double* out)
int n=(int)in;
while (n%2 == 0)
{
- //printf("%d ", 2);
- out[k++]=2;
+ out[k++]=2;
n = n/2;
}
- for (i = 3; i <= sqrt(n); i = i+2)
+ for (i = 3; i <= (int)sqrt((double)n); i = i+2)
{
while (n%i == 0)
{
- out[k++]=i;
- //printf("%d ", i);
+ out[k++]=i;
n = n/i;
}
}
@@ -36,7 +34,6 @@ void dfactors(double in,double* out)
if (n > 2)
{
out[k++]=n;
- //printf ("%d ", n);
}
}
diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c
index 2e5ba478..a2eed09f 100644
--- a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c
+++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c
@@ -18,25 +18,22 @@ void sfactors(float in,float* out)
int n=(int)in;
while (n%2 == 0)
{
- //printf("%d ", 2);
- out[k++]=2;
+ out[k++]=2;
n = n/2;
}
- for (i = 3; i <= sqrt(n); i = i+2)
+ for (i = 3; i <= (int)sqrt((double)n); i = i+2)
{
while (n%i == 0)
{
- out[k++]=i;
- //printf("%d ", i);
+ out[k++]=i;
n = n/i;
}
}
- if (n > 2)
+ if (n > 2)
{
out[k++]=n;
- //printf ("%d ", n);
- }
+ }
}