Commits

Anonymous committed 323c818

Give the poor float its pos/neg operations.

  • Participants
  • Parent commits b27465c

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;
 }