-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Akuli <[email protected]>
- Loading branch information
1 parent
ef849db
commit 6128470
Showing
2 changed files
with
74 additions
and
0 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,40 @@ | ||
declare abs(x: int) -> int | ||
declare llabs(x: long) -> long | ||
declare fabs(x: double) -> double | ||
|
||
declare ceil(x: double) -> double | ||
declare floor(x: double) -> double | ||
declare round(x: double) -> double | ||
|
||
declare acos(x: double) -> double | ||
declare asin(x: double) -> double | ||
declare atan(x: double) -> double | ||
declare atan2(y: double, x: double) -> double | ||
declare cos(x: double) -> double | ||
declare sin(x: double) -> double | ||
declare tan(x: double) -> double | ||
|
||
declare fmod(x: double, y: double) -> double | ||
declare sqrt(x: double) -> double | ||
declare cbrt(x: double) -> double | ||
|
||
declare log(x: double) -> double | ||
declare log10(x: double) -> double | ||
declare log2(x: double) -> double | ||
|
||
declare exp(x: double) -> double | ||
declare exp2(x: double) -> double | ||
declare pow(x: double, y: double) -> double | ||
declare ldexp(x: double, exp: int) -> double | ||
|
||
declare fmax(x: double, y: double) -> double | ||
declare fmin(x: double, y: double) -> double | ||
|
||
declare hypot(x: double, y: double) -> double | ||
|
||
# These function are not support yet... | ||
# syntax error | ||
# declare modf(value: double, *iptr: double) -> double | ||
# declare frexp(value: double, *exp: int) -> double | ||
# declare poly(x: double, degree: int, coeffs[]: double) -> double | ||
# declare matherr(struct exception *e) |
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,34 @@ | ||
from "stdlib/math.jou" import ( | ||
abs, llabs, fabs, ceil, floor, round, acos, asin, atan, atan2, cos, sin, tan, | ||
fmod, sqrt, cbrt, log, log10, log2, exp, exp2, pow, ldexp, fmax, fmin, hypot, | ||
) | ||
from "stdlib/io.jou" import printf | ||
|
||
def main() -> int: | ||
printf("%d\n", abs(-1)) # Output: 1 | ||
printf("%lld\n", llabs(-1145141919180L)) # Output: 1145141919180 | ||
printf("%f\n", fabs(-114.514)) # Output: 114.514000 | ||
printf("%f\n", ceil(3.14159265358979)) # Output: 4.000000 | ||
printf("%f\n", floor(3.14159265358979)) # Output: 3.000000 | ||
printf("%f\n", round(3.14159265358979)) # Output: 3.000000 | ||
printf("%f\n", acos(-1)) # Output: 3.141593 | ||
printf("%f\n", asin(-1)) # Output: -1.570796 | ||
printf("%f\n", atan(-1)) # Output: -0.785398 | ||
printf("%f\n", atan2(-1, -1)) # Output: -2.356194 | ||
printf("%f\n", cos(1.04719753333333)) # Output: 0.500000 | ||
printf("%f\n", sin(0.785398149999999)) # Output: 0.707107 | ||
printf("%f\n", tan(2.45)) # Output: -0.828017 | ||
printf("%f\n", fmod(9.3, 3.1)) # Output: 0.000000 | ||
printf("%f\n", sqrt(5)) # Output: 2.236068 | ||
printf("%f\n", cbrt(27)) # Output: 3.000000 | ||
printf("%f\n", log(114)) # Output: 4.736198 | ||
printf("%f\n", log10(114)) # Output: 2.056905 | ||
printf("%f\n", log2(114)) # Output: 6.832890 | ||
printf("%f\n", exp(3)) # Output: 20.085537 | ||
printf("%f\n", exp2(3)) # Output: 8.000000 | ||
printf("%f\n", pow(2, 2)) # Output: 4.000000 | ||
printf("%f\n", ldexp(10, 2)) # Output: 40.000000 | ||
printf("%f\n", fmax(1.14, 5.14)) # Output: 5.140000 | ||
printf("%f\n", fmin(1.14, 5.14)) # Output: 1.140000 | ||
printf("%f\n", hypot(3, 4)) # Output: 5.000000 | ||
return 0 |