source: vendor/w32api/current/lib/largeint.c

Last change on this file was 2720, checked in by bird, 19 years ago

w32api v3.6

File size: 2.0 KB
Line 
1/*
2 largeint.c
3
4 Large (64 bits) integer arithmetics library
5
6 Written by Anders Norlander <anorland@hem2.passagen.se>
7
8 This file is part of a free library for the Win32 API.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14*/
15
16#define __COMPILING_LARGEINT
17
18#include <largeint.h>
19
20__int64 WINAPI
21LargeIntegerAdd (__int64 i1, __int64 i2)
22{
23 return i1 + i2;
24}
25
26__int64 WINAPI
27LargeIntegerSubtract (__int64 i1, __int64 i2)
28{
29 return i1 - i2;
30}
31
32__int64 WINAPI
33LargeIntegerArithmeticShift (__int64 i, int n)
34{
35 return i >> n;
36}
37
38__int64 WINAPI
39LargeIntegerShiftLeft (__int64 i, int n)
40{
41 return i << n;
42}
43
44__int64 WINAPI
45LargeIntegerShiftRight (__int64 i, int n)
46{
47 return i >> n;
48}
49
50__int64 WINAPI
51LargeIntegerNegate (__int64 i)
52{
53 return -i;
54}
55
56__int64 WINAPI
57ConvertLongToLargeInteger (LONG l)
58{
59 return (__int64) l;
60}
61
62__int64 WINAPI
63ConvertUlongToLargeInteger (ULONG ul)
64{
65 return _toi(_toui(ul));
66}
67
68__int64 WINAPI
69EnlargedIntegerMultiply (LONG l1, LONG l2)
70{
71 return _toi(l1) * _toi(l2);
72}
73
74__int64 WINAPI
75EnlargedUnsignedMultiply (ULONG ul1, ULONG ul2)
76{
77 return _toi(_toui(ul1) * _toui(ul2));
78}
79
80__int64 WINAPI
81ExtendedIntegerMultiply (__int64 i, LONG l)
82{
83 return i * _toi(l);
84}
85
86__int64 WINAPI
87LargeIntegerMultiply (__int64 i1, __int64 i2)
88{
89 return i1 * i2;
90}
91
92__int64 WINAPI LargeIntegerDivide (__int64 i1, __int64 i2, __int64 *remainder)
93{
94 if (remainder)
95 *remainder = i1 % i2;
96 return i1 / i2;
97}
98
99ULONG WINAPI
100EnlargedUnsignedDivide (unsigned __int64 i1, ULONG i2, PULONG remainder)
101{
102 if (remainder)
103 *remainder = i1 % _toi(i2);
104 return i1 / _toi(i2);
105}
106__int64 WINAPI
107ExtendedLargeIntegerDivide (__int64 i1, ULONG i2, PULONG remainder)
108{
109 if (remainder)
110 *remainder = i1 % _toi(i2);
111 return i1 / _toi(i2);
112}
113
114/* FIXME: what is this function supposed to do? */
115__int64 WINAPI ExtendedMagicDivide (__int64 i1, __int64 i2, int n)
116{
117 return 0;
118}
Note: See TracBrowser for help on using the repository browser.