Anonymous avatar Anonymous committed 323c818

Give the poor float its pos/neg operations.

Comments (0)

Files changed (1)

     return AR_FLOAT(AR_AS_DOUBLE(self) / AR_AS_DOUBLE(other));
 }
 
+static AR
+arana_float_pos(AR_SIG, AR self, AR args)
+{
+    AR_ASSERT_EMPTY_ARGS(args, ":pos");
+    return self;
+}
+
+static AR
+arana_float_neg(AR_SIG, AR self, AR args)
+{
+    AR_ASSERT_EMPTY_ARGS(args, ":neg");
+    return AR_FLOAT(-AR_AS_DOUBLE(self));
+}
+
 #define PREC_STR  12
 #define PREC_REPR 16
 
 arana_create_float_type(AR_SIG)
 {
     AR type = AR_CREATE_TYPE(ArFloatType);
-    AR_BIND_METHOD(type, "to_string", arana_float_to_string);
-    AR_BIND_METHOD(type, "to_repr", arana_float_to_repr);
     AR_BIND_METHOD(type, ":add", arana_float_add);
     AR_BIND_METHOD(type, ":sub", arana_float_sub);
     AR_BIND_METHOD(type, ":mul", arana_float_mul);
     AR_BIND_METHOD(type, ":div", arana_float_div);
+    AR_BIND_METHOD(type, ":pos", arana_float_pos);
+    AR_BIND_METHOD(type, ":neg", arana_float_neg);
+    AR_BIND_METHOD(type, "to_string", arana_float_to_string);
+    AR_BIND_METHOD(type, "to_repr", arana_float_to_repr);
     return type;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.