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
252542d5
Kaydet (Commit)
252542d5
authored
Mar 19, 2004
tarafından
Oliver Bolte
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
INTEGRATION: CWS qadev16 (1.1.2); FILE ADDED
2004/02/10 15:04:25 lla 1.1.2.1: #114786# new/old test/helper files
üst
9016dfbf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
0 deletions
+107
-0
float.cxx
testshl2/workben/garbage_dump/float.cxx
+107
-0
No files found.
testshl2/workben/garbage_dump/float.cxx
0 → 100644
Dosyayı görüntüle @
252542d5
#include <stdio.h>
#include <double>
#include <math.h> // fabs()
// #include <sal/types.h>
#define sal_Int16 short
#define SAL_CALL
// LLA: from kernel.h
/*
* min()/max() macros that also do
* strict type-checking.. See the
* "unnecessary" pointer comparison.
*/
#define MIN(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define MAX(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
//------------------------------------------------------------------------
// testing the method toDouble()
//------------------------------------------------------------------------
template
<
class
T
>
sal_Int16
SAL_CALL
test_rtl_OString_checkPrecisionSize
()
{
sal_Int16
nSize
=
sizeof
(
T
);
T
nCalcValue
=
1.0
;
// (i + 1) is the current precision
sal_Int16
i
=
0
;
for
(
i
=
0
;
i
<
50
;
i
++
)
{
nCalcValue
*=
10
;
T
nValue
=
nCalcValue
+
0.1
;
T
dSub
=
nValue
-
nCalcValue
;
// ----- 0.11 ---- 0.1 ---- 0.09 -----
if
(
0.11
>
dSub
&&
dSub
<
0.09
)
{
// due to the fact, that the value is break down we sub 1 from the precision value
// but to suppress this, we start at zero, precision is i+1 till here --i;
break
;
}
}
sal_Int16
j
=
0
;
nCalcValue
=
1.0
;
for
(
j
=
0
;
j
<
50
;
j
++
)
{
nCalcValue
/=
10
;
T
nValue
=
nCalcValue
+
1.0
;
T
dSub
=
nValue
-
1.0
;
// ---- 0.02 ----- 0.01 ---- 0 --- -0.99 ---- -0.98 ----
T
dSubAbsolut
=
fabs
(
dSub
);
// ---- 0.02 ----- 0.01 ---- 0 (cut)
if
(
dSub
==
0
)
break
;
}
if
(
i
!=
j
)
{
// hmmm....
// imho i +- 1 == j is a good value
int
n
=
i
-
j
;
if
(
n
<
0
)
n
=
-
n
;
if
(
n
<=
1
)
{
return
MIN
(
i
,
j
);
}
else
{
printf
(
"warning: presision differs more than 1"
);
}
}
return
i
;
}
void
SAL_CALL
test_precision
(
)
{
sal_Int16
nPrecision
;
nPrecision
=
test_rtl_OString_checkPrecisionSize
<
float
>
();
nPrecision
=
test_rtl_OString_checkPrecisionSize
<
double
>
();
nPrecision
=
test_rtl_OString_checkPrecisionSize
<
long
double
>
();
nPrecision
=
test_rtl_OString_checkPrecisionSize
<
Double
>
();
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
test_precision
();
return
0
;
}
// The following sets variables for GNU EMACS
// Local Variables:
// tab-width:4
// End:
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