Skip to content

Commit

Permalink
revision
Browse files Browse the repository at this point in the history
  • Loading branch information
cameyo42 committed Nov 14, 2017
1 parent 173eaa2 commit 1cb3c80
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 35 deletions.
7 changes: 3 additions & 4 deletions complex.pde
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void fnCXSUB()
isResult = true;
isBlocked = false;
}
else { outputSTR = "Complex suctraction: four numbers required."; }
else { outputSTR = "Complex subtraction: four numbers required."; }
}
// sottrazione di due numeri complessi
double[] CXSUB(double re1, double im1, double re2, double im2)
Expand Down Expand Up @@ -132,6 +132,7 @@ void fnCXDIV()
}
else { outputSTR = "Complex division: four numbers required."; }
}

// divisione di due numeri complessi
double[] CXDIV(double re1, double im1, double re2, double im2)
{
Expand Down Expand Up @@ -162,7 +163,7 @@ void fnCXINV()
{
pila.push(re1);
digitNUM = im1;
outputSTR = "Complex inverse: 0+i0 does not have a reciprocal.";
outputSTR = "Complex inverse: 0 + i0 does not have a reciprocal.";
isResult = true;
isBlocked = false;
}
Expand Down Expand Up @@ -264,5 +265,3 @@ double[] CXPOW(double re1, double im1, int n)
double[] result = { re, im };
return(result);
}

//double CX
21 changes: 0 additions & 21 deletions drawGUI.pde
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

void drawLCD()
{
image(lcd_IMG, 0, 0);
Expand Down Expand Up @@ -40,26 +39,6 @@ void drawOutput()
text(outputSTR, 300, 349);
}

//void setNumberFormat(int num)
//{
// switch(num)
// {
// case 0: df = new DecimalFormat("#,##0E0"); break;
// case 1: df = new DecimalFormat("#,##0.0E0"); break;
// case 2: df = new DecimalFormat("#,##0.00E0"); break;
// case 3: df = new DecimalFormat("#,##0.000E0"); break;
// case 4: df = new DecimalFormat("#,##0.0000E0"); break;
// case 5: df = new DecimalFormat("#,##0.00000E0"); break;
// case 6: df = new DecimalFormat("#,##0.000000E0"); break;
// case 7: df = new DecimalFormat("#,##0.0000000E0"); break;
// case 8: df = new DecimalFormat("#,##0.00000000E0"); break;
// case 9: df = new DecimalFormat("#,##0.000000000E0"); break;
// case 10: df = new DecimalFormat("#,##0.0000000000E0"); break;
// case 11: df = new DecimalFormat("#,##0.00000000000E0"); break;
// case 12: df = new DecimalFormat("#,##0.000000000000E0"); break;
// }
//}

String formatNumber(double n)
{
String numStr;
Expand Down
12 changes: 8 additions & 4 deletions fibo.pde
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
* https://www.nayuki.io/page/fast-fibonacci-algorithms
* adapted by cameyo for ForthCalc.pde (processing)
*/
private static BigInteger fastFibonacciDoubling(int n) {
private static BigInteger fastFibonacciDoubling(int n)
{
BigInteger a = BigInteger.ZERO;
BigInteger b = BigInteger.ONE;
int m = 0;
for (int bit = Integer.highestOneBit(n); bit != 0; bit >>>= 1) {
for (int bit = Integer.highestOneBit(n); bit != 0; bit >>>= 1)
{
// Loop invariant: a = F(m), b = F(m+1)
// Double it
BigInteger d = multiply(a, b.shiftLeft(1).subtract(a));
Expand All @@ -19,7 +21,8 @@
b = e;
m *= 2;
// Advance by one conditionally
if ((n & bit) != 0) {
if ((n & bit) != 0)
{
BigInteger c = a.add(b);
a = b;
b = c;
Expand All @@ -31,6 +34,7 @@

// Multiplies two BigIntegers.
// This function makes it easy to swap in a faster algorithm like Karatsuba multiplication.
private static BigInteger multiply(BigInteger x, BigInteger y) {
private static BigInteger multiply(BigInteger x, BigInteger y)
{
return x.multiply(y);
}
4 changes: 2 additions & 2 deletions functionForth.pde
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 2tuck (a b c d -- c d a b c d) Copy the top couple of value below the second couple of value.

// pick ( xu...x1 x0 u -- xu...x1 x0 xu ) Remove u. Copy the xu to the top of the stack. Num items >= u+2.
// roll ( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) Remove u. Rotate u+1 items on the top of the stack.Num items > u+2.
// roll ( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) Remove u. Rotate u+1 items on the top of the stack. Num items > u+2.
//--------------------------------------------------------------------------

// DUP (a -- a a) Duplica il valore in cima alla pila
Expand Down Expand Up @@ -431,7 +431,7 @@ void fnRUPS()
else { outputSTR = "R UP: at least two numbers required."; }
}

// Rotate Up the stack by N items (BUG: negative roll)
// Rotate Up the stack by N items
void fnROLLS()
{
int idx = (int) digitNUM;
Expand Down
2 changes: 1 addition & 1 deletion functionInput.pde
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void fnFIX()
digitRESET = "0." + nf(0, numFloating);
fnDROP();
}
else { outputSTR = "FIX: integer number required [-1, 9]"; }
else { outputSTR = "FIX: integer number required [-2, 9]"; }
}

void enterPressed()
Expand Down
2 changes: 1 addition & 1 deletion time.pde
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void fnTADD()
//println(res$);
double res = Double.valueOf(res$);
//println(res);
// For example, the result of TIME('11:02:26') - '00:32:56' is 102930 (a duration of 10 hours, 29 minutes, and 30 seconds).
//Example, the result of TIME('11:02:26') - '00:32:56' is 102930 (a duration of 10 hours, 29 minutes, and 30 seconds).
digitNUM = res;
outputSTR = String.valueOf(digitNUM);
isResult = true;
Expand Down
2 changes: 0 additions & 2 deletions vector.pde
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,3 @@ void fnVECMAG()
}
else { outputSTR = "Vector3D Magnitude and Heading: three numbers required."; }
}


0 comments on commit 1cb3c80

Please sign in to comment.