-
Notifications
You must be signed in to change notification settings - Fork 184
fix: complete the Double math suite with missing C wrappers and registrations #1558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,3 +73,4 @@ | |
| (definterface empty? (Fn [&a] Bool)) | ||
|
|
||
| (definterface sign (Fn [a] a)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| #ifndef CARP_DOUBLE_H | ||
| #define CARP_DOUBLE_H | ||
|
Comment on lines
+1
to
+2
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don’t have this guard anywhere else. |
||
|
|
||
| #include <float.h> | ||
| #include <math.h> | ||
| #include <stdbool.h> | ||
| #include <string.h> | ||
|
Comment on lines
+4
to
+7
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We rely on include order, so this is odd. |
||
|
|
||
| const double CARP_DBL_MAX = DBL_MAX; | ||
| const double CARP_DBL_MIN = DBL_MIN; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not |
||
|
|
||
| double Double__PLUS_(double x, double y) { | ||
| return x + y; | ||
|
|
@@ -29,47 +38,46 @@ double Double_copy(const double* x) { | |
| return *x; | ||
| } | ||
|
|
||
| // Double.toInt : Double -> Int | ||
| int Double_to_MINUS_int(double x) { | ||
| return (int)x; | ||
| } | ||
|
|
||
| double Double_from_MINUS_int(int x) { | ||
| return (double)x; | ||
| } | ||
|
|
||
| Long Double_to_MINUS_bytes(double x) { | ||
| Long y; | ||
| memcpy(&y, &x, sizeof(double)); | ||
| return y; | ||
| double Double_from_MINUS_float(float x) { | ||
| return (double)x; | ||
| } | ||
|
|
||
| float Double_to_MINUS_float(double x) { | ||
| return (float)x; | ||
| double Double_from_MINUS_long(Long x) { | ||
| return (double)x; | ||
| } | ||
|
|
||
| double Double_from_MINUS_float(float x) { | ||
| double Double_from_MINUS_uint64(uint64_t x) { | ||
| return (double)x; | ||
| } | ||
|
|
||
| Long Double_to_MINUS_long(double x) { | ||
| return (Long)x; | ||
| int Double_to_MINUS_int(double x) { | ||
| return (int)x; | ||
| } | ||
|
|
||
| double Double_from_MINUS_long(Long x) { | ||
| return (double)x; | ||
| float Double_to_MINUS_float(double x) { | ||
| return (float)x; | ||
| } | ||
|
|
||
| Long Double_to_MINUS_long(double x) { | ||
| return (Long)x; | ||
| } | ||
|
|
||
| uint64_t Double_to_MINUS_uint64(double x) { | ||
| return (uint64_t)x; | ||
| } | ||
|
|
||
| double Double_from_MINUS_uint64(uint64_t x) { | ||
| return (double)x; | ||
| Long Double_to_MINUS_bytes(double x) { | ||
| Long res; | ||
| memcpy(&res, &x, sizeof(double)); | ||
| return res; | ||
| } | ||
|
|
||
| double Double_abs(double x) { | ||
| return x > 0.0 ? x : -x; | ||
| return fabs(x); | ||
| } | ||
|
|
||
| double Double_acos(double x) { | ||
|
|
@@ -100,6 +108,10 @@ double Double_sin(double x) { | |
| return sin(x); | ||
| } | ||
|
|
||
| double Double_tan(double x) { | ||
| return tan(x); | ||
| } | ||
|
|
||
| double Double_sinh(double x) { | ||
| return sinh(x); | ||
| } | ||
|
|
@@ -152,6 +164,8 @@ double Double_mod(double x, double y) { | |
| return fmod(x, y); | ||
| } | ||
|
|
||
| double Double_tan(double x) { | ||
| return tan(x); | ||
| int Double_round(double x) { | ||
| return (int)round(x); | ||
| } | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already exists on line 59.