Re: TIB: Fractions in Output
[Prev][Next][Index][Thread]
Re: TIB: Fractions in Output
Wow, i never though of this but here is what i did to edit it , just added
gcd command to make the fraction lowest terms. (see below) You could maybe
add somekind of flag command flag=1 if neg. flag =0 if its not negative then
just check to see if the num is negative using sign, Then at the bottom
check the sign and put the *-1 or not at the end.
>You'll need to write a fraction routine prog.... (note I think this'll only
work
>for positive fractions, the rounding check would need to be changed to work
both
>ways I think, I just don't want to think that much...)
>a sub prog is easiest, in main, you store x,y, and num
>then sub prog tries many denominators
>for(C,2,999)
>if (C*num)==int(c*num)
>then
>D=1+int (log (C*num)) //store decimal places of numerator, easier way?
If you put D=gcd(C*num,C)
Then add the stuff below as i did you can get
the fraction in lowest terms.
>output(y,x,(c*num)/D) //numerator
>output(y,x+D,"/")// divided by
>output(y,x+D+1,(C/D) //denominator
>return //stop the sub prog
>end
>end //we are done
>disp "Can't make fraction"
>Stop
>
>
>See if that works.....let the list know, and if anyone feels like
optimizing, go
>right ahead, PLEASAE!