View | Details | Raw Unified | Return to issue 114430
Collapse All | Expand All

(-)sal/inc/rtl/math.h (+17 lines)
Lines 24-29 Link Here
24
#if !defined INCLUDED_RTL_MATH_H
24
#if !defined INCLUDED_RTL_MATH_H
25
#define INCLUDED_RTL_MATH_H
25
#define INCLUDED_RTL_MATH_H
26
26
27
#define SAL_STRICTER_MATH
28
27
#include "rtl/ustring.h"
29
#include "rtl/ustring.h"
28
#include "sal/types.h"
30
#include "sal/types.h"
29
31
Lines 396-401 Link Here
396
 */
398
 */
397
double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
399
double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
398
400
401
/** Similar to pow() with stricter exception handling for indeterminate values.
402
403
    powr is intended to partially mimic the IEEE 754 2008 Floating Point Standard.
404
405
    @param fValue
406
    The value to be raised.
407
408
    @param fExp
409
    The exponent.
410
411
    @return
412
    powr(fValue, fExp)
413
 */
414
double SAL_CALL rtl_math_powr(double fValue, double fExp) SAL_THROW_EXTERN_C();
415
399
/** Rounds value to 15 significant decimal digits.
416
/** Rounds value to 15 significant decimal digits.
400
417
401
    @param fValue
418
    @param fValue
(-)sal/inc/rtl/math.hxx (+7 lines)
Lines 186-191 Link Here
186
    return rtl_math_pow10Exp(fValue, nExp);
186
    return rtl_math_pow10Exp(fValue, nExp);
187
}
187
}
188
188
189
/** A wrapper around rtl_math_powr.
190
 */
191
inline double powr(double fValue, double fExp)
192
{
193
    return rtl_math_powr(fValue, fExp);
194
}
195
189
/** A wrapper around rtl_math_approxValue.
196
/** A wrapper around rtl_math_approxValue.
190
 */
197
 */
191
inline double approxValue(double fValue)
198
inline double approxValue(double fValue)
(-)sal/rtl/source/math.cxx (+15 lines)
Lines 1113-1119 Link Here
1113
    return (fe-1.0) * fValue / log(fe);
1113
    return (fe-1.0) * fValue / log(fe);
1114
}
1114
}
1115
1115
1116
double SAL_CALL rtl_math_powr( double fValue,  double fExp ) SAL_THROW_EXTERN_C()
1117
{
1118
#ifdef SAL_STRICTER_MATH
1119
    if ((fValue == 0.0  && fExp == 0.0) ||
1120
	(rtl::math::isInf( fExp ) && !rtl::math::isSignBitSet( fExp )) ||
1121
	(rtl::math::isInf( fValue ) && !rtl::math::isSignBitSet( fValue )))
1122
    {
1123
        double fResult;
1124
        ::rtl::math::setNan( &fResult );
1125
        return fResult;
1126
    }
1127
#endif
1128
    return pow(fValue, fExp);
1129
}
1116
1130
1131
1117
double SAL_CALL rtl_math_log1p( double fValue ) SAL_THROW_EXTERN_C()
1132
double SAL_CALL rtl_math_log1p( double fValue ) SAL_THROW_EXTERN_C()
1118
{
1133
{
1119
    // Use volatile because a compiler may be too smart "optimizing" the
1134
    // Use volatile because a compiler may be too smart "optimizing" the
(-)sal/util/sal.map (+2 lines)
Lines 629-634 Link Here
629
    global:
629
    global:
630
        osl_loadAsciiModule;
630
        osl_loadAsciiModule;
631
        osl_loadAsciiModuleRelative;
631
        osl_loadAsciiModuleRelative;
632
633
        rtl_math_powr;
632
} UDK_3.11;
634
} UDK_3.11;
633
635
634
PRIVATE_1.0 {
636
PRIVATE_1.0 {
(-)sc/source/core/tool/interpr5.cxx (-3 / +3 lines)
Lines 1611-1624 Link Here
1611
            if (bFlag)
1611
            if (bFlag)
1612
            {   for ( SCSIZE i = 0; i < nCount; i++ )
1612
            {   for ( SCSIZE i = 0; i < nCount; i++ )
1613
                    if (pMat->IsValue(i))
1613
                    if (pMat->IsValue(i))
1614
                        pResMat->PutDouble(pow(fVal,pMat->GetDouble(i)), i);
1614
                        pResMat->PutDouble(::rtl::math::powr(fVal,pMat->GetDouble(i)), i);
1615
                    else
1615
                    else
1616
                        pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
1616
                        pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
1617
            }
1617
            }
1618
            else
1618
            else
1619
            {   for ( SCSIZE i = 0; i < nCount; i++ )
1619
            {   for ( SCSIZE i = 0; i < nCount; i++ )
1620
                    if (pMat->IsValue(i))
1620
                    if (pMat->IsValue(i))
1621
                        pResMat->PutDouble(pow(pMat->GetDouble(i),fVal), i);
1621
                        pResMat->PutDouble(::rtl::math::powr(pMat->GetDouble(i),fVal), i);
1622
                    else
1622
                    else
1623
                        pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
1623
                        pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
1624
            }
1624
            }
Lines 1628-1634 Link Here
1628
            PushIllegalArgument();
1628
            PushIllegalArgument();
1629
    }
1629
    }
1630
    else
1630
    else
1631
        PushDouble(pow(fVal1,fVal2));
1631
        PushDouble(::rtl::math::powr(fVal1,fVal2));
1632
}
1632
}
1633
1633
1634
void ScInterpreter::ScSumProduct()
1634
void ScInterpreter::ScSumProduct()

Return to issue 114430