Skip to content

Commit 2c28ced

Browse files
matyalattenico
authored andcommitted
LibC: Add imaxabs
1 parent 481deb4 commit 2c28ced

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Userland/Libraries/LibC/inttypes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
extern "C" {
1313

14+
intmax_t imaxabs(intmax_t n)
15+
{
16+
return n > 0 ? n : -n;
17+
}
18+
1419
imaxdiv_t imaxdiv(intmax_t numerator, intmax_t denominator)
1520
{
1621
imaxdiv_t result;

Userland/Libraries/LibC/inttypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ __BEGIN_DECLS
191191
#define SCNxFAST32 SCNx32
192192
#define SCNxFAST64 SCNx64
193193

194+
intmax_t imaxabs(intmax_t);
195+
194196
typedef struct imaxdiv_t {
195197
intmax_t quot;
196198
intmax_t rem;

0 commit comments

Comments
 (0)