summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2011-10-20 23:08:45 -0400
committerMichael Meeks <michael.meeks@suse.com>2011-10-21 15:10:13 +0100
commit556a61a2f86fef1f828b8352fae7a4c4ed1fdd78 (patch)
tree281f7bf86f4038a7bf05fe66af3cdfb4085e22fa /basic
parent71f4a57b2af6c61533176100e39ce8b4276e807b (diff)
Added Frac function to calc formulas and BASIC standard library
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods1.cxx20
-rw-r--r--basic/source/runtime/rtlproto.hxx1
-rw-r--r--basic/source/runtime/stdobj.cxx2
3 files changed, 23 insertions, 0 deletions
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index f54ff7baea4f..8802245b6498 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -2531,6 +2531,26 @@ RTLFUNC(FormatDateTime)
rPar.Get(0)->PutString( aRetStr );
}
+RTLFUNC(Frac)
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ sal_uInt16 nParCount = rPar.Count();
+ if( nParCount != 2)
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ SbxVariable *pSbxVariable = rPar.Get(1);
+ double dVal = pSbxVariable->GetDouble();
+ if(dVal >= 0)
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxFloor(dVal));
+ else
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxCeil(dVal));
+}
+
RTLFUNC(Round)
{
(void)pBasic;
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index 469cd0f0afe6..101c320bfb2a 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -250,6 +250,7 @@ extern RTLFUNC(Format);
extern RTLFUNC(GetAttr);
extern RTLFUNC(Randomize); // JSM
extern RTLFUNC(Round);
+extern RTLFUNC(Frac);
extern RTLFUNC(Rnd);
extern RTLFUNC(Shell);
extern RTLFUNC(VarType);
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 72ec66a88351..f384784cffef 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -295,6 +295,8 @@ static Methods aMethods[] = {
{ "FormatDateTime", SbxSTRING, 2 | _FUNCTION | _COMPATONLY, RTLNAME(FormatDateTime),0 },
{ "Date", SbxDATE, 0,NULL,0 },
{ "NamedFormat", SbxINTEGER, _OPT, NULL,0 },
+{ "Frac", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Frac),0 },
+ { "number", SbxDOUBLE, 0,NULL,0 },
{ "FRAMEANCHORCHAR", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORCHAR),0 },
{ "FRAMEANCHORPAGE", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORPAGE),0 },
{ "FRAMEANCHORPARA", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORPARA),0 },