[recipes] number: export setters
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] number: export setters
- Date: Sun, 25 Dec 2016 20:04:20 +0000 (UTC)
commit 9ebc6d03ec2db0f3c6a8987d6f766f08ed2f1aa0
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 24 23:14:51 2016 -0500
number: export setters
These will be useful in the ingredients list code.
src/gr-number.c | 24 ++++++++++++------------
src/gr-number.h | 3 +++
2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/gr-number.c b/src/gr-number.c
index ed417a2..e7160cb 100644
--- a/src/gr-number.c
+++ b/src/gr-number.c
@@ -42,7 +42,7 @@ gcd (int m, int n)
return m;
}
-static void
+void
gr_number_set_fraction (GrNumber *number,
int num,
int denom)
@@ -60,6 +60,16 @@ gr_number_set_fraction (GrNumber *number,
number->value = ((double) num) / ((double) denom);
}
+void
+gr_number_set_float (GrNumber *number,
+ double value)
+{
+ number->fraction = FALSE;
+ number->num = 0;
+ number->denom = 0;
+ number->value = value;
+}
+
GrNumber *
gr_number_new_fraction (int num, int denom)
{
@@ -71,16 +81,6 @@ gr_number_new_fraction (int num, int denom)
return number;
}
-static void
-gr_number_set_float (GrNumber *number,
- double value)
-{
- number->fraction = FALSE;
- number->num = 0;
- number->denom = 0;
- number->value = value;
-}
-
GrNumber *
gr_number_new_float (double value)
{
@@ -379,7 +379,7 @@ gr_number_format (GrNumber *number)
g_autofree char *fraction = NULL;
if (number->denom == 0)
- return g_strdup_printf ("%d/0", number->num);
+ return g_strdup ("");
integral = number->num / number->denom;
fraction = format_fraction (number->num % number->denom, number->denom);
diff --git a/src/gr-number.h b/src/gr-number.h
index e37a39a..6682edf 100644
--- a/src/gr-number.h
+++ b/src/gr-number.h
@@ -30,6 +30,9 @@ typedef struct {
GrNumber *gr_number_new_fraction (int num, int denom);
GrNumber *gr_number_new_float (double value);
+
+void gr_number_set_fraction (GrNumber *number, int num, int denom);
+void gr_number_set_float (GrNumber *number, double value);
void gr_number_add (GrNumber *a1,
GrNumber *a2,
GrNumber *b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]