1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_basic.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <basic/sbx.hxx> 32*cdf0e10cSrcweir #include <tools/errcode.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #define _TLBIGINT_INT64 35*cdf0e10cSrcweir #include <tools/bigint.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <basic/sbxvar.hxx> 38*cdf0e10cSrcweir #include "sbxconv.hxx" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir static ::rtl::OUString ImpCurrencyToString( const SbxINT64& ); 41*cdf0e10cSrcweir static SbxINT64 ImpStringToCurrency( const ::rtl::OUString& ); 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir SbxINT64 ImpGetCurrency( const SbxValues* p ) 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir SbxValues aTmp; 46*cdf0e10cSrcweir SbxINT64 nRes; 47*cdf0e10cSrcweir start: 48*cdf0e10cSrcweir switch( +p->eType ) 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir case SbxNULL: 51*cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION ); 52*cdf0e10cSrcweir case SbxEMPTY: 53*cdf0e10cSrcweir nRes.SetNull(); break; 54*cdf0e10cSrcweir case SbxCHAR: 55*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nChar ); break; 56*cdf0e10cSrcweir case SbxBYTE: 57*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nByte ); break; 58*cdf0e10cSrcweir case SbxINTEGER: 59*cdf0e10cSrcweir case SbxBOOL: 60*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nInteger ); break; 61*cdf0e10cSrcweir case SbxERROR: 62*cdf0e10cSrcweir case SbxUSHORT: 63*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nUShort ); break; 64*cdf0e10cSrcweir case SbxCURRENCY: 65*cdf0e10cSrcweir nRes = p->nLong64; break; 66*cdf0e10cSrcweir case SbxLONG: 67*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nLong ); 68*cdf0e10cSrcweir break; 69*cdf0e10cSrcweir case SbxULONG: 70*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nULong ); 71*cdf0e10cSrcweir break; 72*cdf0e10cSrcweir case SbxSALINT64: 73*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nInt64 ); 74*cdf0e10cSrcweir break; 75*cdf0e10cSrcweir case SbxSALUINT64: 76*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( ImpSalUInt64ToDouble( p->uInt64 ) ); 77*cdf0e10cSrcweir break; 78*cdf0e10cSrcweir case SbxSINGLE: 79*cdf0e10cSrcweir if( p->nSingle > SbxMAXCURR ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir else if( p->nSingle < SbxMINCURR ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir else 88*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)p->nSingle ); 89*cdf0e10cSrcweir break; 90*cdf0e10cSrcweir case SbxDATE: 91*cdf0e10cSrcweir case SbxDOUBLE: 92*cdf0e10cSrcweir if( p->nDouble > SbxMAXCURR ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir else if( p->nDouble < SbxMINCURR ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir else 101*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( p->nDouble ); 102*cdf0e10cSrcweir break; 103*cdf0e10cSrcweir case SbxDECIMAL: 104*cdf0e10cSrcweir case SbxBYREF | SbxDECIMAL: 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir double d = 0.0; 107*cdf0e10cSrcweir if( p->pDecimal ) 108*cdf0e10cSrcweir p->pDecimal->getDouble( d ); 109*cdf0e10cSrcweir if( d > SbxMAXCURR ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir else if( d < SbxMINCURR ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir else 118*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( d ); 119*cdf0e10cSrcweir break; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir case SbxBYREF | SbxSTRING: 122*cdf0e10cSrcweir case SbxSTRING: 123*cdf0e10cSrcweir case SbxLPSTR: 124*cdf0e10cSrcweir if( !p->pOUString ) 125*cdf0e10cSrcweir nRes.SetNull(); 126*cdf0e10cSrcweir else 127*cdf0e10cSrcweir nRes = ImpStringToCurrency( *p->pOUString ); 128*cdf0e10cSrcweir break; 129*cdf0e10cSrcweir case SbxOBJECT: 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir SbxValue* pVal = PTR_CAST(SbxValue,p->pObj); 132*cdf0e10cSrcweir if( pVal ) 133*cdf0e10cSrcweir nRes = pVal->GetCurrency(); 134*cdf0e10cSrcweir else 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_OBJECT ); nRes.SetNull(); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir break; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir case SbxBYREF | SbxCHAR: 142*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)*p->pChar ); break; 143*cdf0e10cSrcweir case SbxBYREF | SbxBYTE: 144*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)*p->pByte ); break; 145*cdf0e10cSrcweir case SbxBYREF | SbxINTEGER: 146*cdf0e10cSrcweir case SbxBYREF | SbxBOOL: 147*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)*p->pInteger ); break; 148*cdf0e10cSrcweir case SbxBYREF | SbxERROR: 149*cdf0e10cSrcweir case SbxBYREF | SbxUSHORT: 150*cdf0e10cSrcweir nRes = ImpDoubleToCurrency( (double)*p->pUShort ); break; 151*cdf0e10cSrcweir case SbxBYREF | SbxCURRENCY: 152*cdf0e10cSrcweir nRes = *p->pLong64; break; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // ab hier muss getestet werden 155*cdf0e10cSrcweir case SbxBYREF | SbxLONG: 156*cdf0e10cSrcweir aTmp.nLong = *p->pLong; goto ref; 157*cdf0e10cSrcweir case SbxBYREF | SbxULONG: 158*cdf0e10cSrcweir aTmp.nULong = *p->pULong; goto ref; 159*cdf0e10cSrcweir case SbxBYREF | SbxSINGLE: 160*cdf0e10cSrcweir aTmp.nSingle = *p->pSingle; goto ref; 161*cdf0e10cSrcweir case SbxBYREF | SbxDATE: 162*cdf0e10cSrcweir case SbxBYREF | SbxDOUBLE: 163*cdf0e10cSrcweir aTmp.nDouble = *p->pDouble; goto ref; 164*cdf0e10cSrcweir case SbxBYREF | SbxSALINT64: 165*cdf0e10cSrcweir aTmp.nInt64 = *p->pnInt64; goto ref; 166*cdf0e10cSrcweir case SbxBYREF | SbxSALUINT64: 167*cdf0e10cSrcweir aTmp.uInt64 = *p->puInt64; goto ref; 168*cdf0e10cSrcweir ref: 169*cdf0e10cSrcweir aTmp.eType = SbxDataType( p->eType & 0x0FFF ); 170*cdf0e10cSrcweir p = &aTmp; goto start; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir default: 173*cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION ); nRes.SetNull(); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir return nRes; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void ImpPutCurrency( SbxValues* p, const SbxINT64 &r ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir double dVal = ImpCurrencyToDouble( r ); 181*cdf0e10cSrcweir SbxValues aTmp; 182*cdf0e10cSrcweir start: 183*cdf0e10cSrcweir switch( +p->eType ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir // Hier sind Tests notwendig 186*cdf0e10cSrcweir case SbxCHAR: 187*cdf0e10cSrcweir aTmp.pChar = &p->nChar; goto direct; 188*cdf0e10cSrcweir case SbxBYTE: 189*cdf0e10cSrcweir aTmp.pByte = &p->nByte; goto direct; 190*cdf0e10cSrcweir case SbxINTEGER: 191*cdf0e10cSrcweir case SbxBOOL: 192*cdf0e10cSrcweir aTmp.pInteger = &p->nInteger; goto direct; 193*cdf0e10cSrcweir case SbxLONG: 194*cdf0e10cSrcweir aTmp.pLong = &p->nLong; goto direct; 195*cdf0e10cSrcweir case SbxULONG: 196*cdf0e10cSrcweir aTmp.pULong = &p->nULong; goto direct; 197*cdf0e10cSrcweir case SbxERROR: 198*cdf0e10cSrcweir case SbxUSHORT: 199*cdf0e10cSrcweir aTmp.pUShort = &p->nUShort; goto direct; 200*cdf0e10cSrcweir direct: 201*cdf0e10cSrcweir aTmp.eType = SbxDataType( p->eType | SbxBYREF ); 202*cdf0e10cSrcweir p = &aTmp; goto start; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // ab hier nicht mehr 205*cdf0e10cSrcweir case SbxSINGLE: 206*cdf0e10cSrcweir p->nSingle = (float)dVal; break; 207*cdf0e10cSrcweir case SbxDATE: 208*cdf0e10cSrcweir case SbxDOUBLE: 209*cdf0e10cSrcweir p->nDouble = dVal; break; 210*cdf0e10cSrcweir case SbxSALINT64: 211*cdf0e10cSrcweir p->nInt64 = ImpDoubleToSalInt64( dVal ); break; 212*cdf0e10cSrcweir case SbxSALUINT64: 213*cdf0e10cSrcweir p->uInt64 = ImpDoubleToSalUInt64( dVal ); break; 214*cdf0e10cSrcweir case SbxCURRENCY: 215*cdf0e10cSrcweir p->nLong64 = r; break; 216*cdf0e10cSrcweir case SbxDECIMAL: 217*cdf0e10cSrcweir case SbxBYREF | SbxDECIMAL: 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir SbxDecimal* pDec = ImpCreateDecimal( p ); 220*cdf0e10cSrcweir if( !pDec->setDouble( dVal ) ) 221*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); 222*cdf0e10cSrcweir break; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir case SbxBYREF | SbxSTRING: 225*cdf0e10cSrcweir case SbxSTRING: 226*cdf0e10cSrcweir case SbxLPSTR: 227*cdf0e10cSrcweir if( !p->pOUString ) 228*cdf0e10cSrcweir p->pOUString = new ::rtl::OUString; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir *p->pOUString = ImpCurrencyToString( r ); 231*cdf0e10cSrcweir break; 232*cdf0e10cSrcweir case SbxOBJECT: 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir SbxValue* pVal = PTR_CAST(SbxValue,p->pObj); 235*cdf0e10cSrcweir if( pVal ) 236*cdf0e10cSrcweir pVal->PutCurrency( r ); 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_OBJECT ); 239*cdf0e10cSrcweir break; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir case SbxBYREF | SbxCHAR: 242*cdf0e10cSrcweir if( dVal > SbxMAXCHAR ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXCHAR; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir else if( dVal < SbxMINCHAR ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINCHAR; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir *p->pChar = (xub_Unicode) dVal; break; 251*cdf0e10cSrcweir case SbxBYREF | SbxBYTE: 252*cdf0e10cSrcweir if( dVal > SbxMAXBYTE ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXBYTE; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir else if( dVal < 0 ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir *p->pByte = (sal_uInt8) dVal; break; 261*cdf0e10cSrcweir case SbxBYREF | SbxINTEGER: 262*cdf0e10cSrcweir case SbxBYREF | SbxBOOL: 263*cdf0e10cSrcweir if( dVal > SbxMAXINT ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXINT; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir else if( dVal < SbxMININT ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMININT; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir *p->pInteger = (sal_Int16) dVal; break; 272*cdf0e10cSrcweir case SbxBYREF | SbxERROR: 273*cdf0e10cSrcweir case SbxBYREF | SbxUSHORT: 274*cdf0e10cSrcweir if( dVal > SbxMAXUINT ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXUINT; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir else if( dVal < 0 ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir *p->pUShort = (sal_uInt16) dVal; break; 283*cdf0e10cSrcweir case SbxBYREF | SbxLONG: 284*cdf0e10cSrcweir if( dVal > SbxMAXLNG ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXLNG; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir else if( dVal < SbxMINLNG ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINLNG; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir *p->pLong = (sal_Int32) dVal; break; 293*cdf0e10cSrcweir case SbxBYREF | SbxULONG: 294*cdf0e10cSrcweir if( dVal > SbxMAXULNG ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXULNG; 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir else if( dVal < 0 ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir *p->pULong = (sal_uInt32) dVal; break; 303*cdf0e10cSrcweir case SbxBYREF | SbxSALINT64: 304*cdf0e10cSrcweir *p->pnInt64 = ImpDoubleToSalInt64( dVal ); break; 305*cdf0e10cSrcweir case SbxBYREF | SbxSALUINT64: 306*cdf0e10cSrcweir *p->puInt64 = ImpDoubleToSalUInt64( dVal ); break; 307*cdf0e10cSrcweir case SbxBYREF | SbxSINGLE: 308*cdf0e10cSrcweir *p->pSingle = (float) dVal; break; 309*cdf0e10cSrcweir case SbxBYREF | SbxDATE: 310*cdf0e10cSrcweir case SbxBYREF | SbxDOUBLE: 311*cdf0e10cSrcweir *p->pDouble = (double) dVal; break; 312*cdf0e10cSrcweir case SbxBYREF | SbxCURRENCY: 313*cdf0e10cSrcweir *p->pLong64 = r; break; 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir default: 316*cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION ); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir // Hilfs-Funktionen zur Wandlung 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir static ::rtl::OUString ImpCurrencyToString( const SbxINT64 &r ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir BigInt a10000 = 10000; 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir //return GetpApp()->GetAppInternational().GetCurr( BigInt( r ), 4 ); 327*cdf0e10cSrcweir BigInt aInt( r ); 328*cdf0e10cSrcweir aInt.Abs(); 329*cdf0e10cSrcweir BigInt aFrac = aInt; 330*cdf0e10cSrcweir aInt /= a10000; 331*cdf0e10cSrcweir aFrac %= a10000; 332*cdf0e10cSrcweir aFrac += a10000; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir ::rtl::OUString aString; 335*cdf0e10cSrcweir if( r.nHigh < 0 ) 336*cdf0e10cSrcweir aString = ::rtl::OUString( (sal_Unicode)'-' ); 337*cdf0e10cSrcweir aString += aInt.GetString(); 338*cdf0e10cSrcweir aString += ::rtl::OUString( (sal_Unicode)'.' ); 339*cdf0e10cSrcweir aString += aFrac.GetString().GetBuffer()+1; 340*cdf0e10cSrcweir return aString; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir static SbxINT64 ImpStringToCurrency( const ::rtl::OUString &r ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir int nDec = 4; 346*cdf0e10cSrcweir String aStr; 347*cdf0e10cSrcweir const sal_Unicode* p = r.getStr(); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir if( *p == '-' ) 350*cdf0e10cSrcweir aStr += *p++; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir while( *p >= '0' && *p <= '9' ) { 353*cdf0e10cSrcweir aStr += *p++; 354*cdf0e10cSrcweir if( *p == ',' ) 355*cdf0e10cSrcweir p++; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if( *p == '.' ) { 359*cdf0e10cSrcweir p++; 360*cdf0e10cSrcweir while( nDec && *p >= '0' && *p <= '9' ) { 361*cdf0e10cSrcweir aStr += *p++; 362*cdf0e10cSrcweir nDec--; 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir while( nDec ) { 366*cdf0e10cSrcweir aStr += '0'; 367*cdf0e10cSrcweir nDec--; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir BigInt aBig( aStr ); 371*cdf0e10cSrcweir SbxINT64 nRes; 372*cdf0e10cSrcweir aBig.INT64( &nRes ); 373*cdf0e10cSrcweir return nRes; 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir double ImpINT64ToDouble( const SbxINT64 &r ) 377*cdf0e10cSrcweir { return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir SbxINT64 ImpDoubleToINT64( double d ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir SbxINT64 nRes; 382*cdf0e10cSrcweir nRes.Set( d ); 383*cdf0e10cSrcweir return nRes; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir double ImpUINT64ToDouble( const SbxUINT64 &r ) 387*cdf0e10cSrcweir { return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir SbxUINT64 ImpDoubleToUINT64( double d ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir SbxUINT64 nRes; 392*cdf0e10cSrcweir nRes.Set( d ); 393*cdf0e10cSrcweir return nRes; 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396