diff --git a/libc3/ratio.c b/libc3/ratio.c
index 2e6e3d4..6130e48 100644
--- a/libc3/ratio.c
+++ b/libc3/ratio.c
@@ -127,6 +127,22 @@ s_ratio * ratio_add (const s_ratio *a, const s_ratio *b,
return dest;
}
+s_ratio * ratio_neg (const s_ratio *r, s_ratio *dest)
+{
+ s_ratio tmp = {0};
+ assert(r);
+ assert(dest);
+ assert(! integer_is_zero(&r->denominator));
+ if (! integer_neg(&r->numerator, &tmp.numerator))
+ return NULL;
+ if (! integer_init_copy(&tmp.denominator, &r->denominator)) {
+ integer_clean(&tmp.numerator);
+ return NULL;
+ }
+ *dest = tmp;
+ return dest;
+}
+
s_ratio * ratio_sub (const s_ratio *a, const s_ratio *b,
s_ratio *dest)
{
@@ -314,4 +330,4 @@ u8 ratio_to_u8 (const s_ratio *r)
u8 denominator = integer_to_u8(&r->denominator);
return numerator / denominator;
-}
\ No newline at end of file
+}
diff --git a/libc3/ratio.h b/libc3/ratio.h
index 75f616d..6559e58 100644
--- a/libc3/ratio.h
+++ b/libc3/ratio.h
@@ -51,11 +51,12 @@ u8 ratio_to_u8 (const s_ratio *r);
/* Operators. */
s_ratio * ratio_add (const s_ratio *a, const s_ratio *b,
s_ratio *dest);
-s_ratio * ratio_sub (const s_ratio *a, const s_ratio *b,
+s_ratio * ratio_div (const s_ratio *a, const s_ratio *b,
s_ratio *dest);
s_ratio * ratio_mul (const s_ratio *a, const s_ratio *b,
s_ratio *dest);
-s_ratio * ratio_div (const s_ratio *a, const s_ratio *b,
+s_ratio * ratio_neg (const s_ratio *r, s_ratio *dest);
+s_ratio * ratio_sub (const s_ratio *a, const s_ratio *b,
s_ratio *dest);
/* Setters. */
diff --git a/libc3/tag.c b/libc3/tag.c
index ac5f1bc..dfc996f 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -599,6 +599,10 @@ s_tag * tag_neg (const s_tag *tag, s_tag *result)
result->type = TAG_INTEGER;
integer_neg(&tag->data.integer, &result->data.integer);
return result;
+ case TAG_RATIO:
+ result->type = TAG_RATIO;
+ ratio_neg(&tag->data.ratio, &result->data.ratio);
+ return result;
case TAG_SW:
if (tag->data.sw == SW_MIN) {
integer_init_sw(&tmp, tag->data.sw);