1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #define _TLBIGINT_INT64
22 #include <tools/bigint.hxx>
23 #include <basic/sbx.hxx>
25 ///////////////////////////// BigInt/Currency //////////////////////////////
27 SbxValues::SbxValues( const BigInt
&rBig
) : eType(SbxCURRENCY
)
29 rBig
.INT64( &nLong64
);
32 //TODO: BigInt is TOOLS_DLLPUBLIC, and its four member functions only declared
33 // and defined within basic (#define _TLBIGINT_INT64) are a bad hack that causes
34 // "warning C4273: 'function' : inconsistent dll linkage" on MSC; this whole
35 // mess should be cleaned up properly (e.g., by completely removing Sbx[U]INT64
36 // and using sal_[u]Int64 instead):
38 #pragma warning(disable: 4273)
41 sal_Bool
BigInt::INT64( SbxINT64
*p
) const
44 if( nLen
> 4 || (nNum
[3] & 0x8000) )
47 p
->nLow
= ((sal_uInt32
)nNum
[1] << 16) | (sal_uInt32
)nNum
[0];
48 p
->nHigh
= ((sal_uInt32
)nNum
[3] << 16) | (sal_uInt32
)nNum
[2];
53 p
->Set( (sal_Int32
)nVal
);
58 BigInt::BigInt( const SbxINT64
&r
)
60 BigInt a10000
= 0x10000;
65 *this += (sal_uInt16
)(r
.nLow
>> 16);
67 *this += (sal_uInt16
)r
.nLow
;
70 sal_Bool
BigInt::UINT64( SbxUINT64
*p
) const
73 if( bIsNeg
|| nLen
> 4 )
76 p
->nLow
= ((sal_uInt32
)nNum
[1] << 16) | (sal_uInt32
)nNum
[0];
77 p
->nHigh
= ((sal_uInt32
)nNum
[3] << 16) | (sal_uInt32
)nNum
[2];
83 p
->Set( (sal_uInt32
)nVal
);
89 BigInt::BigInt( const SbxUINT64
&r
)
91 BigInt a10000
= 0x10000;
93 *this = BigInt(r
.nHigh
);
96 *this += (sal_uInt16
)(r
.nLow
>> 16);
98 *this += (sal_uInt16
)r
.nLow
;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */