Hello boys (& girls ^^)
I wanted to code a spigot algorythm in b4p (that means adapt the c code i found here: Pispigot.htm)
The parts i cant cope with are highlited:
Its that variable[some value] meant to be an array?
Arent these for loops actually while loops? And how should the conditions look like in b4p?
is d%f a nother way of doing a division?
THX in advance for your help.
MfG/Regards
Christian
I wanted to code a spigot algorythm in b4p (that means adapt the c code i found here: Pispigot.htm)
The parts i cant cope with are highlited:
B4X:
#include <stdio.h>
#include <stdlib.h>
#define N 4000 /* hier 4000 Stellen*/
#define LEN (N/4+1)*14 /* Feldlaenge def.*/
long a[COLOR="Red"][LEN][/COLOR]; /* 4 stell. Bereich */
long b; /* Zaehler Basis alt*/
long c = LEN; /* Feld-Index */
long d; /* Akkumulator */
long e = 0; /* Uebertr.4 stellig*/
long f = 10000; /* Neue Basis */
long g; /* Nenner Basis */
long h = 0; /* erst 0, dann 1 */
int main(void)
{
[COLOR="Red"]for (;(b=c-=14) > 0;)[/COLOR]/* aeussere Schleife*/
{
[COLOR="Red"] for (; --b > 0;) [/COLOR] /* Radix-Konvertier.*/
{
d *= b; /* Feldindex Basis */
if (h == 0) /* erster Durchlauf?*/
d += 2000*f; /* ja */
else
d += a[b]*f; /* nein */
g = b+b-1; /* Nenner Basis */
a[b] = [COLOR="Red"]d%g[/COLOR]; /* Uebertrag */
d /= g; /* Rest */
}
h = printf("%04d",e+d/f); /*Korrektur */
d = e = d%f; /*nur ein Durchlauf */
/* Stelle bewahren */
}
}
getch();
Its that variable[some value] meant to be an array?
Arent these for loops actually while loops? And how should the conditions look like in b4p?
is d%f a nother way of doing a division?
THX in advance for your help.
MfG/Regards
Christian
Last edited: