-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9383d45
commit 794eb59
Showing
5 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
int idivii (int x, int y) { return (x int./ y); } | ||
double ddivii (int x, int y) { return (double)(x int./ y); } | ||
double ddivid (double x, int y) { return (x double./ (double)y); } | ||
double ddivdd (double x, double y) { return (x double./ y); } | ||
|
||
int main() { | ||
printDouble((double)idivii(5,3)); // 1.0 | ||
printDouble(ddivii(5,3)); // 1.0 | ||
printDouble(ddivdi((double)5,3)); // 1.6666666666666667 | ||
printDouble(ddivdd((double)5,(double)3)); // 1.6666666666666667 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
div(x,y) { return (x / y); } | ||
|
||
main() { | ||
printDouble(div(5,3)); | ||
} | ||
|
||
// What does this print? | ||
// 1 1 | ||
// X 1.6666666666666667 | ||
// 2 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
int idivii (int x, int y) { return (x / y); } | ||
double ddivii (int x, int y) { return (x / y); } | ||
double ddivid (double x, int y) { return (x / y); } | ||
double ddivdd (double x, double y) { return (x / y); } | ||
|
||
int main() { | ||
printDouble(idivii(5,3)); // | ||
printDouble(ddivii(5,3)); // | ||
printDouble(ddivdi(5,3)); // | ||
printDouble(ddivdd(5,3)); // | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// TYPE(VARS): expression of type TYPE over variables VARS | ||
bool divides (int q, int p) { | ||
return BOOL(p,q); | ||
} | ||
|
||
// | ||
bool prime (int p) { | ||
if (BOOL(p)) return BOOL(p); | ||
else { | ||
int q = INT(p,q); | ||
while (BOOL(p,q)) | ||
if (BOOL(p,q)) return BOOL(p,q); | ||
else ANY(p,q); | ||
} | ||
return BOOL(p); | ||
} | ||
|
||
int main () { | ||
if (BOOL()) ANY(); else ANY(); | ||
} | ||
|
||
/* | ||
BOOL(p,q): (p / q) * q == p | ||
BOOL(p): p == 1 || divides(2,p) | ||
BOOL(p): true | ||
INT(p,q): 3 | ||
BOOL(p,q): q * q <= p | ||
BOOL(p,q): divides(q,p) | ||
BOOL(p,q): false | ||
ANY(p,q): q = q + 2 | ||
BOOL(p): false | ||
BOOL(): prime(641) | ||
ANY(): printInt(641) | ||
ANY(): printInt(0) | ||
*/ | ||
|
||
|
||
|
||
/* | ||
BOOL(): prime(641) | ||
BOOL(p): p == 1 || divides(2,p) | ||
true | ||
false | ||
BOOL(p,q): (p / q) * q == p | ||
q * q <= p | ||
divides(q,p) | ||
false | ||
INT(p,q): 3 | ||
ANY(): printInt(641) | ||
printInt(0) | ||
ANY(p,q): q = q + 2 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters