From af389cd969ab7ae6507710cb8667660c3bd51577 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Sep 2015 18:55:15 +0200 Subject: add div functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/stdlib.h | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index f24fbf3..fd78d27 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -27,9 +27,9 @@ #define __NEED_size_t #define __NEED_wchar_t -#define __NEED_div_t /* TODO not defined */ -#define __NEED_ldiv_t /* TODO not defined */ -#define __NEED_lldiv_t /* TODO not defined */ +#define __NEED_div_t +#define __NEED_ldiv_t +#define __NEED_lldiv_t #include @@ -56,5 +56,40 @@ +/** + * Perform an integer division and return + * both the quotient and the remainder. + * + * @param numerator The numerator. + * @param denominator The denominator. + * @return The quotient in `.quot`, and + * the remainder in `.rem`. + */ +div_t div(int, int); + +/** + * Perform an integer division and return + * both the quotient and the remainder. + * + * @param numerator The numerator. + * @param denominator The denominator. + * @return The quotient in `.quot`, and + * the remainder in `.rem`. + */ +ldiv_t ldiv(long, long); + +/** + * Perform an integer division and return + * both the quotient and the remainder. + * + * @param numerator The numerator. + * @param denominator The denominator. + * @return The quotient in `.quot`, and + * the remainder in `.rem`. + */ +lldiv_t lldiv(long long, long long); + + + #endif -- cgit v1.2.3-70-g09d2