java - Continuous Fractions -


My understanding of continuous fragments was that it would represent a decimal in fraction. I thought the constant fraction would always return less than or equal to the decimal number. Unfortunately my code sometimes gives a greater partial value than the decimal input

Is the understanding of my constant fractions right? If you can do this, please tell us where the error will be in your code. Public stable rational contfrac (double a, int i, int n) {if (i & lt; n) {boolean neg = false; If (a & lt; 0) {neg = true; // this dual recesi = monastery Bass (1 / a); // A subsidiary method is required to have mutual double values ​​of a given decimal value = receipt% 1; // Reciprocal double intprt = decimal part of the race; remainder; Reciprocal rational difference = new 'rational' (long) intprt; 'integer' part; // Creates a new rational number using 'integer'; Part of reciprocal if (stay! = 0) {inter = inter.add (contFrac (stay, I + 1, n)); } Return (reciprocal); // becomes a logical number reciprocity} second {new rational (0); }}

I am confident that your computer will be 1 / one .


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -