1/*
2** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3** Distributed under the terms of the Haiku License.
4*/
5
6
7#include <inttypes.h>
8#include <stdlib.h>
9
10
11intmax_t
12imaxabs(intmax_t number)
13{
14	return number > 0 ? number : -number;
15}
16
17
18imaxdiv_t
19imaxdiv(intmax_t numer, intmax_t denom)
20{
21	imaxdiv_t result;
22
23	result.quot = numer / denom;
24	result.rem = numer % denom;
25
26	if (numer >= 0 && result.rem < 0) {
27		result.quot++;
28		result.rem -= denom;
29	}
30
31	return result;
32}
33
34
35intmax_t
36strtoimax(const char *string, char **_end, int base)
37{
38	// ToDo: implement me properly!
39	return (intmax_t)strtol(string, _end, base);
40}
41
42
43uintmax_t
44strtoumax(const char *string, char **_end, int base)
45{
46	// ToDo: implement me properly!
47	return (intmax_t)strtoul(string, _end, base);
48}
49
50