mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add imaxdiv(3).
This commit is contained in:
parent
a9d8712435
commit
02013158e7
3 changed files with 41 additions and 1 deletions
|
@ -25,6 +25,7 @@ dirent/alphasort.o \
|
|||
dirent/dir.o \
|
||||
dirent/versionsort.o \
|
||||
errno/errno.o \
|
||||
inttypes/imaxdiv.o \
|
||||
inttypes/strtoimax.o \
|
||||
inttypes/strtoumax.o \
|
||||
inttypes/wcstoimax.o \
|
||||
|
|
|
@ -200,8 +200,14 @@ __BEGIN_DECLS
|
|||
|
||||
@include(wchar_t.h)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
intmax_t quot;
|
||||
intmax_t rem;
|
||||
} imaxdiv_t;
|
||||
|
||||
intmax_t imaxabs(intmax_t);
|
||||
/* TODO: imaxdiv */
|
||||
imaxdiv_t imaxdiv(intmax_t, intmax_t);
|
||||
intmax_t strtoimax(const char* __restrict, char** __restrict, int);
|
||||
uintmax_t strtoumax(const char* __restrict, char** __restrict, int);
|
||||
intmax_t wcstoimax(const wchar_t* __restrict, wchar_t** __restrict, int);
|
||||
|
|
33
libc/inttypes/imaxdiv.cpp
Normal file
33
libc/inttypes/imaxdiv.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2013
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
inttypes/imaxdiv.cpp
|
||||
Compute quotient and remainder of integer division.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
extern "C" imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
|
||||
{
|
||||
imaxdiv_t ret;
|
||||
ret.quot = numer / denom;
|
||||
ret.rem = numer % denom;
|
||||
return ret;
|
||||
}
|
Loading…
Reference in a new issue