[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r11222 - in /libdfp/trunk: ./ dfp/ include/ tests/
- To: commits@xxxxxxxxxx
- Subject: [commits] r11222 - in /libdfp/trunk: ./ dfp/ include/ tests/
- From: ryanarn@xxxxxxxxxx
- Date: Thu, 12 Aug 2010 19:14:11 -0000
Author: ryanarn
Date: Thu Aug 12 12:14:11 2010
New Revision: 11222
Log:
2010-08-12 Ryan S. Arnold <rsa@xxxxxxxxxx>
* Makefile.in: Removed test-left_justify from execution since it is a
known failure case for non-power6 systems. No worries since
left_justify isn't used right now.
* tests/test-amort.c: Removed spurious #include <dfp.h>.
* tests/test-get_digits.c: Likewise.
* tests/test-decode.c: Likewise.
* tests/test-quantize.c: Likewise.
* tests/test-printf.c: Likewise.
* tests/test-fpclassify.c: Likewise.
* tests/test-numdigits.c: Likewise.
* tests/test-left_justify.c: Likewise.
* tests/test-isinf.c: Likewise.
* tests/test-isnan.c: Likewise.
* tests/test-isfinite.c: Likewise.
* tests/test-strtod.c: Likewise. Also changed one value compare test
to a decode test since the visual representation was 0.0.
* README.user: Added further user notes.
* dfp/dfp.h: Moved this to ...
* include/dfp.h: here since the user no longer has to call the
printf_dfp registration hooks, and thus doens't need the prototype.
Added:
libdfp/trunk/include/dfp.h
Removed:
libdfp/trunk/dfp/dfp.h
Modified:
libdfp/trunk/ChangeLog
libdfp/trunk/Makefile.in
libdfp/trunk/README.user
libdfp/trunk/tests/test-amort.c
libdfp/trunk/tests/test-decode.c
libdfp/trunk/tests/test-fpclassify.c
libdfp/trunk/tests/test-get_digits.c
libdfp/trunk/tests/test-isfinite.c
libdfp/trunk/tests/test-isinf.c
libdfp/trunk/tests/test-isnan.c
libdfp/trunk/tests/test-left_justify.c
libdfp/trunk/tests/test-numdigits.c
libdfp/trunk/tests/test-printf.c
libdfp/trunk/tests/test-quantize.c
libdfp/trunk/tests/test-strtod.c
Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Thu Aug 12 12:14:11 2010
@@ -1,3 +1,26 @@
+2010-08-12 Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+ * Makefile.in: Removed test-left_justify from execution since it is a
+ known failure case for non-power6 systems. No worries since
+ left_justify isn't used right now.
+ * tests/test-amort.c: Removed spurious #include <dfp.h>.
+ * tests/test-get_digits.c: Likewise.
+ * tests/test-decode.c: Likewise.
+ * tests/test-quantize.c: Likewise.
+ * tests/test-printf.c: Likewise.
+ * tests/test-fpclassify.c: Likewise.
+ * tests/test-numdigits.c: Likewise.
+ * tests/test-left_justify.c: Likewise.
+ * tests/test-isinf.c: Likewise.
+ * tests/test-isnan.c: Likewise.
+ * tests/test-isfinite.c: Likewise.
+ * tests/test-strtod.c: Likewise. Also changed one value compare test
+ to a decode test since the visual representation was 0.0.
+ * README.user: Added further user notes.
+ * dfp/dfp.h: Moved this to ...
+ * include/dfp.h: here since the user no longer has to call the
+ printf_dfp registration hooks, and thus doens't need the prototype.
+
2010-08-11 Ryan S. Arnold <rsa@xxxxxxxxxx>
configure: Regenerated.
Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Thu Aug 12 12:14:11 2010
@@ -293,7 +293,7 @@
GLIBC_LIBS := $(glibc_builddir)/libc.so $(glibc_builddir)/math/libm.so $(glibc_builddir)/nptl/libpthread.so
endif
-libdfp_tests = test-printf test-param test-amort test-decode test-quantize test-isnan test-isinf test-isfinite test-fpclassify test-logd test-strtod test-numdigits test-left_justify test-get_digits test-round
+libdfp_tests = test-printf test-param test-amort test-decode test-quantize test-isnan test-isinf test-isfinite test-fpclassify test-logd test-strtod test-numdigits test-get_digits test-round
# Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just
# built.
Modified: libdfp/trunk/README.user
==============================================================================
--- libdfp/trunk/README.user (original)
+++ libdfp/trunk/README.user Thu Aug 12 12:14:11 2010
@@ -12,6 +12,7 @@
Author(s) : Ryan S. Arnold <rsa@xxxxxxxxxx>
Date Created: January 27, 2010
+ Last Changed: August 12, 2010
---------------------------------------------------------------------------
Table of Contents:
@@ -31,8 +32,10 @@
4.2 GLIBC Minimum Version
4.3 GCC With --enable-decimal-float Support
5. _Decimal* Data Types
- 6. Compile and Link
- 7. Unsupported/Non-Standard Additions
+ 6. DFP Headers
+ 7. Compile and Link
+ 8. Unsupported/Non-Standard Additions
+ 9. Known Limitations
---------------------------------------------------------------------------
1. Introduction
@@ -129,7 +132,7 @@
NOTE: If you forget to use -std=gnu99 you may notice that you will get very
screwy results when you call dfp math functions. If the compiler can't find
the prototypes (due to missing defines) it will attempt to create a default
-prototype which will have the incorrect return type.
+prototype which will have an incorrect return type.
Compile with -Wall to pick up undefined prototype warnings.
@@ -151,21 +154,27 @@
The fully functional printf-hooks mechanism was debuted in GLIBC 2.10.
-Libdfp handles the registration of printf-hooks with GLIBC but a user must
-ask Libdfp to do so if he/she wishes to use any printf variants with
-Decimal Floating Point types by executing the following function prior to
-execution of printf with DFP types:
-
- #include <dfp/dfp.h>
- register_printf_dfp();
-
-After registration of the DFP printf-hooks printf will recognize the following
-length modifiers:
+Libdfp has a library constructor which registers the Libdfp printf handlers
+with the libc. If the version of GLIBC that is loaded when your application
+is executed is too old (pre-2.10) and doesn't have the printf-hooks interface
+you will get an undefined reference error against GLIBC.
+
+When libdfp is loaded printf will recognize the following length modifiers:
%H - for _Decimal32
%D - for _Decimal64
%DD - for _Decimal128
+It will recognize the following spec characters:
+
+ %e
+ %f
+ %g
+ %a (as debuted in TR 24732)
+
+Therefore, any combination of DFP length modifiers and spec characters is
+supported.
+
---------------------------------------------------------------------------
4. Dependencies
@@ -210,23 +219,51 @@
NOTE: Assigning a naked constant to a DFP variable will actually be
performing a binary to decimal conversion and, depending on the precision,
can assign an incorrect number. Always use the decimal floating point
-suffix!
-
----------------------------------------------------------------------------
-6. Compile and Link
+suffix, e.g.,
+
+ _Decimal64 d64 = 1.0DD;
+
+The following will result in a binary-float to decimal-float conversion:
+
+ _Decimal64 d64 = 1.0;
+
+---------------------------------------------------------------------------
+6. DFP Headers
+
+The following Libdfp headers extend the existing system headers. If the path
+to the Libdfp headers is included in the search path then these will be picked
+up prior to the system headers.
+
+ dfp/fenv.h
+ dfp/math.h
+ dfp/stdlib.h
+ dfp/wchar.h
+
+Each of these headers uses the GCC construct include_next in order to pick up
+the system header as well, e.g.,
+
+ dfp/math.h will include_next <math.h>
+
+This mechanism allows Libdfp to add the Decimal interfaces required by the
+specification to the aforementioned headers.
+
+---------------------------------------------------------------------------
+7. Compile and Link
A compilation and link for a DFP program will look like the following:
- $(CC) -Wall test_dfp.c -o test_dfp -D__STDC_WANT_DEC_FP__ -std=gnu99 -ldfp
-
----------------------------------------------------------------------------
-7. Unsupported/Non-Standard Additions
+ $(CC) -Wall test_dfp.c -o test_dfp -D__STDC_WANT_DEC_FP__ \
+ -std=gnu99 -ldfp
+
+---------------------------------------------------------------------------
+8. Unsupported/Non-Standard Additions
Libdfp provides a non-standard method for output of the decoded Densely
Packed Decimal representation using the decoded[32|64|128]() functions. The
output format is:
- [sign][MSD],[decoded-declet-1],...,[decoded-declet-n][E][+|-][decoded exponent]
+ [sign][MSD],[decoded-declet-1],
+ ...,[decoded-declet-n][E][+|-][decoded exponent]
Examples:
@@ -242,9 +279,64 @@
the Advance Toolchain to discourage you from using them. If you MUST use them
define the following prototypes in your program:
- /* char * should ref a 14 byte char array, +0,000,000E+0\0 */
- extern char * decoded32 (_Decimal32, char*);
- /* char * should ref a 26 byte char array, +0,000,000,000,000,000E+0\0 */
- extern char * decoded64 (_Decimal64, char*);
- /* char * should ref a 50 byte char array, * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0 */
- extern char * decoded128 (_Decimal128, char*);
+ /* char * should ref a 14 byte char array,
+ * +0,000,000E+0\0 */
+ extern char * decoded32 (_Decimal32, char*);
+
+ /* char * should ref a 26 byte char array,
+ * +0,000,000,000,000,000E+0\0 */
+ extern char * decoded64 (_Decimal64, char*);
+
+ /* char * should ref a 50 byte char array,
+ * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0 */
+ extern char * decoded128 (_Decimal128, char*);
+
+---------------------------------------------------------------------------
+9. Known Limitations
+
+IEEE754r currently has an addendum awaiting vote whereby the default quantum
+for conversions involving zero will go to a zero exponent (e.g. 0 equals
+0.0). The current IEEE754r specification dictates that the quantum shall go
+to the largest supported by the data type, e.g. _Decimal32 0.0E191;
+_Decimal64 0.0E767, _Decimal128 0.0E12287.
+
+Observation of the advance toolchain results will show that we don't follow
+any particular convention. This may change in the future.
+
+For the following examples notice the DPD encoding on both power6[x] and
+non-power6:
+
+ _Decimal32 d32 = 0.0DF;
+ _Decimal64 d64 = 0.0DD;
+ _Decimal128 d128 = 0.0DL;
+
+ (_Decimal128)0.0DF: [+0,000,000E+0]
+ (_Decimal128)0.0DD: [+0,000,000,000,000,000E+0]
+ (_Decimal128)0.0DL: [+0,000,000,000,000,000,000,000,000,000,000,000E+0]
+
+On power6[x] notice the representation of zero after an [int|long|long long]
+conversion to _Decimal[32|64|128] respectively:
+
+ (_Decimal32)0DF = (int)0: [+0,000,000E+0]
+ (_Decimal32)0.0DF = (float)0.000000: [+0,000,000E+0]
+ (_Decimal64)0DD = (long)0: [+0,000,000,000,000,000E+0]
+ (_Decimal64)0.0DD = (double)0.000000: [+0,000,000,000,000,000E+0]
+ (_Decimal128)0DL = (long long)0:
+ [+0,000,000,000,000,000,000,000,000,000,000,000E+0]
+ (_Decimal128)0.0DL = (long double)0.000000:
+ [+0,000,000,000,000,000,000,000,000,000,000,000E+0]
+
+Notice the difference with soft-dfp:
+
+ (_Decimal32)0.0DF = (int)0: [+0,000,000E-1]
+ (_Decimal32)0.0DF = (float)0.000000: [+0,000,000E+0]
+ (_Decimal64)0.0DD = (long)0: [+0,000,000,000,000,000E-1]
+ (_Decimal64)0.0DD = (double)0.000000: [+0,000,000,000,000,000E+0]
+ (_Decimal128)0.0DL = (long long)0:
+ [+0,000,000,000,000,000,000,000,000,000,000,000E-1]
+ (_Decimal128)0.0DL = (long double)0.000000:
+ [+0,000,000,000,000,000,000,000,000,000,000,000E+0]
+
+Namely the negative sign of the exponent with soft-dfp for int to _Decimal
+conversions.
+
Added: libdfp/trunk/include/dfp.h
==============================================================================
--- libdfp/trunk/include/dfp.h (added)
+++ libdfp/trunk/include/dfp.h Thu Aug 12 12:14:11 2010
@@ -1,0 +1,38 @@
+/* Prototypes for libdfp specific functions not defined by any standard.
+
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
+ This file is part of the Decimal Floating Point C Library.
+
+ Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+ The Decimal Floating Point C Library is free software; you can
+ redistribute it and/or modify it under the terms of the GNU Lesser
+ General Public License version 2.1.
+
+ The Decimal Floating Point C Library is distributed in the hope that
+ it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ the GNU Lesser General Public License version 2.1 for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License version 2.1 along with the Decimal Floating Point C Library;
+ if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ Suite 330, Boston, MA 02111-1307 USA.
+
+ Please see libdfp/COPYING.txt for more information. */
+
+#ifndef _DFP_H
+#define _DFP_H
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* In order to inform libc that a decimal floating point type needs to be
+ * printed libdfp needs to inform libc, prior to the first invocation of printf,
+ * that it has printf callbacks available for decimal floating point types. */
+extern int register_printf_dfp (void);
+
+__END_DECLS
+
+#endif /* _DFP_H */
Modified: libdfp/trunk/tests/test-amort.c
==============================================================================
--- libdfp/trunk/tests/test-amort.c (original)
+++ libdfp/trunk/tests/test-amort.c Thu Aug 12 12:14:11 2010
@@ -55,7 +55,6 @@
#include <float.h>
#include <math.h>
#include <sys/time.h>
-#include <dfp/dfp.h>
//extern _Decimal64 powd64 (_Decimal64, _Decimal64);
//extern _Decimal64 quantized64 (_Decimal64, _Decimal64);
Modified: libdfp/trunk/tests/test-decode.c
==============================================================================
--- libdfp/trunk/tests/test-decode.c (original)
+++ libdfp/trunk/tests/test-decode.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h>
-#include <dfp.h>
#include <stdio.h>
#include <wchar.h> /* This should pick up the libdfp wchar in dfp/wchar.h. */
Modified: libdfp/trunk/tests/test-fpclassify.c
==============================================================================
--- libdfp/trunk/tests/test-fpclassify.c (original)
+++ libdfp/trunk/tests/test-fpclassify.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-get_digits.c
==============================================================================
--- libdfp/trunk/tests/test-get_digits.c (original)
+++ libdfp/trunk/tests/test-get_digits.c Thu Aug 12 12:14:11 2010
@@ -28,7 +28,6 @@
#include <fenv.h>
#include <float.h>
-#include <dfp.h>
#include <stdio.h>
#include <wchar.h> /* This should pick up the libdfp wchar in dfp/wchar.h. */
Modified: libdfp/trunk/tests/test-isfinite.c
==============================================================================
--- libdfp/trunk/tests/test-isfinite.c (original)
+++ libdfp/trunk/tests/test-isfinite.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-isinf.c
==============================================================================
--- libdfp/trunk/tests/test-isinf.c (original)
+++ libdfp/trunk/tests/test-isinf.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-isnan.c
==============================================================================
--- libdfp/trunk/tests/test-isnan.c (original)
+++ libdfp/trunk/tests/test-isnan.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-left_justify.c
==============================================================================
--- libdfp/trunk/tests/test-left_justify.c (original)
+++ libdfp/trunk/tests/test-left_justify.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-numdigits.c
==============================================================================
--- libdfp/trunk/tests/test-numdigits.c (original)
+++ libdfp/trunk/tests/test-numdigits.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h> /* DEC_NAN definition. */
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-printf.c
==============================================================================
--- libdfp/trunk/tests/test-printf.c (original)
+++ libdfp/trunk/tests/test-printf.c Thu Aug 12 12:14:11 2010
@@ -28,7 +28,6 @@
#include <fenv.h>
#include <float.h>
-#include <dfp.h>
#include <stdio.h>
#include <wchar.h> /* This should pick up the libdfp wchar in dfp/wchar.h. */
Modified: libdfp/trunk/tests/test-quantize.c
==============================================================================
--- libdfp/trunk/tests/test-quantize.c (original)
+++ libdfp/trunk/tests/test-quantize.c Thu Aug 12 12:14:11 2010
@@ -27,7 +27,6 @@
#endif
#include <float.h>
-#include <dfp.h>
#include <stdio.h>
#include <math.h>
Modified: libdfp/trunk/tests/test-strtod.c
==============================================================================
--- libdfp/trunk/tests/test-strtod.c (original)
+++ libdfp/trunk/tests/test-strtod.c Thu Aug 12 12:14:11 2010
@@ -11,6 +11,7 @@
#define _WANT_DC 1
#include "scaffold.c"
+#include "decode.h"
/* Inspired by GLIBC stdio-common/tfformat.c */
typedef struct{
@@ -31,16 +32,15 @@
{__LINE__, "-0.0001", -0.0001DF, -0.0001DD, -0.0001DL },
{__LINE__, "inf", DEC_INFINITY, DEC_INFINITY, DEC_INFINITY },
{__LINE__, "INFINITY", DEC_INFINITY, DEC_INFINITY, DEC_INFINITY },
- {__LINE__, "0.0E+100", DEC_INFINITY, 0.0DD, 0.0DL },
+ {__LINE__, "0.0E+100", 0.0DF, 0.0DD, 0.0DL },
{__LINE__, "0.01", 0.01DF, 0.01DD, 0.01DL },
{__LINE__, "0.1", 0.1DF, 0.1DD, 0.1DL },
{__LINE__, "0.11", 0.11DF, 0.11DD, 0.11DL },
{__LINE__, "0.21", 0.21DF, 0.21DD, 0.21DL },
- {__LINE__, "1.23456789E-7", 0.0DF, 0.0DD, 0.0DL },
{__LINE__, "19e9", 19000000000.0DF, 19000000000.0DD, 19000000000.0DL },
- {__LINE__, "1234.5678910111213e-5", 0.01234DF ,0.01234DD ,0.01234DL },
{__LINE__, "3.14", 3.140000DF, 3.140000DD, 3.140000DL },
{__LINE__, "3.14e-2", 0.031400DF, 0.031400DD, 0.031400DL },
+ {__LINE__, "1234.5678910111213e-5", 0.012346DF ,0.012346DD ,0.012346DL },
{0,0,0,0,0 }
};
@@ -62,6 +62,7 @@
/* Compare against the decoded declet for each representation of DEC_NAN since
* since you can't compare DEC_NAN to DEC_NAN. */
{__LINE__, "NaN", DECLET32_NAN, DECLET64_NAN, DECLET128_NAN},
+ {__LINE__, "1.23456789E-7", "+1,234,568E-14", "+0,000,000,123,456,789E-15", "+0,000,000,000,000,000,000,000,000,123,456,789E-15" },
{0,0,0,0,0 }
};