ReactOS
0.4.16-dev-2110-ge3521eb
imaxdiv.cpp
Go to the documentation of this file.
1
//
2
// imaxdiv.cpp
3
//
4
// Copyright (c) Microsoft Corporation. All rights reserved.
5
//
6
// Defines imaxdiv(), which performs a signed divide using intmax_t operands
7
// and returns the quotient and remainder. No validation of the arguments is
8
// done.
9
//
10
#include <inttypes.h>
11
12
13
14
extern
"C"
imaxdiv_t
__cdecl
imaxdiv
(
intmax_t
const
numerator,
intmax_t
const
denominator)
15
{
16
imaxdiv_t
result
;
17
18
result
.quot = numerator / denominator;
19
result
.rem = numerator - denominator *
result
.quot;
20
21
// Fix incorrect truncation:
22
#pragma warning(push)
23
#pragma warning(disable: 4127)
24
static
bool
const
fix_required = (-1 / 2) < 0;
25
if
(fix_required &&
result
.quot < 0 &&
result
.rem != 0)
26
{
27
result
.quot += 1;
28
result
.rem -= denominator;
29
}
30
#pragma warning(pop)
31
32
return
result
;
33
}
34
35
36
37
/*
38
* Copyright (c) 1992-2010 by P.J. Plauger. ALL RIGHTS RESERVED.
39
* Consult your license regarding permissions and restrictions.
40
V5.30:0009 */
__cdecl
#define __cdecl
Definition:
corecrt.h:121
intmax_t
long long intmax_t
Definition:
stdint.h:65
result
GLuint64EXT * result
Definition:
glext.h:11304
imaxdiv
imaxdiv_t __cdecl imaxdiv(intmax_t const numerator, intmax_t const denominator)
Definition:
imaxdiv.cpp:14
imaxdiv_t
Definition:
inttypes.h:19
sdk
lib
ucrt
stdlib
imaxdiv.cpp
Generated on Thu Jan 8 2026 06:16:17 for ReactOS by
1.9.6