/* Could someone please translate this C code into a Visual Basic equivalent */
#include <stdio.h>
#include <math.h>
#include <float.h>
int cf(double v, double p, int *N, int *D){
int i;
i=v;
v -= i;
v=fabs(v);
if( v>p ){
int a,n,d;
a=cf(1/v,p+p/v,&n,&d);
*N=d;
*D=d*a+n;
}else{
*N=0; *D=1;
}
return i;
}
main(int argc,char *argv[]){
int i,n,d;
i=cf(27.0/26.0,FLT_EPSILON
,&n,&d);
printf("%d %d/%d\n",i,n,d);
}
Start Free Trial