]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/DivS64x64Remainder.c
2 Integer division worker functions for Ia32.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "BaseLibInternals.h"
12 Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and
13 generates a 64-bit signed result and a optional 64-bit signed remainder.
15 This function divides the 64-bit signed value Dividend by the 64-bit
16 signed value Divisor and generates a 64-bit signed quotient. If Remainder
17 is not NULL, then the 64-bit signed remainder is returned in Remainder.
18 This function returns the 64-bit signed quotient.
20 @param Dividend A 64-bit signed value.
21 @param Divisor A 64-bit signed value.
22 @param Remainder A pointer to a 64-bit signed value. This parameter is
23 optional and may be NULL.
25 @return Dividend / Divisor
30 InternalMathDivRemS64x64 (
33 OUT INT64
*Remainder OPTIONAL
38 Quot
= InternalMathDivRemU64x64 (
39 (UINT64
) (Dividend
>= 0 ? Dividend
: -Dividend
),
40 (UINT64
) (Divisor
>= 0 ? Divisor
: -Divisor
),
43 if (Remainder
!= NULL
&& Dividend
< 0) {
44 *Remainder
= -*Remainder
;
46 return (Dividend
^ Divisor
) >= 0 ? Quot
: -Quot
;