Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
58b09c2b
Kaydet (Commit)
58b09c2b
authored
Eyl 14, 2010
tarafından
obo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
CWS-TOOLING: integrate CWS dba33h
üst
8c29f37b
46647dbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
146 deletions
+166
-146
math.h
sal/inc/rtl/math.h
+10
-10
math.cxx
sal/rtl/source/math.cxx
+156
-136
No files found.
sal/inc/rtl/math.h
Dosyayı görüntüle @
58b09c2b
...
@@ -140,9 +140,8 @@ enum rtl_math_DecimalPlaces
...
@@ -140,9 +140,8 @@ enum rtl_math_DecimalPlaces
/** Conversions analogous to sprintf() using internal rounding.
/** Conversions analogous to sprintf() using internal rounding.
+/-HUGE_VAL are converted to "1.#INF" and "-1.#INF", NAN values are
+/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
converted to "1.#NAN" and "-1.#NAN", of course using cDecSeparator instead
converted to "NaN".
of '.'.
@param pResult
@param pResult
Returns the resulting byte string. Must itself not be null, and must point
Returns the resulting byte string. Must itself not be null, and must point
...
@@ -216,9 +215,8 @@ void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
...
@@ -216,9 +215,8 @@ void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
/** Conversions analogous to sprintf() using internal rounding.
/** Conversions analogous to sprintf() using internal rounding.
+/-HUGE_VAL are converted to "1.#INF" and "-1.#INF", NAN values are
+/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
converted to "1.#NAN" and "-1.#NAN", of course using cDecSeparator instead
converted to "NaN".
of '.'.
@param pResult
@param pResult
Returns the resulting Unicode string. Must itself not be null, and must
Returns the resulting Unicode string. Must itself not be null, and must
...
@@ -296,8 +294,9 @@ void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
...
@@ -296,8 +294,9 @@ void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns
Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns
+/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+/-HUGE_VAL, underflow 0. In both cases pStatus is set to
rtl_math_ConversionStatus_OutOfRange, otherwise to
rtl_math_ConversionStatus_OutOfRange, otherwise to
rtl_math_ConversionStatus_Ok. "+/-1.#INF" is recognized as +/-HUGE_VAL,
rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
pStatus is set to rtl_math_ConversionStatus_OutOfRange. "+/-1.#NAN" is
recognized as +/-HUGE_VAL, pStatus is set to
rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
recognized and the value is set to +/-NAN, pStatus is set to
recognized and the value is set to +/-NAN, pStatus is set to
rtl_math_ConversionStatus_Ok.
rtl_math_ConversionStatus_Ok.
...
@@ -333,8 +332,9 @@ double SAL_CALL rtl_math_stringToDouble(
...
@@ -333,8 +332,9 @@ double SAL_CALL rtl_math_stringToDouble(
Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns
Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns
+/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+/-HUGE_VAL, underflow 0. In both cases pStatus is set to
rtl_math_ConversionStatus_OutOfRange, otherwise to
rtl_math_ConversionStatus_OutOfRange, otherwise to
rtl_math_ConversionStatus_Ok. "+/-1.#INF" is recognized as +/-HUGE_VAL,
rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
pStatus is set to rtl_math_ConversionStatus_OutOfRange. "+/-1.#NAN" is
recognized as +/-HUGE_VAL, pStatus is set to
rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
recognized and the value is set to +/-NAN, pStatus is set to
recognized and the value is set to +/-NAN, pStatus is set to
rtl_math_ConversionStatus_Ok.
rtl_math_ConversionStatus_Ok.
...
...
sal/rtl/source/math.cxx
Dosyayı görüntüle @
58b09c2b
...
@@ -318,44 +318,37 @@ inline void doubleToString(StringT ** pResult,
...
@@ -318,44 +318,37 @@ inline void doubleToString(StringT ** pResult,
if
(
rtl
::
math
::
isNan
(
fValue
)
)
if
(
rtl
::
math
::
isNan
(
fValue
)
)
{
{
sal_Int32
nCapacity
=
RTL_CONSTASCII_LENGTH
(
"-1.#NAN"
);
// #i112652# XMLSchema-2
sal_Int32
nCapacity
=
RTL_CONSTASCII_LENGTH
(
"NaN"
);
if
(
pResultCapacity
==
0
)
if
(
pResultCapacity
==
0
)
{
{
pResultCapacity
=
&
nCapacity
;
pResultCapacity
=
&
nCapacity
;
T
::
createBuffer
(
pResult
,
pResultCapacity
);
T
::
createBuffer
(
pResult
,
pResultCapacity
);
nResultOffset
=
0
;
nResultOffset
=
0
;
}
}
if
(
bSign
)
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"-"
));
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"1"
));
T
::
appendChar
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
cDecSeparator
);
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"#NAN"
));
RTL_CONSTASCII_STRINGPARAM
(
"NaN"
));
return
;
return
;
}
}
bool
bHuge
=
fValue
==
HUGE_VAL
;
// g++ 3.0.1 requires it this way...
bool
bHuge
=
fValue
==
HUGE_VAL
;
// g++ 3.0.1 requires it this way...
if
(
bHuge
||
rtl
::
math
::
isInf
(
fValue
)
)
if
(
bHuge
||
rtl
::
math
::
isInf
(
fValue
)
)
{
{
sal_Int32
nCapacity
=
RTL_CONSTASCII_LENGTH
(
"-1.#INF"
);
// #i112652# XMLSchema-2
sal_Int32
nCapacity
=
RTL_CONSTASCII_LENGTH
(
"-INF"
);
if
(
pResultCapacity
==
0
)
if
(
pResultCapacity
==
0
)
{
{
pResultCapacity
=
&
nCapacity
;
pResultCapacity
=
&
nCapacity
;
T
::
createBuffer
(
pResult
,
pResultCapacity
);
T
::
createBuffer
(
pResult
,
pResultCapacity
);
nResultOffset
=
0
;
nResultOffset
=
0
;
}
}
if
(
bSign
)
if
(
bSign
)
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"-"
));
RTL_CONSTASCII_STRINGPARAM
(
"-"
));
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"1"
));
RTL_CONSTASCII_STRINGPARAM
(
"INF"
));
T
::
appendChar
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
cDecSeparator
);
T
::
appendAscii
(
pResult
,
pResultCapacity
,
&
nResultOffset
,
RTL_CONSTASCII_STRINGPARAM
(
"#INF"
));
return
;
return
;
}
}
...
@@ -736,158 +729,185 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
...
@@ -736,158 +729,185 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
++
p0
;
++
p0
;
}
}
CharT
const
*
p
=
p0
;
CharT
const
*
p
=
p0
;
bool
bDone
=
false
;
// leading zeros and group separators may be safely ignored
// #i112652# XMLSchema-2
while
(
p
!=
pEnd
&&
(
*
p
==
CharT
(
'0'
)
||
*
p
==
cGroupSeparator
))
if
(
3
>=
(
pEnd
-
p
))
++
p
;
long
nValExp
=
0
;
// carry along exponent of mantissa
// integer part of mantissa
for
(;
p
!=
pEnd
;
++
p
)
{
{
CharT
c
=
*
p
;
if
((
CharT
(
'N'
)
==
p
[
0
])
&&
(
CharT
(
'a'
)
==
p
[
1
])
if
(
isDigit
(
c
))
&&
(
CharT
(
'N'
)
==
p
[
2
]
))
{
{
fVal
=
fVal
*
10.0
+
static_cast
<
double
>
(
c
-
CharT
(
'0'
)
);
p
+=
3
;
++
nValExp
;
rtl
::
math
::
setNan
(
&
fVal
);
bDone
=
true
;
}
else
if
((
CharT
(
'I'
)
==
p
[
0
])
&&
(
CharT
(
'N'
)
==
p
[
1
])
&&
(
CharT
(
'F'
)
==
p
[
2
]))
{
p
+=
3
;
fVal
=
HUGE_VAL
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
bDone
=
true
;
}
}
else
if
(
c
!=
cGroupSeparator
)
break
;
}
}
// fraction part of mantissa
if
(
!
bDone
)
// do not recognize e.g. NaN1.23
if
(
p
!=
pEnd
&&
*
p
==
cDecSeparator
)
{
{
++
p
;
// leading zeros and group separators may be safely ignored
double
fFrac
=
0.0
;
while
(
p
!=
pEnd
&&
(
*
p
==
CharT
(
'0'
)
||
*
p
==
cGroupSeparator
))
long
nFracExp
=
0
;
while
(
p
!=
pEnd
&&
*
p
==
CharT
(
'0'
))
{
--
nFracExp
;
++
p
;
++
p
;
}
if
(
nValExp
==
0
)
long
nValExp
=
0
;
// carry along exponent of mantissa
nValExp
=
nFracExp
-
1
;
// no integer part => fraction exponent
// one decimal digit needs ld(10) ~= 3.32 bits
// integer part of mantissa
static
const
int
nSigs
=
(
DBL_MANT_DIG
/
3
)
+
1
;
int
nDigs
=
0
;
for
(;
p
!=
pEnd
;
++
p
)
for
(;
p
!=
pEnd
;
++
p
)
{
{
CharT
c
=
*
p
;
CharT
c
=
*
p
;
if
(
!
isDigit
(
c
))
if
(
isDigit
(
c
))
break
;
{
if
(
nDigs
<
nSigs
)
fVal
=
fVal
*
10.0
+
static_cast
<
double
>
(
c
-
CharT
(
'0'
)
);
{
// further digits (more than nSigs) don't have any significance
++
nValExp
;
fFrac
=
fFrac
*
10.0
+
static_cast
<
double
>
(
c
-
CharT
(
'0'
)
);
--
nFracExp
;
++
nDigs
;
}
}
else
if
(
c
!=
cGroupSeparator
)
break
;
}
}
if
(
fFrac
!=
0.0
)
fVal
+=
rtl
::
math
::
pow10Exp
(
fFrac
,
nFracExp
);
else
if
(
nValExp
<
0
)
nValExp
=
0
;
// no digit other than 0 after decimal point
}
if
(
nValExp
>
0
)
--
nValExp
;
// started with offset +1 at the first mantissa digit
// Exponent
// fraction part of mantissa
if
(
p
!=
p0
&&
p
!=
pEnd
&&
(
*
p
==
CharT
(
'E'
)
||
*
p
==
CharT
(
'e'
)))
if
(
p
!=
pEnd
&&
*
p
==
cDecSeparator
)
{
++
p
;
bool
bExpSign
;
if
(
p
!=
pEnd
&&
*
p
==
CharT
(
'-'
))
{
{
bExpSign
=
true
;
++
p
;
++
p
;
}
double
fFrac
=
0.0
;
else
long
nFracExp
=
0
;
{
while
(
p
!=
pEnd
&&
*
p
==
CharT
(
'0'
))
bExpSign
=
false
;
{
if
(
p
!=
pEnd
&&
*
p
==
CharT
(
'+'
))
--
nFracExp
;
++
p
;
}
if
(
fVal
==
0.0
)
{
// no matter what follows, zero stays zero, but carry on the offset
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
++
p
;
++
p
;
}
}
else
if
(
nValExp
==
0
)
{
nValExp
=
nFracExp
-
1
;
// no integer part => fraction exponent
bool
bOverFlow
=
false
;
// one decimal digit needs ld(10) ~= 3.32 bits
long
nExp
=
0
;
static
const
int
nSigs
=
(
DBL_MANT_DIG
/
3
)
+
1
;
int
nDigs
=
0
;
for
(;
p
!=
pEnd
;
++
p
)
for
(;
p
!=
pEnd
;
++
p
)
{
{
CharT
c
=
*
p
;
CharT
c
=
*
p
;
if
(
!
isDigit
(
c
))
if
(
!
isDigit
(
c
))
break
;
break
;
int
i
=
c
-
CharT
(
'0'
);
if
(
nDigs
<
nSigs
)
if
(
long10Overflow
(
nExp
,
i
)
)
{
// further digits (more than nSigs) don't have any
bOverFlow
=
true
;
// significance
else
fFrac
=
fFrac
*
10.0
+
static_cast
<
double
>
(
c
-
CharT
(
'0'
));
nExp
=
nExp
*
10
+
i
;
--
nFracExp
;
}
++
nDigs
;
if
(
nExp
)
{
if
(
bExpSign
)
nExp
=
-
nExp
;
long
nAllExp
=
(
bOverFlow
?
0
:
nExp
+
nValExp
);
if
(
nAllExp
>
DBL_MAX_10_EXP
||
(
bOverFlow
&&
!
bExpSign
)
)
{
// overflow
fVal
=
HUGE_VAL
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
}
else
if
(
nAllExp
<
DBL_MIN_10_EXP
||
(
bOverFlow
&&
bExpSign
)
)
{
// underflow
fVal
=
0.0
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
}
else
if
(
nExp
>
DBL_MAX_10_EXP
||
nExp
<
DBL_MIN_10_EXP
)
{
// compensate exponents
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
-
nValExp
);
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
nAllExp
);
}
}
else
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
nExp
);
// normal
}
}
if
(
fFrac
!=
0.0
)
fVal
+=
rtl
::
math
::
pow10Exp
(
fFrac
,
nFracExp
);
else
if
(
nValExp
<
0
)
nValExp
=
0
;
// no digit other than 0 after decimal point
}
}
}
else
if
(
p
-
p0
==
2
&&
p
!=
pEnd
&&
p
[
0
]
==
CharT
(
'#'
)
if
(
nValExp
>
0
)
&&
p
[
-
1
]
==
cDecSeparator
&&
p
[
-
2
]
==
CharT
(
'1'
))
--
nValExp
;
// started with offset +1 at the first mantissa digit
{
if
(
pEnd
-
p
>=
4
&&
p
[
1
]
==
CharT
(
'I'
)
&&
p
[
2
]
==
CharT
(
'N'
)
// Exponent
&&
p
[
3
]
==
CharT
(
'F'
))
if
(
p
!=
p0
&&
p
!=
pEnd
&&
(
*
p
==
CharT
(
'E'
)
||
*
p
==
CharT
(
'e'
)
))
{
{
// "1.#INF", "+1.#INF", "-1.#INF"
++
p
;
p
+=
4
;
bool
bExpSign
;
fVal
=
HUGE_VAL
;
if
(
p
!=
pEnd
&&
*
p
==
CharT
(
'-'
))
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
{
// Eat any further digits:
bExpSign
=
true
;
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
++
p
;
++
p
;
}
else
{
bExpSign
=
false
;
if
(
p
!=
pEnd
&&
*
p
==
CharT
(
'+'
))
++
p
;
}
if
(
fVal
==
0.0
)
{
// no matter what follows, zero stays zero, but carry on the
// offset
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
++
p
;
}
else
{
bool
bOverFlow
=
false
;
long
nExp
=
0
;
for
(;
p
!=
pEnd
;
++
p
)
{
CharT
c
=
*
p
;
if
(
!
isDigit
(
c
))
break
;
int
i
=
c
-
CharT
(
'0'
);
if
(
long10Overflow
(
nExp
,
i
)
)
bOverFlow
=
true
;
else
nExp
=
nExp
*
10
+
i
;
}
if
(
nExp
)
{
if
(
bExpSign
)
nExp
=
-
nExp
;
long
nAllExp
=
(
bOverFlow
?
0
:
nExp
+
nValExp
);
if
(
nAllExp
>
DBL_MAX_10_EXP
||
(
bOverFlow
&&
!
bExpSign
)
)
{
// overflow
fVal
=
HUGE_VAL
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
}
else
if
((
nAllExp
<
DBL_MIN_10_EXP
)
||
(
bOverFlow
&&
bExpSign
)
)
{
// underflow
fVal
=
0.0
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
}
else
if
(
nExp
>
DBL_MAX_10_EXP
||
nExp
<
DBL_MIN_10_EXP
)
{
// compensate exponents
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
-
nValExp
);
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
nAllExp
);
}
else
fVal
=
rtl
::
math
::
pow10Exp
(
fVal
,
nExp
);
// normal
}
}
}
}
else
if
(
p
End
-
p
>=
4
&&
p
[
1
]
==
CharT
(
'N'
)
&&
p
[
2
]
==
CharT
(
'A
'
)
else
if
(
p
-
p0
==
2
&&
p
!=
pEnd
&&
p
[
0
]
==
CharT
(
'#
'
)
&&
p
[
3
]
==
CharT
(
'N
'
))
&&
p
[
-
1
]
==
cDecSeparator
&&
p
[
-
2
]
==
CharT
(
'1
'
))
{
{
// "1.#NAN", "+1.#NAN", "-1.#NAN"
if
(
pEnd
-
p
>=
4
&&
p
[
1
]
==
CharT
(
'I'
)
&&
p
[
2
]
==
CharT
(
'N'
)
p
+=
4
;
&&
p
[
3
]
==
CharT
(
'F'
))
rtl
::
math
::
setNan
(
&
fVal
);
if
(
bSign
)
{
{
union
{
// "1.#INF", "+1.#INF", "-1.#INF"
double
sd
;
p
+=
4
;
sal_math_Double
md
;
fVal
=
HUGE_VAL
;
}
m
;
eStatus
=
rtl_math_ConversionStatus_OutOfRange
;
m
.
sd
=
fVal
;
// Eat any further digits:
m
.
md
.
w32_parts
.
msw
|=
0x80000000
;
// create negative NaN
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
fVal
=
m
.
sd
;
++
p
;
bSign
=
false
;
// don't negate again
}
else
if
(
pEnd
-
p
>=
4
&&
p
[
1
]
==
CharT
(
'N'
)
&&
p
[
2
]
==
CharT
(
'A'
)
&&
p
[
3
]
==
CharT
(
'N'
))
{
// "1.#NAN", "+1.#NAN", "-1.#NAN"
p
+=
4
;
rtl
::
math
::
setNan
(
&
fVal
);
if
(
bSign
)
{
union
{
double
sd
;
sal_math_Double
md
;
}
m
;
m
.
sd
=
fVal
;
m
.
md
.
w32_parts
.
msw
|=
0x80000000
;
// create negative NaN
fVal
=
m
.
sd
;
bSign
=
false
;
// don't negate again
}
// Eat any further digits:
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
++
p
;
}
}
// Eat any further digits:
while
(
p
!=
pEnd
&&
isDigit
(
*
p
))
++
p
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment