service plugin and qdecimal library has been added
parent
3d68281c87
commit
4d74bed177
@ -0,0 +1,61 @@
|
||||
# QDecimal Library
|
||||
|
||||
The QDecimal is a thin layer around IBM's decNumber library which implements the General Decimal Arithmetic Specification in ANSI C.[1] This specification defines a decimal arithmetic which meets the requirements of commercial, financial, and human-oriented applications. It also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic. The decNumber library also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic.
|
||||
|
||||
The QDecimal/decNumberlibrary,[2] fully implements the specification, and hence supports integer, fixed-point, and floating-point decimal numbers directly, including infinite, NaN (Not a Number), and subnormal values. Both arbitrary-precision and fixed-size representations are supported.
|
||||
|
||||
The aim of the QDecimal library is to extend decNumber functionality to C++ language and Qt framework by using idioms, tecniques and best practices in both tecnologies. For instance, inline functions are used heavily to aid optimization, operator overloading and conversion operators are defined to aid type casting in between the types defined by QDecimal. Further these types are integrated with Qt object model by introducing them to Qt meta type system.
|
||||
|
||||
Following classes are defined by QDecimal library:
|
||||
|
||||
**QDecNumber** (based on decNumber):
|
||||
|
||||
decNumber module uses an arbitrary-precision decimal number representation designed for efficient computation in software and implements the arithmetic and logical operations, together with a number of conversions and utilities. Once a number is held as a decNumber, no further conversions are necessary to carry out arithmetic. The decNumber representation is variable-length and machine-dependent (for example, it contains integers which may be big-endian or little-endian). QDecNumber encapsulates decNumber and reimplements global functions that operates upon decNumber as member functions with the same name.
|
||||
|
||||
**QDecContext** (based on decContext):
|
||||
|
||||
Most functions in the decNumber module take as an argument a decContext structure, which provides the context for operations (precision, rounding mode, etc.) and also controls the handling of exceptional conditions (corresponding to the flags and trap enablers in a hardware floating-point implementation).
|
||||
|
||||
**QDecSingle** (based on decSingle/decimal32):
|
||||
|
||||
decimal32 is a 32-bit decimal floating-point representation which provides 7 decimal digits of precision in a compressed format. decSingle module provides the functions for the decimal32 format; this format is intended for storage and interchange only and so the module provides utilities and conversions but no arithmetic functions. QDecSingle encapsulates decSingle and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
**QDecDouble** (based on decDouble/decimal64):
|
||||
|
||||
decimal64 is a 64-bit decimal floating-point representation which provides 16 decimal digits of precision in a compressed format. decDouble module provides the functions for the decimal64 format; this format is an IEEE 754 basic format and so a full set of arithmetic and other functions is included. QDecDouble encapsulates decDouble and provides decNumber library functions that operates upon decDouble as member functions with the same name.
|
||||
|
||||
**QDecQuad** (based on decQuad/decimal128):
|
||||
|
||||
decimal128 is a 128-bit decimal floating-point representation which provides 34 decimal digits of precision in a compressed format. decQuad module provides the functions for the decimal128 format; this format is an IEEE 754 basic format; it contains the same set of functions as decDouble. QDecQuad encapsulates decQuad and provides decNumber library functions that operates upon decQuad as member functions with the same name.
|
||||
|
||||
**QDecPacked** (based on decPacked):
|
||||
|
||||
The decPacked format is the classic packed decimal format implemented by IBM S/360 and later machines, where each digit is encoded as a 4-bit binary sequence (BCD) and a number is ended by a 4-bit sign indicator. The decPacked module accepts variable lengths, allowing for very large numbers (up to a billion digits), and also allows the specification of a scale. QDecPacked augments decPacked by encapsulating reference counted byte array and scale of the decimal point as members variables, thus, freeing up user of this class from memory management and keeping track of scale value.
|
||||
|
||||
## License ##
|
||||
QDecimal is under the terms of the LGPL v2.1. decNumber is under the terms of ICU v1.8.1 See COPYRIGHT file for terms of the these licenses.
|
||||
|
||||
## Platforms ##
|
||||
QDecimal should be usable in all platforms that Qt supports. We regularly test on following platforms: Solaris 11 x86 (sun studio 12.5) Linux (Ubuntu x64 - gcc) Linux (Ubuntu x86 - gcc) Windows XP (msvc 2012)
|
||||
|
||||
## Installation ##
|
||||
Read INSTALL.txt to build and install QDecimal.
|
||||
|
||||
## Copyright ##
|
||||
Copyright (C) 2012-16 Semih Cemiloglu
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This 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 for more details (COPYRIGHT.txt).
|
||||
|
||||
## Credits ##
|
||||
We are grateful to Mike Cowlishaw et al. from IBM for making decNumber package available. Mr. Cowlishaw has kindly helped while making QDecimal production ready.
|
||||
|
||||
## References ##
|
||||
1. General Decimal Arithmetic Specification: http://speleotrove.com/decimal/decarith.html
|
||||
|
||||
2. The decNumber Library: http://speleotrove.com/decimal/decnumber.html
|
||||
|
||||
3. General Decimal Arithmetic: http://speleotrove.com/decimal/
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
#
|
||||
# Configuration/Defaults file for SConscript.
|
||||
# This is Python file.
|
||||
# Store frequently used command-line variables in this file rather than
|
||||
# suppying them to scons at each invocation.
|
||||
|
||||
#build_mode = 'rel'
|
||||
use_plat = 1
|
@ -0,0 +1,66 @@
|
||||
#!python
|
||||
# -*-python-*-
|
||||
import os
|
||||
import sys
|
||||
import SConsLib
|
||||
|
||||
|
||||
|
||||
# Construct variables object by merging command-line settings and
|
||||
# configuration file.
|
||||
vars = SConsLib.constructVariables('SConsCfg.py')
|
||||
|
||||
# Instantiate Scons environment
|
||||
env = Environment(
|
||||
variables = vars,
|
||||
MSVC_VERSION='11.0', # VMSVC 2012 choose any version you prefer
|
||||
TARGET_ARCH='x86', # x86 -> 32bit or x86_64 => 64bit
|
||||
PREFIX = GetOption('prefix')
|
||||
)
|
||||
|
||||
# Check for unrecognized variables and warn
|
||||
SConsLib.checkUnknownVariables(vars)
|
||||
|
||||
# Setup Scons environment to be used during build
|
||||
SConsLib.setupEnvironment(env)
|
||||
|
||||
# Further refinements to the environment
|
||||
Help(vars.GenerateHelpText(env))
|
||||
env.Decider('timestamp-newer')
|
||||
env.SetOption('implicit_cache', 1)
|
||||
|
||||
# Identify Qt location
|
||||
if sys.platform.startswith('win'):
|
||||
qtdir = SConsLib.findQtDir('Q:/Qt/5.5.1')
|
||||
elif sys.platform.startswith('linux'):
|
||||
qtdir = SConsLib.findQtDir('/home/semih/Qt/5.5.1')
|
||||
|
||||
# Set QT5DIR
|
||||
env['QT5DIR'] = qtdir
|
||||
env['ENV']['PKG_CONFIG_PATH'] = os.path.join(qtdir, 'lib/pkgconfig')
|
||||
# Add qt5 tool
|
||||
env.Tool('qt5')
|
||||
# Normally in SConscript files
|
||||
env.EnableQt5Modules([
|
||||
'QtCore',
|
||||
'QtTest'
|
||||
])
|
||||
#...further customization of Qt env
|
||||
if sys.platform == 'win32':
|
||||
if 'cl' in env['CC']:
|
||||
env.AppendUnique(CPPPATH = ['#', '.'])
|
||||
env.AppendUnique(CCFLAGS = [ '-EHsc', '-Zc:wchar_t', '-Zc:forScope' ])
|
||||
env.AppendUnique(CPPDEFINES = ['UNICODE', 'WIN32', '_CRT_SECURE_NO_WARNINGS'])
|
||||
elif 'linux' in sys.platform:
|
||||
pass
|
||||
|
||||
|
||||
# Source directories that we expect to find SConscript files:
|
||||
src_dirs = Split('decnumber src test')
|
||||
|
||||
# Read and process SConscript files
|
||||
SConsLib.readSConscriptFiles(env, src_dirs)
|
||||
|
||||
# Use progress indicator to get feedback from SCons
|
||||
SConsLib.useProgress()
|
||||
|
@ -0,0 +1,35 @@
|
||||
# Following are defaults for decnumber library.
|
||||
# These defines must be defined when library clients are compiled.
|
||||
# We don't recommend enabling them unless it's specifically required.
|
||||
#DEFINES += DECNUMDIGITS=34 # default is 34
|
||||
#DEFINES += DECSUBSET=0 # default is 0
|
||||
#DEFINES += DECEXTFLAG=1 # default is 1
|
||||
#DEFINES += DECLITEND=0 # default is 1
|
||||
|
||||
CONFIG += debug
|
||||
|
||||
|
||||
if(win32) {
|
||||
INCLUDEPATH += .
|
||||
# Remove Qt's defaults
|
||||
QMAKE_CXXFLAGS -= -Zc:wchar_t-
|
||||
# Add our defaults
|
||||
QMAKE_CXXFLAGS += /Zc:forScope /Zc:wchar_t
|
||||
DEFINES *= _CRT_SECURE_NO_WARNINGS
|
||||
# Are we in debug mode?
|
||||
debug {
|
||||
# Use iterator debugging
|
||||
#DEFINES *= _SECURE_SCL=1
|
||||
#DEFINES *= _SECURE_SCL_THROWS=1
|
||||
#msvc2010 onwards above flags are deprecated.
|
||||
|
||||
# Use Run-time checks for stack corruption and uninitialized var use
|
||||
QMAKE_CXXFLAGS += /RTC1
|
||||
}
|
||||
|
||||
} # end win32
|
||||
else {
|
||||
MOC_DIR = moc
|
||||
OBJECTS_DIR = obj
|
||||
}
|
||||
|
@ -0,0 +1,735 @@
|
||||
#ifndef TC_PORTABLE_STDINT_H
|
||||
#define TC_PORTABLE_STDINT_H
|
||||
|
||||
/**
|
||||
* \file Port_stdint.h
|
||||
* A portable stdint.h
|
||||
****************************************************************************
|
||||
* BSD License:
|
||||
****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2005-2007 Paul Hsieh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Version 0.1.11
|
||||
*
|
||||
* The ANSI C standard committee, for the C99 standard, specified the
|
||||
* inclusion of a new standard include file called stdint.h. This is
|
||||
* a very useful and long desired include file which contains several
|
||||
* very precise definitions for integer scalar types that is
|
||||
* critically important for making portable several classes of
|
||||
* applications including cryptography, hashing, variable length
|
||||
* integer libraries and so on. But for most developers its likely
|
||||
* useful just for programming sanity.
|
||||
*
|
||||
* The problem is that most compiler vendors have decided not to
|
||||
* implement the C99 standard, and the next C++ language standard
|
||||
* (which has a lot more mindshare these days) will be a long time in
|
||||
* coming and its unknown whether or not it will include stdint.h or
|
||||
* how much adoption it will have. Either way, it will be a long time
|
||||
* before all compilers come with a stdint.h and it also does nothing
|
||||
* for the extremely large number of compilers available today which
|
||||
* do not include this file, or anything comparable to it.
|
||||
*
|
||||
* So that's what this file is all about. Its an attempt to build a
|
||||
* single universal include file that works on as many platforms as
|
||||
* possible to deliver what stdint.h is supposed to. A few things
|
||||
* that should be noted about this file:
|
||||
*
|
||||
* 1) It is not guaranteed to be portable and/or present an identical
|
||||
* interface on all platforms. The extreme variability of the
|
||||
* ANSI C standard makes this an impossibility right from the
|
||||
* very get go. Its really only meant to be useful for the vast
|
||||
* majority of platforms that possess the capability of
|
||||
* implementing usefully and precisely defined, standard sized
|
||||
* integer scalars. Systems which are not intrinsically 2s
|
||||
* complement may produce invalid constants.
|
||||
*
|
||||
* 2) There is an unavoidable use of non-reserved symbols.
|
||||
*
|
||||
* 3) Other standard include files are invoked.
|
||||
*
|
||||
* 4) This file may come in conflict with future platforms that do
|
||||
* include stdint.h. The hope is that one or the other can be
|
||||
* used with no real difference.
|
||||
*
|
||||
* 5) In the current verison, if your platform can't represent
|
||||
* int32_t, int16_t and int8_t, it just dumps out with a compiler
|
||||
* error.
|
||||
*
|
||||
* 6) 64 bit integers may or may not be defined. Test for their
|
||||
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
|
||||
* Note that this is different from the C99 specification which
|
||||
* requires the existence of 64 bit support in the compiler. If
|
||||
* this is not defined for your platform, yet it is capable of
|
||||
* dealing with 64 bits then it is because this file has not yet
|
||||
* been extended to cover all of your system's capabilities.
|
||||
*
|
||||
* 7) (u)intptr_t may or may not be defined. Test for its presence
|
||||
* with the test: #ifdef PTRDIFF_MAX. If this is not defined
|
||||
* for your platform, then it is because this file has not yet
|
||||
* been extended to cover all of your system's capabilities, not
|
||||
* because its optional.
|
||||
*
|
||||
* 8) The following might not been defined even if your platform is
|
||||
* capable of defining it:
|
||||
*
|
||||
* WCHAR_MIN
|
||||
* WCHAR_MAX
|
||||
* (u)int64_t
|
||||
* PTRDIFF_MIN
|
||||
* PTRDIFF_MAX
|
||||
* (u)intptr_t
|
||||
*
|
||||
* 9) The following have not been defined:
|
||||
*
|
||||
* WINT_MIN
|
||||
* WINT_MAX
|
||||
*
|
||||
* 10) The criteria for defining (u)int_least(*)_t isn't clear,
|
||||
* except for systems which don't have a type that precisely
|
||||
* defined 8, 16, or 32 bit types (which this include file does
|
||||
* not support anyways). Default definitions have been given.
|
||||
*
|
||||
* 11) The criteria for defining (u)int_fast(*)_t isn't something I
|
||||
* would trust to any particular compiler vendor or the ANSI C
|
||||
* committee. It is well known that "compatible systems" are
|
||||
* commonly created that have very different performance
|
||||
* characteristics from the systems they are compatible with,
|
||||
* especially those whose vendors make both the compiler and the
|
||||
* system. Default definitions have been given, but its strongly
|
||||
* recommended that users never use these definitions for any
|
||||
* reason (they do *NOT* deliver any serious guarantee of
|
||||
* improved performance -- not in this file, nor any vendor's
|
||||
* stdint.h).
|
||||
*
|
||||
* 12) The following macros:
|
||||
*
|
||||
* PRINTF_INTMAX_MODIFIER
|
||||
* PRINTF_INT64_MODIFIER
|
||||
* PRINTF_INT32_MODIFIER
|
||||
* PRINTF_INT16_MODIFIER
|
||||
* PRINTF_LEAST64_MODIFIER
|
||||
* PRINTF_LEAST32_MODIFIER
|
||||
* PRINTF_LEAST16_MODIFIER
|
||||
* PRINTF_INTPTR_MODIFIER
|
||||
*
|
||||
* are strings which have been defined as the modifiers required
|
||||
* for the "d", "u" and "x" printf formats to correctly output
|
||||
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
|
||||
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
|
||||
* PRINTF_INTPTR_MODIFIER is not defined for some systems which
|
||||
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not
|
||||
* defined if INT64_MAX is not defined. These are an extension
|
||||
* beyond what C99 specifies must be in stdint.h.
|
||||
*
|
||||
* In addition, the following macros are defined:
|
||||
*
|
||||
* PRINTF_INTMAX_HEX_WIDTH
|
||||
* PRINTF_INT64_HEX_WIDTH
|
||||
* PRINTF_INT32_HEX_WIDTH
|
||||
* PRINTF_INT16_HEX_WIDTH
|
||||
* PRINTF_INT8_HEX_WIDTH
|
||||
* PRINTF_INTMAX_DEC_WIDTH
|
||||
* PRINTF_INT64_DEC_WIDTH
|
||||
* PRINTF_INT32_DEC_WIDTH
|
||||
* PRINTF_INT16_DEC_WIDTH
|
||||
* PRINTF_INT8_DEC_WIDTH
|
||||
*
|
||||
* Which specifies the maximum number of characters required to
|
||||
* print the number of that type in either hexadecimal or decimal.
|
||||
* These are an extension beyond what C99 specifies must be in
|
||||
* stdint.h.
|
||||
*
|
||||
* Compilers tested (all with 0 warnings at their highest respective
|
||||
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
|
||||
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
|
||||
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
|
||||
*
|
||||
* This file should be considered a work in progress. Suggestions for
|
||||
* improvements, especially those which increase coverage are strongly
|
||||
* encouraged.
|
||||
*
|
||||
* Acknowledgements
|
||||
*
|
||||
* The following people have made significant contributions to the
|
||||
* development and testing of this file:
|
||||
*
|
||||
* Chris Howie
|
||||
* John Steele Scott
|
||||
* Dave Thorup
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
|
||||
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
||||
*/
|
||||
|
||||
#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )) && !defined (_PSTDINT_H_INCLUDED)
|
||||
#include <stdint.h>
|
||||
#define _PSTDINT_H_INCLUDED
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INT64_HEX_WIDTH
|
||||
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_HEX_WIDTH
|
||||
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_HEX_WIDTH
|
||||
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||
# endif
|
||||
# ifndef PRINTF_INT8_HEX_WIDTH
|
||||
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||
# endif
|
||||
# ifndef PRINTF_INT64_DEC_WIDTH
|
||||
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_DEC_WIDTH
|
||||
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_DEC_WIDTH
|
||||
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||
# endif
|
||||
# ifndef PRINTF_INT8_DEC_WIDTH
|
||||
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Something really weird is going on with Open Watcom. Just pull some of
|
||||
* these duplicated definitions from Open Watcom's stdint.h file for now.
|
||||
*/
|
||||
|
||||
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
|
||||
# if !defined (INT64_C)
|
||||
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
|
||||
# endif
|
||||
# if !defined (UINT64_C)
|
||||
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
|
||||
# endif
|
||||
# if !defined (INT32_C)
|
||||
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
|
||||
# endif
|
||||
# if !defined (UINT32_C)
|
||||
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
|
||||
# endif
|
||||
# if !defined (INT16_C)
|
||||
# define INT16_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT16_C)
|
||||
# define UINT16_C(x) (x)
|
||||
# endif
|
||||
# if !defined (INT8_C)
|
||||
# define INT8_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT8_C)
|
||||
# define UINT8_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT64_MAX)
|
||||
# define UINT64_MAX 18446744073709551615ULL
|
||||
# endif
|
||||
# if !defined (INT64_MAX)
|
||||
# define INT64_MAX 9223372036854775807LL
|
||||
# endif
|
||||
# if !defined (UINT32_MAX)
|
||||
# define UINT32_MAX 4294967295UL
|
||||
# endif
|
||||
# if !defined (INT32_MAX)
|
||||
# define INT32_MAX 2147483647L
|
||||
# endif
|
||||
# if !defined (INTMAX_MAX)
|
||||
# define INTMAX_MAX INT64_MAX
|
||||
# endif
|
||||
# if !defined (INTMAX_MIN)
|
||||
# define INTMAX_MIN INT64_MIN
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _PSTDINT_H_INCLUDED
|
||||
#define _PSTDINT_H_INCLUDED
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deduce the type assignments from limits.h under the assumption that
|
||||
* integer sizes in bits are powers of 2, and follow the ANSI
|
||||
* definitions.
|
||||
*/
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
# define UINT8_MAX 0xff
|
||||
#endif
|
||||
#ifndef uint8_t
|
||||
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned char uint8_t;
|
||||
# define UINT8_C(v) ((uint8_t) v)
|
||||
# else
|
||||
# error "Platform not supported"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INT8_MAX
|
||||
# define INT8_MAX 0x7f
|
||||
#endif
|
||||
#ifndef INT8_MIN
|
||||
# define INT8_MIN INT8_C(0x80)
|
||||
#endif
|
||||
#ifndef int8_t
|
||||
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed char int8_t;
|
||||
# define INT8_C(v) ((int8_t) v)
|
||||
# else
|
||||
# error "Platform not supported"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_MAX
|
||||
# define UINT16_MAX 0xffff
|
||||
#endif
|
||||
#ifndef uint16_t
|
||||
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned int uint16_t;
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER ""
|
||||
# endif
|
||||
# define UINT16_C(v) ((uint16_t) (v))
|
||||
#elif (USHRT_MAX == UINT16_MAX)
|
||||
typedef unsigned short uint16_t;
|
||||
# define UINT16_C(v) ((uint16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT16_MAX
|
||||
# define INT16_MAX 0x7fff
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
# define INT16_MIN INT16_C(0x8000)
|
||||
#endif
|
||||
#ifndef int16_t
|
||||
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed int int16_t;
|
||||
# define INT16_C(v) ((int16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER ""
|
||||
# endif
|
||||
#elif (SHRT_MAX == INT16_MAX)
|
||||
typedef signed short int16_t;
|
||||
# define INT16_C(v) ((int16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX (0xffffffffUL)
|
||||
#endif
|
||||
#ifndef uint32_t
|
||||
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned long uint32_t;
|
||||
# define UINT32_C(v) v ## UL
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
#elif (UINT_MAX == UINT32_MAX)
|
||||
typedef unsigned int uint32_t;
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
# define UINT32_C(v) v ## U
|
||||
#elif (USHRT_MAX == UINT32_MAX)
|
||||
typedef unsigned short uint32_t;
|
||||
# define UINT32_C(v) ((unsigned short) (v))
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MAX
|
||||
# define INT32_MAX (0x7fffffffL)
|
||||
#endif
|
||||
#ifndef INT32_MIN
|
||||
# define INT32_MIN INT32_C(0x80000000)
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed long int32_t;
|
||||
# define INT32_C(v) v ## L
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
#elif (INT_MAX == INT32_MAX)
|
||||
typedef signed int int32_t;
|
||||
# define INT32_C(v) v
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#elif (SHRT_MAX == INT32_MAX)
|
||||
typedef signed short int32_t;
|
||||
# define INT32_C(v) ((short) (v))
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The macro stdint_int64_defined is temporarily used to record
|
||||
* whether or not 64 integer support is available. It must be
|
||||
* defined for any 64 integer extensions for new platforms that are
|
||||
* added.
|
||||
*/
|
||||
|
||||
#undef stdint_int64_defined
|
||||
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
|
||||
# if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
|
||||
# define stdint_int64_defined
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (stdint_int64_defined)
|
||||
# if defined(__GNUC__)
|
||||
# define stdint_int64_defined
|
||||
__extension__ typedef long long int64_t;
|
||||
__extension__ typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
|
||||
# define stdint_int64_defined
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
|
||||
# define stdint_int64_defined
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# define UINT64_C(v) v ## UI64
|
||||
# define INT64_C(v) v ## I64
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "I64"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (LONG_LONG_MAX) && defined (INT64_C)
|
||||
# define LONG_LONG_MAX INT64_C (9223372036854775807)
|
||||
#endif
|
||||
#ifndef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
|
||||
#endif
|
||||
|
||||
#if !defined (INT64_MAX) && defined (INT64_C)
|
||||
# define INT64_MAX INT64_C (9223372036854775807)
|
||||
#endif
|
||||
#if !defined (INT64_MIN) && defined (INT64_C)
|
||||
# define INT64_MIN INT64_C (-9223372036854775808)
|
||||
#endif
|
||||
#if !defined (UINT64_MAX) && defined (INT64_C)
|
||||
# define UINT64_MAX UINT64_C (18446744073709551615)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Width of hexadecimal for number field.
|
||||
*/
|
||||
|
||||
#ifndef PRINTF_INT64_HEX_WIDTH
|
||||
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||
#endif
|
||||
#ifndef PRINTF_INT32_HEX_WIDTH
|
||||
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||
#endif
|
||||
#ifndef PRINTF_INT16_HEX_WIDTH
|
||||
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||
#endif
|
||||
#ifndef PRINTF_INT8_HEX_WIDTH
|
||||
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_INT64_DEC_WIDTH
|
||||
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||
#endif
|
||||
#ifndef PRINTF_INT32_DEC_WIDTH
|
||||
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||
#endif
|
||||
#ifndef PRINTF_INT16_DEC_WIDTH
|
||||
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||
#endif
|
||||
#ifndef PRINTF_INT8_DEC_WIDTH
|
||||
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ok, lets not worry about 128 bit integers for now. Moore's law says
|
||||
* we don't need to worry about that until about 2040 at which point
|
||||
* we'll have bigger things to worry about.
|
||||
*/
|
||||
|
||||
#ifdef stdint_int64_defined
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
# define INTMAX_MAX INT64_MAX
|
||||
# define INTMAX_MIN INT64_MIN
|
||||
# define UINTMAX_MAX UINT64_MAX
|
||||
# define UINTMAX_C(v) UINT64_C(v)
|
||||
# define INTMAX_C(v) INT64_C(v)
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||
# endif
|
||||
#else
|
||||
typedef int32_t intmax_t;
|
||||
typedef uint32_t uintmax_t;
|
||||
# define INTMAX_MAX INT32_MAX
|
||||
# define UINTMAX_MAX UINT32_MAX
|
||||
# define UINTMAX_C(v) UINT32_C(v)
|
||||
# define INTMAX_C(v) INT32_C(v)
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Because this file currently only supports platforms which have
|
||||
* precise powers of 2 as bit sizes for the default integers, the
|
||||
* least definitions are all trivial. Its possible that a future
|
||||
* version of this file could have different definitions.
|
||||
*/
|
||||
|
||||
#ifndef stdint_least_defined
|
||||
typedef int8_t int_least8_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
|
||||
# define UINT_LEAST8_MAX UINT8_MAX
|
||||
# define INT_LEAST8_MAX INT8_MAX
|
||||
# define UINT_LEAST16_MAX UINT16_MAX
|
||||
# define INT_LEAST16_MAX INT16_MAX
|
||||
# define UINT_LEAST32_MAX UINT32_MAX
|
||||
# define INT_LEAST32_MAX INT32_MAX
|
||||
# define INT_LEAST8_MIN INT8_MIN
|
||||
# define INT_LEAST16_MIN INT16_MIN
|
||||
# define INT_LEAST32_MIN INT32_MIN
|
||||
# ifdef stdint_int64_defined
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# define UINT_LEAST64_MAX UINT64_MAX
|
||||
# define INT_LEAST64_MAX INT64_MAX
|
||||
# define INT_LEAST64_MIN INT64_MIN
|
||||
# endif
|
||||
#endif
|
||||
#undef stdint_least_defined
|
||||
|
||||
/*
|
||||
* The ANSI C committee pretending to know or specify anything about
|
||||
* performance is the epitome of misguided arrogance. The mandate of
|
||||
* this file is to *ONLY* ever support that absolute minimum
|
||||
* definition of the fast integer types, for compatibility purposes.
|
||||
* No extensions, and no attempt to suggest what may or may not be a
|
||||
* faster integer type will ever be made in this file. Developers are
|
||||
* warned to stay away from these types when using this or any other
|
||||
* stdint.h.
|
||||
*/
|
||||
|
||||
typedef int_least8_t int_fast8_t;
|
||||
typedef uint_least8_t uint_fast8_t;
|
||||
typedef int_least16_t int_fast16_t;
|
||||
typedef uint_least16_t uint_fast16_t;
|
||||
typedef int_least32_t int_fast32_t;
|
||||
typedef uint_least32_t uint_fast32_t;
|
||||
#define UINT_FAST8_MAX UINT_LEAST8_MAX
|
||||
#define INT_FAST8_MAX INT_LEAST8_MAX
|
||||
#define UINT_FAST16_MAX UINT_LEAST16_MAX
|
||||
#define INT_FAST16_MAX INT_LEAST16_MAX
|
||||
#define UINT_FAST32_MAX UINT_LEAST32_MAX
|
||||
#define INT_FAST32_MAX INT_LEAST32_MAX
|
||||
#define INT_FAST8_MIN INT_LEAST8_MIN
|
||||
#define INT_FAST16_MIN INT_LEAST16_MIN
|
||||
#define INT_FAST32_MIN INT_LEAST32_MIN
|
||||
#ifdef stdint_int64_defined
|
||||
typedef int_least64_t int_fast64_t;
|
||||
typedef uint_least64_t uint_fast64_t;
|
||||
# define UINT_FAST64_MAX UINT_LEAST64_MAX
|
||||
# define INT_FAST64_MAX INT_LEAST64_MAX
|
||||
# define INT_FAST64_MIN INT_LEAST64_MIN
|
||||
#endif
|
||||
|
||||
#undef stdint_int64_defined
|
||||
|
||||
/*
|
||||
* Whatever piecemeal, per compiler thing we can do about the wchar_t
|
||||
* type limits.
|
||||
*/
|
||||
|
||||
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
|
||||
# include <wchar.h>
|
||||
# ifndef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
# endif
|
||||
# ifndef WCHAR_MAX
|
||||
# define WCHAR_MAX ((wchar_t)-1)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whatever piecemeal, per compiler/platform thing we can do about the
|
||||
* (u)intptr_t types and limits.
|
||||
*/
|
||||
|
||||
#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
|
||||
# define STDINT_H_UINTPTR_T_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef STDINT_H_UINTPTR_T_DEFINED
|
||||
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
|
||||
# define stdint_intptr_bits 64
|
||||
# elif defined (__WATCOMC__) || defined (__TURBOC__)
|
||||
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
|
||||
# define stdint_intptr_bits 16
|
||||
# else
|
||||
# define stdint_intptr_bits 32
|
||||
# endif
|
||||
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
|
||||
# define stdint_intptr_bits 32
|
||||
# elif defined (__INTEL_COMPILER)
|
||||
/* TODO -- what will Intel do about x86-64? */
|
||||
# endif
|
||||
|
||||
# ifdef stdint_intptr_bits
|
||||
# define stdint_intptr_glue3_i(a,b,c) a##b##c
|
||||
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
|
||||
# ifndef PRINTF_INTPTR_MODIFIER
|
||||
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
|
||||
# endif
|
||||
# ifndef PTRDIFF_MAX
|
||||
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef PTRDIFF_MIN
|
||||
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||
# endif
|
||||
# ifndef UINTPTR_MAX
|
||||
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef INTPTR_MAX
|
||||
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef INTPTR_MIN
|
||||
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||
# endif
|
||||
# ifndef INTPTR_C
|
||||
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
|
||||
# endif
|
||||
# ifndef UINTPTR_C
|
||||
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
|
||||
# endif
|
||||
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
|
||||
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
|
||||
# else
|
||||
/* TODO -- This following is likely wrong for some platforms, and does
|
||||
nothing for the definition of uintptr_t. */
|
||||
typedef ptrdiff_t intptr_t;
|
||||
# endif
|
||||
# define STDINT_H_UINTPTR_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Assumes sig_atomic_t is signed and we have a 2s complement machine.
|
||||
*/
|
||||
|
||||
#ifndef SIG_ATOMIC_MAX
|
||||
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,11 @@
|
||||
Import('*')
|
||||
|
||||
srcs = Split('decContext.c decDouble.c decimal128.c decimal32.c decimal64.c decNumber.c decPacked.c decQuad.c decSingle.c')
|
||||
|
||||
lib = env.StaticLibrary('decnumber', srcs)
|
||||
|
||||
env['PRJ_LIBS']['decnumber'] = lib
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,247 @@
|
||||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006-2008 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||
#ifndef _W64
|
||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
# else
|
||||
# define _W64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
|
||||
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
// realize that, e.g. char has the same size as __int8
|
||||
// so we give up on __intX for them.
|
||||
#if (_MSC_VER < 1300)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#else
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef signed __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef _W64 signed int intptr_t;
|
||||
typedef _W64 unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,437 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Context module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2009. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises the routines for handling arithmetic */
|
||||
/* context structures. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#include <string.h> // for strcmp
|
||||
#include <stdio.h> // for printf if DECCHECK
|
||||
#include "decContext.h" // context and base types
|
||||
#include "decNumberLocal.h" // decNumber local types, etc.
|
||||
|
||||
/* compile-time endian tester [assumes sizeof(Int)>1] */
|
||||
static const Int mfcone=1; // constant 1
|
||||
static const Flag *mfctop=(const Flag *)&mfcone; // -> top byte
|
||||
#define LITEND *mfctop // named flag; 1=little-endian
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* round-for-reround digits */
|
||||
/* ------------------------------------------------------------------ */
|
||||
const uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Powers of ten (powers[n]==10**n, 0<=n<=9) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000,
|
||||
10000000, 100000000, 1000000000};
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextClearStatus -- clear bits in current status */
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* mask indicates the bits to be cleared (the status bit that */
|
||||
/* corresponds to each 1 bit in the mask is cleared) */
|
||||
/* returns context */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext *decContextClearStatus(decContext *context, uInt mask) {
|
||||
context->status&=~mask;
|
||||
return context;
|
||||
} // decContextClearStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextDefault -- initialize a context structure */
|
||||
/* */
|
||||
/* context is the structure to be initialized */
|
||||
/* kind selects the required set of default values, one of: */
|
||||
/* DEC_INIT_BASE -- select ANSI X3-274 defaults */
|
||||
/* DEC_INIT_DECIMAL32 -- select IEEE 754 defaults, 32-bit */
|
||||
/* DEC_INIT_DECIMAL64 -- select IEEE 754 defaults, 64-bit */
|
||||
/* DEC_INIT_DECIMAL128 -- select IEEE 754 defaults, 128-bit */
|
||||
/* For any other value a valid context is returned, but with */
|
||||
/* Invalid_operation set in the status field. */
|
||||
/* returns a context structure with the appropriate initial values. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextDefault(decContext *context, Int kind) {
|
||||
// set defaults...
|
||||
context->digits=9; // 9 digits
|
||||
context->emax=DEC_MAX_EMAX; // 9-digit exponents
|
||||
context->emin=DEC_MIN_EMIN; // .. balanced
|
||||
context->round=DEC_ROUND_HALF_UP; // 0.5 rises
|
||||
context->traps=DEC_Errors; // all but informational
|
||||
context->status=0; // cleared
|
||||
context->clamp=0; // no clamping
|
||||
#if DECSUBSET
|
||||
context->extended=0; // cleared
|
||||
#endif
|
||||
switch (kind) {
|
||||
case DEC_INIT_BASE:
|
||||
// [use defaults]
|
||||
break;
|
||||
case DEC_INIT_DECIMAL32:
|
||||
context->digits=7; // digits
|
||||
context->emax=96; // Emax
|
||||
context->emin=-95; // Emin
|
||||
context->round=DEC_ROUND_HALF_EVEN; // 0.5 to nearest even
|
||||
context->traps=0; // no traps set
|
||||
context->clamp=1; // clamp exponents
|
||||
#if DECSUBSET
|
||||
context->extended=1; // set
|
||||
#endif
|
||||
break;
|
||||
case DEC_INIT_DECIMAL64:
|
||||
context->digits=16; // digits
|
||||
context->emax=384; // Emax
|
||||
context->emin=-383; // Emin
|
||||
context->round=DEC_ROUND_HALF_EVEN; // 0.5 to nearest even
|
||||
context->traps=0; // no traps set
|
||||
context->clamp=1; // clamp exponents
|
||||
#if DECSUBSET
|
||||
context->extended=1; // set
|
||||
#endif
|
||||
break;
|
||||
case DEC_INIT_DECIMAL128:
|
||||
context->digits=34; // digits
|
||||
context->emax=6144; // Emax
|
||||
context->emin=-6143; // Emin
|
||||
context->round=DEC_ROUND_HALF_EVEN; // 0.5 to nearest even
|
||||
context->traps=0; // no traps set
|
||||
context->clamp=1; // clamp exponents
|
||||
#if DECSUBSET
|
||||
context->extended=1; // set
|
||||
#endif
|
||||
break;
|
||||
|
||||
default: // invalid Kind
|
||||
// use defaults, and ..
|
||||
decContextSetStatus(context, DEC_Invalid_operation); // trap
|
||||
}
|
||||
|
||||
return context;} // decContextDefault
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextGetRounding -- return current rounding mode */
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* returns the rounding mode */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
enum rounding decContextGetRounding(decContext *context) {
|
||||
return context->round;
|
||||
} // decContextGetRounding
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextGetStatus -- return current status */
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* returns status */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decContextGetStatus(decContext *context) {
|
||||
return context->status;
|
||||
} // decContextGetStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextRestoreStatus -- restore bits in current status */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* newstatus is the source for the bits to be restored */
|
||||
/* mask indicates the bits to be restored (the status bit that */
|
||||
/* corresponds to each 1 bit in the mask is set to the value of */
|
||||
/* the correspnding bit in newstatus) */
|
||||
/* returns context */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext *decContextRestoreStatus(decContext *context,
|
||||
uInt newstatus, uInt mask) {
|
||||
context->status&=~mask; // clear the selected bits
|
||||
context->status|=(mask&newstatus); // or in the new bits
|
||||
return context;
|
||||
} // decContextRestoreStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSaveStatus -- save bits in current status */
|
||||
/* */
|
||||
/* context is the context structure to be queried */
|
||||
/* mask indicates the bits to be saved (the status bits that */
|
||||
/* correspond to each 1 bit in the mask are saved) */
|
||||
/* returns the AND of the mask and the current status */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decContextSaveStatus(decContext *context, uInt mask) {
|
||||
return context->status&mask;
|
||||
} // decContextSaveStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSetRounding -- set current rounding mode */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* newround is the value which will replace the current mode */
|
||||
/* returns context */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext *decContextSetRounding(decContext *context,
|
||||
enum rounding newround) {
|
||||
context->round=newround;
|
||||
return context;
|
||||
} // decContextSetRounding
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSetStatus -- set status and raise trap if appropriate */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* status is the DEC_ exception code */
|
||||
/* returns the context structure */
|
||||
/* */
|
||||
/* Control may never return from this routine, if there is a signal */
|
||||
/* handler and it takes a long jump. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatus(decContext *context, uInt status) {
|
||||
context->status|=status;
|
||||
if (status & context->traps) raise(SIGFPE);
|
||||
return context;} // decContextSetStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSetStatusFromString -- set status from a string + trap */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* string is a string exactly equal to one that might be returned */
|
||||
/* by decContextStatusToString */
|
||||
/* */
|
||||
/* The status bit corresponding to the string is set, and a trap */
|
||||
/* is raised if appropriate. */
|
||||
/* */
|
||||
/* returns the context structure, unless the string is equal to */
|
||||
/* DEC_Condition_MU or is not recognized. In these cases NULL is */
|
||||
/* returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatusFromString(decContext *context,
|
||||
const char *string) {
|
||||
if (strcmp(string, DEC_Condition_CS)==0)
|
||||
return decContextSetStatus(context, DEC_Conversion_syntax);
|
||||
if (strcmp(string, DEC_Condition_DZ)==0)
|
||||
return decContextSetStatus(context, DEC_Division_by_zero);
|
||||
if (strcmp(string, DEC_Condition_DI)==0)
|
||||
return decContextSetStatus(context, DEC_Division_impossible);
|
||||
if (strcmp(string, DEC_Condition_DU)==0)
|
||||
return decContextSetStatus(context, DEC_Division_undefined);
|
||||
if (strcmp(string, DEC_Condition_IE)==0)
|
||||
return decContextSetStatus(context, DEC_Inexact);
|
||||
if (strcmp(string, DEC_Condition_IS)==0)
|
||||
return decContextSetStatus(context, DEC_Insufficient_storage);
|
||||
if (strcmp(string, DEC_Condition_IC)==0)
|
||||
return decContextSetStatus(context, DEC_Invalid_context);
|
||||
if (strcmp(string, DEC_Condition_IO)==0)
|
||||
return decContextSetStatus(context, DEC_Invalid_operation);
|
||||
#if DECSUBSET
|
||||
if (strcmp(string, DEC_Condition_LD)==0)
|
||||
return decContextSetStatus(context, DEC_Lost_digits);
|
||||
#endif
|
||||
if (strcmp(string, DEC_Condition_OV)==0)
|
||||
return decContextSetStatus(context, DEC_Overflow);
|
||||
if (strcmp(string, DEC_Condition_PA)==0)
|
||||
return decContextSetStatus(context, DEC_Clamped);
|
||||
if (strcmp(string, DEC_Condition_RO)==0)
|
||||
return decContextSetStatus(context, DEC_Rounded);
|
||||
if (strcmp(string, DEC_Condition_SU)==0)
|
||||
return decContextSetStatus(context, DEC_Subnormal);
|
||||
if (strcmp(string, DEC_Condition_UN)==0)
|
||||
return decContextSetStatus(context, DEC_Underflow);
|
||||
if (strcmp(string, DEC_Condition_ZE)==0)
|
||||
return context;
|
||||
return NULL; // Multiple status, or unknown
|
||||
} // decContextSetStatusFromString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSetStatusFromStringQuiet -- set status from a string */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* string is a string exactly equal to one that might be returned */
|
||||
/* by decContextStatusToString */
|
||||
/* */
|
||||
/* The status bit corresponding to the string is set; no trap is */
|
||||
/* raised. */
|
||||
/* */
|
||||
/* returns the context structure, unless the string is equal to */
|
||||
/* DEC_Condition_MU or is not recognized. In these cases NULL is */
|
||||
/* returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatusFromStringQuiet(decContext *context,
|
||||
const char *string) {
|
||||
if (strcmp(string, DEC_Condition_CS)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Conversion_syntax);
|
||||
if (strcmp(string, DEC_Condition_DZ)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Division_by_zero);
|
||||
if (strcmp(string, DEC_Condition_DI)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Division_impossible);
|
||||
if (strcmp(string, DEC_Condition_DU)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Division_undefined);
|
||||
if (strcmp(string, DEC_Condition_IE)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Inexact);
|
||||
if (strcmp(string, DEC_Condition_IS)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Insufficient_storage);
|
||||
if (strcmp(string, DEC_Condition_IC)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Invalid_context);
|
||||
if (strcmp(string, DEC_Condition_IO)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Invalid_operation);
|
||||
#if DECSUBSET
|
||||
if (strcmp(string, DEC_Condition_LD)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Lost_digits);
|
||||
#endif
|
||||
if (strcmp(string, DEC_Condition_OV)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Overflow);
|
||||
if (strcmp(string, DEC_Condition_PA)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Clamped);
|
||||
if (strcmp(string, DEC_Condition_RO)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Rounded);
|
||||
if (strcmp(string, DEC_Condition_SU)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Subnormal);
|
||||
if (strcmp(string, DEC_Condition_UN)==0)
|
||||
return decContextSetStatusQuiet(context, DEC_Underflow);
|
||||
if (strcmp(string, DEC_Condition_ZE)==0)
|
||||
return context;
|
||||
return NULL; // Multiple status, or unknown
|
||||
} // decContextSetStatusFromStringQuiet
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextSetStatusQuiet -- set status without trap */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* status is the DEC_ exception code */
|
||||
/* returns the context structure */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext * decContextSetStatusQuiet(decContext *context, uInt status) {
|
||||
context->status|=status;
|
||||
return context;} // decContextSetStatusQuiet
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextStatusToString -- convert status flags to a string */
|
||||
/* */
|
||||
/* context is a context with valid status field */
|
||||
/* */
|
||||
/* returns a constant string describing the condition. If multiple */
|
||||
/* (or no) flags are set, a generic constant message is returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
const char *decContextStatusToString(const decContext *context) {
|
||||
Int status=context->status;
|
||||
|
||||
// test the five IEEE first, as some of the others are ambiguous when
|
||||
// DECEXTFLAG=0
|
||||
if (status==DEC_Invalid_operation ) return DEC_Condition_IO;
|
||||
if (status==DEC_Division_by_zero ) return DEC_Condition_DZ;
|
||||
if (status==DEC_Overflow ) return DEC_Condition_OV;
|
||||
if (status==DEC_Underflow ) return DEC_Condition_UN;
|
||||
if (status==DEC_Inexact ) return DEC_Condition_IE;
|
||||
|
||||
if (status==DEC_Division_impossible ) return DEC_Condition_DI;
|
||||
if (status==DEC_Division_undefined ) return DEC_Condition_DU;
|
||||
if (status==DEC_Rounded ) return DEC_Condition_RO;
|
||||
if (status==DEC_Clamped ) return DEC_Condition_PA;
|
||||
if (status==DEC_Subnormal ) return DEC_Condition_SU;
|
||||
if (status==DEC_Conversion_syntax ) return DEC_Condition_CS;
|
||||
if (status==DEC_Insufficient_storage ) return DEC_Condition_IS;
|
||||
if (status==DEC_Invalid_context ) return DEC_Condition_IC;
|
||||
#if DECSUBSET
|
||||
if (status==DEC_Lost_digits ) return DEC_Condition_LD;
|
||||
#endif
|
||||
if (status==0 ) return DEC_Condition_ZE;
|
||||
return DEC_Condition_MU; // Multiple errors
|
||||
} // decContextStatusToString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextTestEndian -- test whether DECLITEND is set correctly */
|
||||
/* */
|
||||
/* quiet is 1 to suppress message; 0 otherwise */
|
||||
/* returns 0 if DECLITEND is correct */
|
||||
/* 1 if DECLITEND is incorrect and should be 1 */
|
||||
/* -1 if DECLITEND is incorrect and should be 0 */
|
||||
/* */
|
||||
/* A message is displayed if the return value is not 0 and quiet==0. */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
Int decContextTestEndian(Flag quiet) {
|
||||
Int res=0; // optimist
|
||||
uInt dle=(uInt)DECLITEND; // unsign
|
||||
if (dle>1) dle=1; // ensure 0 or 1
|
||||
|
||||
if (LITEND!=DECLITEND) {
|
||||
if (!quiet) { // always refer to this
|
||||
#if DECPRINT
|
||||
const char *adj;
|
||||
if (LITEND) adj="little";
|
||||
else adj="big";
|
||||
printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
|
||||
DECLITEND, adj);
|
||||
#endif
|
||||
}
|
||||
res=(Int)LITEND-dle;
|
||||
}
|
||||
return res;
|
||||
} // decContextTestEndian
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextTestSavedStatus -- test bits in saved status */
|
||||
/* */
|
||||
/* oldstatus is the status word to be tested */
|
||||
/* mask indicates the bits to be tested (the oldstatus bits that */
|
||||
/* correspond to each 1 bit in the mask are tested) */
|
||||
/* returns 1 if any of the tested bits are 1, or 0 otherwise */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decContextTestSavedStatus(uInt oldstatus, uInt mask) {
|
||||
return (oldstatus&mask)!=0;
|
||||
} // decContextTestSavedStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextTestStatus -- test bits in current status */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* mask indicates the bits to be tested (the status bits that */
|
||||
/* correspond to each 1 bit in the mask are tested) */
|
||||
/* returns 1 if any of the tested bits are 1, or 0 otherwise */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decContextTestStatus(decContext *context, uInt mask) {
|
||||
return (context->status&mask)!=0;
|
||||
} // decContextTestStatus
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decContextZeroStatus -- clear all status bits */
|
||||
/* */
|
||||
/* context is the context structure to be updated */
|
||||
/* returns context */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decContext *decContextZeroStatus(decContext *context) {
|
||||
context->status=0;
|
||||
return context;
|
||||
} // decContextZeroStatus
|
||||
|
@ -0,0 +1,261 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Context module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* */
|
||||
/* Context variables must always have valid values: */
|
||||
/* */
|
||||
/* status -- [any bits may be cleared, but not set, by user] */
|
||||
/* round -- must be one of the enumerated rounding modes */
|
||||
/* */
|
||||
/* The following variables are implied for fixed size formats (i.e., */
|
||||
/* they are ignored) but should still be set correctly in case used */
|
||||
/* with decNumber functions: */
|
||||
/* */
|
||||
/* clamp -- must be either 0 or 1 */
|
||||
/* digits -- must be in the range 1 through 999999999 */
|
||||
/* emax -- must be in the range 0 through 999999999 */
|
||||
/* emin -- must be in the range 0 through -999999999 */
|
||||
/* extended -- must be either 0 or 1 [present only if DECSUBSET] */
|
||||
/* traps -- only defined bits may be set */
|
||||
/* */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECCONTEXT)
|
||||
#define DECCONTEXT
|
||||
#define DECCNAME "decContext" /* Short name */
|
||||
#define DECCFULLNAME "Decimal Context Descriptor" /* Verbose name */
|
||||
#define DECCAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
#if !defined(int32_t)
|
||||
#if defined(_MSC_VER)
|
||||
/* MS Visual C++ */
|
||||
#include <VCpp_stdint.h>
|
||||
#else
|
||||
#include <stdint.h> /* C99 standard integers */
|
||||
// For unknown compilers, you can use portable stdint.h
|
||||
//include <Port_stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdio.h> /* for printf, etc. */
|
||||
#include <signal.h> /* for traps */
|
||||
|
||||
/* Extended flags setting -- set this to 0 to use only IEEE flags */
|
||||
#if !defined(DECEXTFLAG)
|
||||
#define DECEXTFLAG 1 /* 1=enable extended flags */
|
||||
#endif
|
||||
|
||||
/* Conditional code flag -- set this to 0 for best performance */
|
||||
#if !defined(DECSUBSET)
|
||||
#define DECSUBSET 1 /* 1=enable subset arithmetic */
|
||||
#endif
|
||||
|
||||
/* Context for operations, with associated constants */
|
||||
enum rounding {
|
||||
DEC_ROUND_CEILING, /* round towards +infinity */
|
||||
DEC_ROUND_UP, /* round away from 0 */
|
||||
DEC_ROUND_HALF_UP, /* 0.5 rounds up */
|
||||
DEC_ROUND_HALF_EVEN, /* 0.5 rounds to nearest even */
|
||||
DEC_ROUND_HALF_DOWN, /* 0.5 rounds down */
|
||||
DEC_ROUND_DOWN, /* round towards 0 (truncate) */
|
||||
DEC_ROUND_FLOOR, /* round towards -infinity */
|
||||
DEC_ROUND_05UP, /* round for reround */
|
||||
DEC_ROUND_MAX /* enum must be less than this */
|
||||
};
|
||||
#define DEC_ROUND_DEFAULT DEC_ROUND_HALF_EVEN;
|
||||
|
||||
typedef struct {
|
||||
int32_t digits; /* working precision */
|
||||
int32_t emax; /* maximum positive exponent */
|
||||
int32_t emin; /* minimum negative exponent */
|
||||
enum rounding round; /* rounding mode */
|
||||
uint32_t traps; /* trap-enabler flags */
|
||||
uint32_t status; /* status flags */
|
||||
uint8_t clamp; /* flag: apply IEEE exponent clamp */
|
||||
#if DECSUBSET
|
||||
uint8_t extended; /* flag: special-values allowed */
|
||||
#endif
|
||||
} decContext;
|
||||
|
||||
/* Maxima and Minima for context settings */
|
||||
#define DEC_MAX_DIGITS 999999999
|
||||
#define DEC_MIN_DIGITS 1
|
||||
#define DEC_MAX_EMAX 999999999
|
||||
#define DEC_MIN_EMAX 0
|
||||
#define DEC_MAX_EMIN 0
|
||||
#define DEC_MIN_EMIN -999999999
|
||||
#define DEC_MAX_MATH 999999 /* max emax, etc., for math funcs. */
|
||||
|
||||
/* Classifications for decimal numbers, aligned with 754 (note that */
|
||||
/* 'normal' and 'subnormal' are meaningful only with a decContext */
|
||||
/* or a fixed size format). */
|
||||
enum decClass {
|
||||
DEC_CLASS_SNAN,
|
||||
DEC_CLASS_QNAN,
|
||||
DEC_CLASS_NEG_INF,
|
||||
DEC_CLASS_NEG_NORMAL,
|
||||
DEC_CLASS_NEG_SUBNORMAL,
|
||||
DEC_CLASS_NEG_ZERO,
|
||||
DEC_CLASS_POS_ZERO,
|
||||
DEC_CLASS_POS_SUBNORMAL,
|
||||
DEC_CLASS_POS_NORMAL,
|
||||
DEC_CLASS_POS_INF
|
||||
};
|
||||
/* Strings for the decClasses */
|
||||
#define DEC_ClassString_SN "sNaN"
|
||||
#define DEC_ClassString_QN "NaN"
|
||||
#define DEC_ClassString_NI "-Infinity"
|
||||
#define DEC_ClassString_NN "-Normal"
|
||||
#define DEC_ClassString_NS "-Subnormal"
|
||||
#define DEC_ClassString_NZ "-Zero"
|
||||
#define DEC_ClassString_PZ "+Zero"
|
||||
#define DEC_ClassString_PS "+Subnormal"
|
||||
#define DEC_ClassString_PN "+Normal"
|
||||
#define DEC_ClassString_PI "+Infinity"
|
||||
#define DEC_ClassString_UN "Invalid"
|
||||
|
||||
/* Trap-enabler and Status flags (exceptional conditions), and */
|
||||
/* their names. The top byte is reserved for internal use */
|
||||
#if DECEXTFLAG
|
||||
/* Extended flags */
|
||||
#define DEC_Conversion_syntax 0x00000001
|
||||
#define DEC_Division_by_zero 0x00000002
|
||||
#define DEC_Division_impossible 0x00000004
|
||||
#define DEC_Division_undefined 0x00000008
|
||||
#define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */
|
||||
#define DEC_Inexact 0x00000020
|
||||
#define DEC_Invalid_context 0x00000040
|
||||
#define DEC_Invalid_operation 0x00000080
|
||||
#if DECSUBSET
|
||||
#define DEC_Lost_digits 0x00000100
|
||||
#endif
|
||||
#define DEC_Overflow 0x00000200
|
||||
#define DEC_Clamped 0x00000400
|
||||
#define DEC_Rounded 0x00000800
|
||||
#define DEC_Subnormal 0x00001000
|
||||
#define DEC_Underflow 0x00002000
|
||||
#else
|
||||
/* IEEE flags only */
|
||||
#define DEC_Conversion_syntax 0x00000010
|
||||
#define DEC_Division_by_zero 0x00000002
|
||||
#define DEC_Division_impossible 0x00000010
|
||||
#define DEC_Division_undefined 0x00000010
|
||||
#define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */
|
||||
#define DEC_Inexact 0x00000001
|
||||
#define DEC_Invalid_context 0x00000010
|
||||
#define DEC_Invalid_operation 0x00000010
|
||||
#if DECSUBSET
|
||||
#define DEC_Lost_digits 0x00000000
|
||||
#endif
|
||||
#define DEC_Overflow 0x00000008
|
||||
#define DEC_Clamped 0x00000000
|
||||
#define DEC_Rounded 0x00000000
|
||||
#define DEC_Subnormal 0x00000000
|
||||
#define DEC_Underflow 0x00000004
|
||||
#endif
|
||||
|
||||
/* IEEE 754 groupings for the flags */
|
||||
/* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal */
|
||||
/* are not in IEEE 754] */
|
||||
#define DEC_IEEE_754_Division_by_zero (DEC_Division_by_zero)
|
||||
#if DECSUBSET
|
||||
#define DEC_IEEE_754_Inexact (DEC_Inexact | DEC_Lost_digits)
|
||||
#else
|
||||
#define DEC_IEEE_754_Inexact (DEC_Inexact)
|
||||
#endif
|
||||
#define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax | \
|
||||
DEC_Division_impossible | \
|
||||
DEC_Division_undefined | \
|
||||
DEC_Insufficient_storage | \
|
||||
DEC_Invalid_context | \
|
||||
DEC_Invalid_operation)
|
||||
#define DEC_IEEE_754_Overflow (DEC_Overflow)
|
||||
#define DEC_IEEE_754_Underflow (DEC_Underflow)
|
||||
|
||||
/* flags which are normally errors (result is qNaN, infinite, or 0) */
|
||||
#define DEC_Errors (DEC_IEEE_754_Division_by_zero | \
|
||||
DEC_IEEE_754_Invalid_operation | \
|
||||
DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow)
|
||||
/* flags which cause a result to become qNaN */
|
||||
#define DEC_NaNs DEC_IEEE_754_Invalid_operation
|
||||
|
||||
/* flags which are normally for information only (finite results) */
|
||||
#if DECSUBSET
|
||||
#define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact \
|
||||
| DEC_Lost_digits)
|
||||
#else
|
||||
#define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)
|
||||
#endif
|
||||
|
||||
/* IEEE 854 names (for compatibility with older decNumber versions) */
|
||||
#define DEC_IEEE_854_Division_by_zero DEC_IEEE_754_Division_by_zero
|
||||
#define DEC_IEEE_854_Inexact DEC_IEEE_754_Inexact
|
||||
#define DEC_IEEE_854_Invalid_operation DEC_IEEE_754_Invalid_operation
|
||||
#define DEC_IEEE_854_Overflow DEC_IEEE_754_Overflow
|
||||
#define DEC_IEEE_854_Underflow DEC_IEEE_754_Underflow
|
||||
|
||||
/* Name strings for the exceptional conditions */
|
||||
#define DEC_Condition_CS "Conversion syntax"
|
||||
#define DEC_Condition_DZ "Division by zero"
|
||||
#define DEC_Condition_DI "Division impossible"
|
||||
#define DEC_Condition_DU "Division undefined"
|
||||
#define DEC_Condition_IE "Inexact"
|
||||
#define DEC_Condition_IS "Insufficient storage"
|
||||
#define DEC_Condition_IC "Invalid context"
|
||||
#define DEC_Condition_IO "Invalid operation"
|
||||
#if DECSUBSET
|
||||
#define DEC_Condition_LD "Lost digits"
|
||||
#endif
|
||||
#define DEC_Condition_OV "Overflow"
|
||||
#define DEC_Condition_PA "Clamped"
|
||||
#define DEC_Condition_RO "Rounded"
|
||||
#define DEC_Condition_SU "Subnormal"
|
||||
#define DEC_Condition_UN "Underflow"
|
||||
#define DEC_Condition_ZE "No status"
|
||||
#define DEC_Condition_MU "Multiple status"
|
||||
#define DEC_Condition_Length 21 /* length of the longest string, */
|
||||
/* including terminator */
|
||||
|
||||
/* Initialization descriptors, used by decContextDefault */
|
||||
#define DEC_INIT_BASE 0
|
||||
#define DEC_INIT_DECIMAL32 32
|
||||
#define DEC_INIT_DECIMAL64 64
|
||||
#define DEC_INIT_DECIMAL128 128
|
||||
/* Synonyms */
|
||||
#define DEC_INIT_DECSINGLE DEC_INIT_DECIMAL32
|
||||
#define DEC_INIT_DECDOUBLE DEC_INIT_DECIMAL64
|
||||
#define DEC_INIT_DECQUAD DEC_INIT_DECIMAL128
|
||||
|
||||
/* decContext routines */
|
||||
extern decContext * decContextClearStatus(decContext *, uint32_t);
|
||||
extern decContext * decContextDefault(decContext *, int32_t);
|
||||
extern enum rounding decContextGetRounding(decContext *);
|
||||
extern uint32_t decContextGetStatus(decContext *);
|
||||
extern decContext * decContextRestoreStatus(decContext *, uint32_t, uint32_t);
|
||||
extern uint32_t decContextSaveStatus(decContext *, uint32_t);
|
||||
extern decContext * decContextSetRounding(decContext *, enum rounding);
|
||||
extern decContext * decContextSetStatus(decContext *, uint32_t);
|
||||
extern decContext * decContextSetStatusFromString(decContext *, const char *);
|
||||
extern decContext * decContextSetStatusFromStringQuiet(decContext *, const char *);
|
||||
extern decContext * decContextSetStatusQuiet(decContext *, uint32_t);
|
||||
extern const char * decContextStatusToString(const decContext *);
|
||||
extern int32_t decContextTestEndian(uint8_t);
|
||||
extern uint32_t decContextTestSavedStatus(uint32_t, uint32_t);
|
||||
extern uint32_t decContextTestStatus(decContext *, uint32_t);
|
||||
extern decContext * decContextZeroStatus(decContext *);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,140 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decDouble.c -- decDouble operations module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises decDouble operations (including conversions) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#include "decContext.h" // public includes
|
||||
#include "decDouble.h" // ..
|
||||
|
||||
/* Constant mappings for shared code */
|
||||
#define DECPMAX DECDOUBLE_Pmax
|
||||
#define DECEMIN DECDOUBLE_Emin
|
||||
#define DECEMAX DECDOUBLE_Emax
|
||||
#define DECEMAXD DECDOUBLE_EmaxD
|
||||
#define DECBYTES DECDOUBLE_Bytes
|
||||
#define DECSTRING DECDOUBLE_String
|
||||
#define DECECONL DECDOUBLE_EconL
|
||||
#define DECBIAS DECDOUBLE_Bias
|
||||
#define DECLETS DECDOUBLE_Declets
|
||||
#define DECQTINY (-DECDOUBLE_Bias)
|
||||
// parameters of next-wider format
|
||||
#define DECWBYTES DECQUAD_Bytes
|
||||
#define DECWPMAX DECQUAD_Pmax
|
||||
#define DECWECONL DECQUAD_EconL
|
||||
#define DECWBIAS DECQUAD_Bias
|
||||
|
||||
/* Type and function mappings for shared code */
|
||||
#define decFloat decDouble // Type name
|
||||
#define decFloatWider decQuad // Type name
|
||||
|
||||
// Utilities and conversions (binary results, extractors, etc.)
|
||||
#define decFloatFromBCD decDoubleFromBCD
|
||||
#define decFloatFromInt32 decDoubleFromInt32
|
||||
#define decFloatFromPacked decDoubleFromPacked
|
||||
#define decFloatFromPackedChecked decDoubleFromPackedChecked
|
||||
#define decFloatFromString decDoubleFromString
|
||||
#define decFloatFromUInt32 decDoubleFromUInt32
|
||||
#define decFloatFromWider decDoubleFromWider
|
||||
#define decFloatGetCoefficient decDoubleGetCoefficient
|
||||
#define decFloatGetExponent decDoubleGetExponent
|
||||
#define decFloatSetCoefficient decDoubleSetCoefficient
|
||||
#define decFloatSetExponent decDoubleSetExponent
|
||||
#define decFloatShow decDoubleShow
|
||||
#define decFloatToBCD decDoubleToBCD
|
||||
#define decFloatToEngString decDoubleToEngString
|
||||
#define decFloatToInt32 decDoubleToInt32
|
||||
#define decFloatToInt32Exact decDoubleToInt32Exact
|
||||
#define decFloatToPacked decDoubleToPacked
|
||||
#define decFloatToString decDoubleToString
|
||||
#define decFloatToUInt32 decDoubleToUInt32
|
||||
#define decFloatToUInt32Exact decDoubleToUInt32Exact
|
||||
#define decFloatToWider decDoubleToWider
|
||||
#define decFloatZero decDoubleZero
|
||||
|
||||
// Computational (result is a decFloat)
|
||||
#define decFloatAbs decDoubleAbs
|
||||
#define decFloatAdd decDoubleAdd
|
||||
#define decFloatAnd decDoubleAnd
|
||||
#define decFloatDivide decDoubleDivide
|
||||
#define decFloatDivideInteger decDoubleDivideInteger
|
||||
#define decFloatFMA decDoubleFMA
|
||||
#define decFloatInvert decDoubleInvert
|
||||
#define decFloatLogB decDoubleLogB
|
||||
#define decFloatMax decDoubleMax
|
||||
#define decFloatMaxMag decDoubleMaxMag
|
||||
#define decFloatMin decDoubleMin
|
||||
#define decFloatMinMag decDoubleMinMag
|
||||
#define decFloatMinus decDoubleMinus
|
||||
#define decFloatMultiply decDoubleMultiply
|
||||
#define decFloatNextMinus decDoubleNextMinus
|
||||
#define decFloatNextPlus decDoubleNextPlus
|
||||
#define decFloatNextToward decDoubleNextToward
|
||||
#define decFloatOr decDoubleOr
|
||||
#define decFloatPlus decDoublePlus
|
||||
#define decFloatQuantize decDoubleQuantize
|
||||
#define decFloatReduce decDoubleReduce
|
||||
#define decFloatRemainder decDoubleRemainder
|
||||
#define decFloatRemainderNear decDoubleRemainderNear
|
||||
#define decFloatRotate decDoubleRotate
|
||||
#define decFloatScaleB decDoubleScaleB
|
||||
#define decFloatShift decDoubleShift
|
||||
#define decFloatSubtract decDoubleSubtract
|
||||
#define decFloatToIntegralValue decDoubleToIntegralValue
|
||||
#define decFloatToIntegralExact decDoubleToIntegralExact
|
||||
#define decFloatXor decDoubleXor
|
||||
|
||||
// Comparisons
|
||||
#define decFloatCompare decDoubleCompare
|
||||
#define decFloatCompareSignal decDoubleCompareSignal
|
||||
#define decFloatCompareTotal decDoubleCompareTotal
|
||||
#define decFloatCompareTotalMag decDoubleCompareTotalMag
|
||||
|
||||
// Copies
|
||||
#define decFloatCanonical decDoubleCanonical
|
||||
#define decFloatCopy decDoubleCopy
|
||||
#define decFloatCopyAbs decDoubleCopyAbs
|
||||
#define decFloatCopyNegate decDoubleCopyNegate
|
||||
#define decFloatCopySign decDoubleCopySign
|
||||
|
||||
// Non-computational
|
||||
#define decFloatClass decDoubleClass
|
||||
#define decFloatClassString decDoubleClassString
|
||||
#define decFloatDigits decDoubleDigits
|
||||
#define decFloatIsCanonical decDoubleIsCanonical
|
||||
#define decFloatIsFinite decDoubleIsFinite
|
||||
#define decFloatIsInfinite decDoubleIsInfinite
|
||||
#define decFloatIsInteger decDoubleIsInteger
|
||||
#define decFloatIsLogical decDoubleIsLogical
|
||||
#define decFloatIsNaN decDoubleIsNaN
|
||||
#define decFloatIsNegative decDoubleIsNegative
|
||||
#define decFloatIsNormal decDoubleIsNormal
|
||||
#define decFloatIsPositive decDoubleIsPositive
|
||||
#define decFloatIsSignaling decDoubleIsSignaling
|
||||
#define decFloatIsSignalling decDoubleIsSignalling
|
||||
#define decFloatIsSigned decDoubleIsSigned
|
||||
#define decFloatIsSubnormal decDoubleIsSubnormal
|
||||
#define decFloatIsZero decDoubleIsZero
|
||||
#define decFloatRadix decDoubleRadix
|
||||
#define decFloatSameQuantum decDoubleSameQuantum
|
||||
#define decFloatVersion decDoubleVersion
|
||||
|
||||
#include "decNumberLocal.h" // local includes (need DECPMAX)
|
||||
#include "decCommon.c" // non-arithmetic decFloat routines
|
||||
#include "decBasic.c" // basic formats routines
|
||||
|
@ -0,0 +1,155 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decDouble.h -- Decimal 64-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECDOUBLE)
|
||||
#define DECDOUBLE
|
||||
|
||||
#define DECDOUBLENAME "decimalDouble" /* Short name */
|
||||
#define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */
|
||||
#define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
/* parameters for decDoubles */
|
||||
#define DECDOUBLE_Bytes 8 /* length */
|
||||
#define DECDOUBLE_Pmax 16 /* maximum precision (digits) */
|
||||
#define DECDOUBLE_Emin -383 /* minimum adjusted exponent */
|
||||
#define DECDOUBLE_Emax 384 /* maximum adjusted exponent */
|
||||
#define DECDOUBLE_EmaxD 3 /* maximum exponent digits */
|
||||
#define DECDOUBLE_Bias 398 /* bias for the exponent */
|
||||
#define DECDOUBLE_String 25 /* maximum string length, +1 */
|
||||
#define DECDOUBLE_EconL 8 /* exponent continuation length */
|
||||
#define DECDOUBLE_Declets 5 /* count of declets */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))
|
||||
|
||||
/* Required includes */
|
||||
#include "decContext.h"
|
||||
#include "decQuad.h"
|
||||
|
||||
/* The decDouble decimal 64-bit type, accessible by all sizes */
|
||||
typedef union {
|
||||
uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */
|
||||
uint16_t shorts[DECDOUBLE_Bytes/2];
|
||||
uint32_t words[DECDOUBLE_Bytes/4];
|
||||
#if DECUSE64
|
||||
uint64_t longs[DECDOUBLE_Bytes/8];
|
||||
#endif
|
||||
} decDouble;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines -- implemented as decFloat routines in common files */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Utilities and conversions, extractors, etc.) */
|
||||
extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
|
||||
extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
|
||||
extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
|
||||
extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);
|
||||
extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
|
||||
extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
|
||||
extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
|
||||
extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *);
|
||||
extern int32_t decDoubleGetExponent(const decDouble *);
|
||||
extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
|
||||
extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
|
||||
extern void decDoubleShow(const decDouble *, const char *);
|
||||
extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
|
||||
extern char * decDoubleToEngString(const decDouble *, char *);
|
||||
extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding);
|
||||
extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
|
||||
extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
|
||||
extern char * decDoubleToString(const decDouble *, char *);
|
||||
extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
|
||||
extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
|
||||
extern decQuad * decDoubleToWider(const decDouble *, decQuad *);
|
||||
extern decDouble * decDoubleZero(decDouble *);
|
||||
|
||||
/* Computational (result is a decDouble) */
|
||||
extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
|
||||
extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
|
||||
/* Comparisons */
|
||||
extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
|
||||
extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
|
||||
extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);
|
||||
|
||||
/* Copies */
|
||||
extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
|
||||
extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
|
||||
extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
|
||||
extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
|
||||
extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);
|
||||
|
||||
/* Non-computational */
|
||||
extern enum decClass decDoubleClass(const decDouble *);
|
||||
extern const char * decDoubleClassString(const decDouble *);
|
||||
extern uint32_t decDoubleDigits(const decDouble *);
|
||||
extern uint32_t decDoubleIsCanonical(const decDouble *);
|
||||
extern uint32_t decDoubleIsFinite(const decDouble *);
|
||||
extern uint32_t decDoubleIsInfinite(const decDouble *);
|
||||
extern uint32_t decDoubleIsInteger(const decDouble *);
|
||||
extern uint32_t decDoubleIsLogical(const decDouble *);
|
||||
extern uint32_t decDoubleIsNaN(const decDouble *);
|
||||
extern uint32_t decDoubleIsNegative(const decDouble *);
|
||||
extern uint32_t decDoubleIsNormal(const decDouble *);
|
||||
extern uint32_t decDoubleIsPositive(const decDouble *);
|
||||
extern uint32_t decDoubleIsSignaling(const decDouble *);
|
||||
extern uint32_t decDoubleIsSignalling(const decDouble *);
|
||||
extern uint32_t decDoubleIsSigned(const decDouble *);
|
||||
extern uint32_t decDoubleIsSubnormal(const decDouble *);
|
||||
extern uint32_t decDoubleIsZero(const decDouble *);
|
||||
extern uint32_t decDoubleRadix(const decDouble *);
|
||||
extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *);
|
||||
extern const char * decDoubleVersion(void);
|
||||
|
||||
/* decNumber conversions; these are implemented as macros so as not */
|
||||
/* to force a dependency on decimal64 and decNumber in decDouble. */
|
||||
/* decDoubleFromNumber returns a decimal64 * to avoid warnings. */
|
||||
#define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
|
||||
#define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,182 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal Number arithmetic module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECNUMBER)
|
||||
#define DECNUMBER
|
||||
#define DECNAME "decNumber" /* Short name */
|
||||
#define DECFULLNAME "Decimal Number Module" /* Verbose name */
|
||||
#define DECAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
#if !defined(DECCONTEXT)
|
||||
#include "decContext.h"
|
||||
#endif
|
||||
|
||||
/* Bit settings for decNumber.bits */
|
||||
#define DECNEG 0x80 /* Sign; 1=negative, 0=positive or zero */
|
||||
#define DECINF 0x40 /* 1=Infinity */
|
||||
#define DECNAN 0x20 /* 1=NaN */
|
||||
#define DECSNAN 0x10 /* 1=sNaN */
|
||||
/* The remaining bits are reserved; they must be 0 */
|
||||
#define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value */
|
||||
|
||||
/* Define the decNumber data structure. The size and shape of the */
|
||||
/* units array in the structure is determined by the following */
|
||||
/* constant. This must not be changed without recompiling the */
|
||||
/* decNumber library modules. */
|
||||
|
||||
#define DECDPUN 3 /* DECimal Digits Per UNit [must be >0 */
|
||||
/* and <10; 3 or powers of 2 are best]. */
|
||||
|
||||
/* DECNUMDIGITS is the default number of digits that can be held in */
|
||||
/* the structure. If undefined, 1 is assumed and it is assumed */
|
||||
/* that the structure will be immediately followed by extra space, */
|
||||
/* as required. DECNUMDIGITS is always >0. */
|
||||
#if !defined(DECNUMDIGITS)
|
||||
#define DECNUMDIGITS 1
|
||||
#endif
|
||||
|
||||
/* The size (integer data type) of each unit is determined by the */
|
||||
/* number of digits it will hold. */
|
||||
#if DECDPUN<=2
|
||||
#define decNumberUnit uint8_t
|
||||
#elif DECDPUN<=4
|
||||
#define decNumberUnit uint16_t
|
||||
#else
|
||||
#define decNumberUnit uint32_t
|
||||
#endif
|
||||
/* The number of units needed is ceil(DECNUMDIGITS/DECDPUN) */
|
||||
#define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)
|
||||
|
||||
/* The data structure... */
|
||||
typedef struct {
|
||||
int32_t digits; /* Count of digits in the coefficient; >0 */
|
||||
int32_t exponent; /* Unadjusted exponent, unbiased, in */
|
||||
/* range: -1999999997 through 999999999 */
|
||||
uint8_t bits; /* Indicator bits (see above) */
|
||||
/* Coefficient, from least significant unit */
|
||||
decNumberUnit lsu[DECNUMUNITS];
|
||||
} decNumber;
|
||||
|
||||
/* Notes: */
|
||||
/* 1. If digits is > DECDPUN then there will one or more */
|
||||
/* decNumberUnits immediately following the first element of lsu.*/
|
||||
/* These contain the remaining (more significant) digits of the */
|
||||
/* number, and may be in the lsu array, or may be guaranteed by */
|
||||
/* some other mechanism (such as being contained in another */
|
||||
/* structure, or being overlaid on dynamically allocated */
|
||||
/* storage). */
|
||||
/* */
|
||||
/* Each integer of the coefficient (except potentially the last) */
|
||||
/* contains DECDPUN digits (e.g., a value in the range 0 through */
|
||||
/* 99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3). */
|
||||
/* */
|
||||
/* 2. A decNumber converted to a string may need up to digits+14 */
|
||||
/* characters. The worst cases (non-exponential and exponential */
|
||||
/* formats) are -0.00000{9...}# and -9.{9...}E+999999999# */
|
||||
/* (where # is '\0') */
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* decNumber public functions and macros */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Conversions */
|
||||
decNumber * decNumberFromInt32(decNumber *, int32_t);
|
||||
decNumber * decNumberFromUInt32(decNumber *, uint32_t);
|
||||
decNumber * decNumberFromString(decNumber *, const char *, decContext *);
|
||||
char * decNumberToString(const decNumber *, char *);
|
||||
char * decNumberToEngString(const decNumber *, char *);
|
||||
uint32_t decNumberToUInt32(const decNumber *, decContext *);
|
||||
int32_t decNumberToInt32(const decNumber *, decContext *);
|
||||
uint8_t * decNumberGetBCD(const decNumber *, uint8_t *);
|
||||
decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
|
||||
|
||||
/* Operators and elementary functions */
|
||||
decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberExp(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberInvert(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberLn(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberLogB(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberReduce(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);
|
||||
decNumber * decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
|
||||
/* Utilities */
|
||||
enum decClass decNumberClass(const decNumber *, decContext *);
|
||||
const char * decNumberClassToString(enum decClass);
|
||||
decNumber * decNumberCopy(decNumber *, const decNumber *);
|
||||
decNumber * decNumberCopyAbs(decNumber *, const decNumber *);
|
||||
decNumber * decNumberCopyNegate(decNumber *, const decNumber *);
|
||||
decNumber * decNumberCopySign(decNumber *, const decNumber *, const decNumber *);
|
||||
decNumber * decNumberNextMinus(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberNextPlus(decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);
|
||||
decNumber * decNumberTrim(decNumber *);
|
||||
const char * decNumberVersion(void);
|
||||
decNumber * decNumberZero(decNumber *);
|
||||
|
||||
/* Functions for testing decNumbers (normality depends on context) */
|
||||
int32_t decNumberIsNormal(const decNumber *, decContext *);
|
||||
int32_t decNumberIsSubnormal(const decNumber *, decContext *);
|
||||
|
||||
/* Macros for testing decNumber *dn */
|
||||
#define decNumberIsCanonical(dn) (1) /* All decNumbers are saintly */
|
||||
#define decNumberIsFinite(dn) (((dn)->bits&DECSPECIAL)==0)
|
||||
#define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0)
|
||||
#define decNumberIsNaN(dn) (((dn)->bits&(DECNAN|DECSNAN))!=0)
|
||||
#define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0)
|
||||
#define decNumberIsQNaN(dn) (((dn)->bits&(DECNAN))!=0)
|
||||
#define decNumberIsSNaN(dn) (((dn)->bits&(DECSNAN))!=0)
|
||||
#define decNumberIsSpecial(dn) (((dn)->bits&DECSPECIAL)!=0)
|
||||
#define decNumberIsZero(dn) (*(dn)->lsu==0 \
|
||||
&& (dn)->digits==1 \
|
||||
&& (((dn)->bits&DECSPECIAL)==0))
|
||||
#define decNumberRadix(dn) (10)
|
||||
|
||||
#endif
|
@ -0,0 +1,757 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decNumber package local type, tuning, and macro definitions */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This header file is included by all modules in the decNumber */
|
||||
/* library, and contains local type definitions, tuning parameters, */
|
||||
/* etc. It should not need to be used by application programs. */
|
||||
/* decNumber.h or one of decDouble (etc.) must be included first. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECNUMBERLOC)
|
||||
#define DECNUMBERLOC
|
||||
#define DECVERSION "decNumber 3.68" /* Package Version [16 max.] */
|
||||
#define DECNLAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
#include <stdlib.h> /* for abs */
|
||||
#include <string.h> /* for memset, strcpy */
|
||||
|
||||
/* Conditional code flag -- set this to match hardware platform */
|
||||
#if !defined(DECLITEND)
|
||||
#define DECLITEND 1 /* 1=little-endian, 0=big-endian */
|
||||
#endif
|
||||
|
||||
/* Conditional code flag -- set this to 1 for best performance */
|
||||
#if !defined(DECUSE64)
|
||||
#define DECUSE64 1 /* 1=use int64s, 0=int32 & smaller only */
|
||||
#endif
|
||||
|
||||
/* Conditional code flag -- set this to 0 to exclude printf calls */
|
||||
#if !defined(DECPRINT)
|
||||
#define DECPRINT 1 /* 1=allow printf calls; 0=no printf */
|
||||
#endif
|
||||
|
||||
/* Conditional check flags -- set these to 0 for best performance */
|
||||
#if !defined(DECCHECK)
|
||||
#define DECCHECK 0 /* 1 to enable robust checking */
|
||||
#endif
|
||||
#if !defined(DECALLOC)
|
||||
#define DECALLOC 0 /* 1 to enable memory accounting */
|
||||
#endif
|
||||
#if !defined(DECTRACE)
|
||||
#define DECTRACE 0 /* 1 to trace certain internals, etc. */
|
||||
#endif
|
||||
|
||||
/* Tuning parameter for decNumber (arbitrary precision) module */
|
||||
#if !defined(DECBUFFER)
|
||||
#define DECBUFFER 36 /* Size basis for local buffers. This */
|
||||
/* should be a common maximum precision */
|
||||
/* rounded up to a multiple of 4; must */
|
||||
/* be zero or positive. */
|
||||
#endif
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Check parameter dependencies */
|
||||
/* ---------------------------------------------------------------- */
|
||||
#if DECCHECK & !DECPRINT
|
||||
#error DECCHECK needs DECPRINT to be useful
|
||||
#endif
|
||||
#if DECALLOC & !DECPRINT
|
||||
#error DECALLOC needs DECPRINT to be useful
|
||||
#endif
|
||||
#if DECTRACE & !DECPRINT
|
||||
#error DECTRACE needs DECPRINT to be useful
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Definitions for all modules (general-purpose) */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Local names for common types -- for safety, decNumber modules do */
|
||||
/* not use int or long directly. */
|
||||
#define Flag uint8_t
|
||||
#define Byte int8_t
|
||||
#define uByte uint8_t
|
||||
#define Short int16_t
|
||||
#define uShort uint16_t
|
||||
#define Int int32_t
|
||||
#define uInt uint32_t
|
||||
#define Unit decNumberUnit
|
||||
#if DECUSE64
|
||||
#define Long int64_t
|
||||
#define uLong uint64_t
|
||||
#endif
|
||||
|
||||
/* Development-use definitions */
|
||||
typedef long int LI; /* for printf arguments only */
|
||||
#define DECNOINT 0 /* 1 to check no internal use of 'int' */
|
||||
/* or stdint types */
|
||||
#if DECNOINT
|
||||
/* if these interfere with your C includes, do not set DECNOINT */
|
||||
#define int ? /* enable to ensure that plain C 'int' */
|
||||
#define long ?? /* .. or 'long' types are not used */
|
||||
#endif
|
||||
|
||||
/* Shared lookup tables */
|
||||
extern const uByte DECSTICKYTAB[10]; /* re-round digits if sticky */
|
||||
extern const uInt DECPOWERS[10]; /* powers of ten table */
|
||||
/* The following are included from decDPD.h */
|
||||
extern const uShort DPD2BIN[1024]; /* DPD -> 0-999 */
|
||||
extern const uShort BIN2DPD[1000]; /* 0-999 -> DPD */
|
||||
extern const uInt DPD2BINK[1024]; /* DPD -> 0-999000 */
|
||||
extern const uInt DPD2BINM[1024]; /* DPD -> 0-999000000 */
|
||||
extern const uByte DPD2BCD8[4096]; /* DPD -> ddd + len */
|
||||
extern const uByte BIN2BCD8[4000]; /* 0-999 -> ddd + len */
|
||||
extern const uShort BCD2DPD[2458]; /* 0-0x999 -> DPD (0x999=2457)*/
|
||||
|
||||
/* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts */
|
||||
/* (that is, sets w to be the high-order word of the 64-bit result; */
|
||||
/* the low-order word is simply u*v.) */
|
||||
/* This version is derived from Knuth via Hacker's Delight; */
|
||||
/* it seems to optimize better than some others tried */
|
||||
#define LONGMUL32HI(w, u, v) { \
|
||||
uInt u0, u1, v0, v1, w0, w1, w2, t; \
|
||||
u0=u & 0xffff; u1=u>>16; \
|
||||
v0=v & 0xffff; v1=v>>16; \
|
||||
w0=u0*v0; \
|
||||
t=u1*v0 + (w0>>16); \
|
||||
w1=t & 0xffff; w2=t>>16; \
|
||||
w1=u0*v1 + w1; \
|
||||
(w)=u1*v1 + w2 + (w1>>16);}
|
||||
|
||||
/* ROUNDUP -- round an integer up to a multiple of n */
|
||||
#define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)
|
||||
#define ROUNDUP4(i) (((i)+3)&~3) /* special for n=4 */
|
||||
|
||||
/* ROUNDDOWN -- round an integer down to a multiple of n */
|
||||
#define ROUNDDOWN(i, n) (((i)/n)*n)
|
||||
#define ROUNDDOWN4(i) ((i)&~3) /* special for n=4 */
|
||||
|
||||
/* References to multi-byte sequences under different sizes; these */
|
||||
/* require locally declared variables, but do not violate strict */
|
||||
/* aliasing or alignment (as did the UINTAT simple cast to uInt). */
|
||||
/* Variables needed are uswork, uiwork, etc. [so do not use at same */
|
||||
/* level in an expression, e.g., UBTOUI(x)==UBTOUI(y) may fail]. */
|
||||
|
||||
/* Return a uInt, etc., from bytes starting at a char* or uByte* */
|
||||
#define UBTOUS(b) (memcpy((void *)&uswork, b, 2), uswork)
|
||||
#define UBTOUI(b) (memcpy((void *)&uiwork, b, 4), uiwork)
|
||||
|
||||
/* Store a uInt, etc., into bytes starting at a char* or uByte*. */
|
||||
/* Returns i, evaluated, for convenience; has to use uiwork because */
|
||||
/* i may be an expression. */
|
||||
#define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)
|
||||
#define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)
|
||||
|
||||
/* X10 and X100 -- multiply integer i by 10 or 100 */
|
||||
/* [shifts are usually faster than multiply; could be conditional] */
|
||||
#define X10(i) (((i)<<1)+((i)<<3))
|
||||
#define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
|
||||
|
||||
/* MAXI and MINI -- general max & min (not in ANSI) for integers */
|
||||
#define MAXI(x,y) ((x)<(y)?(y):(x))
|
||||
#define MINI(x,y) ((x)>(y)?(y):(x))
|
||||
|
||||
/* Useful constants */
|
||||
#define BILLION 1000000000 /* 10**9 */
|
||||
/* CHARMASK: 0x30303030 for ASCII/UTF8; 0xF0F0F0F0 for EBCDIC */
|
||||
#define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0')
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Definitions for arbitary-precision modules (only valid after */
|
||||
/* decNumber.h has been included) */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Limits and constants */
|
||||
#define DECNUMMAXP 999999999 /* maximum precision code can handle */
|
||||
#define DECNUMMAXE 999999999 /* maximum adjusted exponent ditto */
|
||||
#define DECNUMMINE -999999999 /* minimum adjusted exponent ditto */
|
||||
#if (DECNUMMAXP != DEC_MAX_DIGITS)
|
||||
#error Maximum digits mismatch
|
||||
#endif
|
||||
#if (DECNUMMAXE != DEC_MAX_EMAX)
|
||||
#error Maximum exponent mismatch
|
||||
#endif
|
||||
#if (DECNUMMINE != DEC_MIN_EMIN)
|
||||
#error Minimum exponent mismatch
|
||||
#endif
|
||||
|
||||
/* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN */
|
||||
/* digits, and D2UTABLE -- the initializer for the D2U table */
|
||||
#if DECDPUN==1
|
||||
#define DECDPUNMAX 9
|
||||
#define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, \
|
||||
18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
|
||||
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
|
||||
48,49}
|
||||
#elif DECDPUN==2
|
||||
#define DECDPUNMAX 99
|
||||
#define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, \
|
||||
11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \
|
||||
18,19,19,20,20,21,21,22,22,23,23,24,24,25}
|
||||
#elif DECDPUN==3
|
||||
#define DECDPUNMAX 999
|
||||
#define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7, \
|
||||
8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \
|
||||
13,14,14,14,15,15,15,16,16,16,17}
|
||||
#elif DECDPUN==4
|
||||
#define DECDPUNMAX 9999
|
||||
#define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6, \
|
||||
6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \
|
||||
11,11,11,12,12,12,12,13}
|
||||
#elif DECDPUN==5
|
||||
#define DECDPUNMAX 99999
|
||||
#define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5, \
|
||||
5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9, \
|
||||
9,9,10,10,10,10}
|
||||
#elif DECDPUN==6
|
||||
#define DECDPUNMAX 999999
|
||||
#define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4, \
|
||||
4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8, \
|
||||
8,8,8,8,8,9}
|
||||
#elif DECDPUN==7
|
||||
#define DECDPUNMAX 9999999
|
||||
#define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3, \
|
||||
4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7, \
|
||||
7,7,7,7,7,7}
|
||||
#elif DECDPUN==8
|
||||
#define DECDPUNMAX 99999999
|
||||
#define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3, \
|
||||
3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6, \
|
||||
6,6,6,6,6,7}
|
||||
#elif DECDPUN==9
|
||||
#define DECDPUNMAX 999999999
|
||||
#define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3, \
|
||||
3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5, \
|
||||
5,5,6,6,6,6}
|
||||
#elif defined(DECDPUN)
|
||||
#error DECDPUN must be in the range 1-9
|
||||
#endif
|
||||
|
||||
/* ----- Shared data (in decNumber.c) ----- */
|
||||
/* Public lookup table used by the D2U macro (see below) */
|
||||
#define DECMAXD2U 49
|
||||
extern const uByte d2utable[DECMAXD2U+1];
|
||||
|
||||
/* ----- Macros ----- */
|
||||
/* ISZERO -- return true if decNumber dn is a zero */
|
||||
/* [performance-critical in some situations] */
|
||||
#define ISZERO(dn) decNumberIsZero(dn) /* now just a local name */
|
||||
|
||||
/* D2U -- return the number of Units needed to hold d digits */
|
||||
/* (runtime version, with table lookaside for small d) */
|
||||
#if DECDPUN==8
|
||||
#define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
|
||||
#elif DECDPUN==4
|
||||
#define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
|
||||
#else
|
||||
#define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
|
||||
#endif
|
||||
/* SD2U -- static D2U macro (for compile-time calculation) */
|
||||
#define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)
|
||||
|
||||
/* MSUDIGITS -- returns digits in msu, from digits, calculated */
|
||||
/* using D2U */
|
||||
#define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
|
||||
|
||||
/* D2N -- return the number of decNumber structs that would be */
|
||||
/* needed to contain that number of digits (and the initial */
|
||||
/* decNumber struct) safely. Note that one Unit is included in the */
|
||||
/* initial structure. Used for allocating space that is aligned on */
|
||||
/* a decNumber struct boundary. */
|
||||
#define D2N(d) \
|
||||
((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))
|
||||
|
||||
/* TODIGIT -- macro to remove the leading digit from the unsigned */
|
||||
/* integer u at column cut (counting from the right, LSD=0) and */
|
||||
/* place it as an ASCII character into the character pointed to by */
|
||||
/* c. Note that cut must be <= 9, and the maximum value for u is */
|
||||
/* 2,000,000,000 (as is needed for negative exponents of */
|
||||
/* subnormals). The unsigned integer pow is used as a temporary */
|
||||
/* variable. */
|
||||
#define TODIGIT(u, cut, c, pow) { \
|
||||
*(c)='0'; \
|
||||
pow=DECPOWERS[cut]*2; \
|
||||
if ((u)>pow) { \
|
||||
pow*=4; \
|
||||
if ((u)>=pow) {(u)-=pow; *(c)+=8;} \
|
||||
pow/=2; \
|
||||
if ((u)>=pow) {(u)-=pow; *(c)+=4;} \
|
||||
pow/=2; \
|
||||
} \
|
||||
if ((u)>=pow) {(u)-=pow; *(c)+=2;} \
|
||||
pow/=2; \
|
||||
if ((u)>=pow) {(u)-=pow; *(c)+=1;} \
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Definitions for fixed-precision modules (only valid after */
|
||||
/* decSingle.h, decDouble.h, or decQuad.h has been included) */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* bcdnum -- a structure describing a format-independent finite */
|
||||
/* number, whose coefficient is a string of bcd8 uBytes */
|
||||
typedef struct {
|
||||
uByte *msd; /* -> most significant digit */
|
||||
uByte *lsd; /* -> least ditto */
|
||||
uInt sign; /* 0=positive, DECFLOAT_Sign=negative */
|
||||
Int exponent; /* Unadjusted signed exponent (q), or */
|
||||
/* DECFLOAT_NaN etc. for a special */
|
||||
} bcdnum;
|
||||
|
||||
/* Test if exponent or bcdnum exponent must be a special, etc. */
|
||||
#define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp)
|
||||
#define EXPISINF(exp) (exp==DECFLOAT_Inf)
|
||||
#define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN)
|
||||
#define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))
|
||||
|
||||
/* Refer to a 32-bit word or byte in a decFloat (df) by big-endian */
|
||||
/* (array) notation (the 0 word or byte contains the sign bit), */
|
||||
/* automatically adjusting for endianness; similarly address a word */
|
||||
/* in the next-wider format (decFloatWider, or dfw) */
|
||||
#define DECWORDS (DECBYTES/4)
|
||||
#define DECWWORDS (DECWBYTES/4)
|
||||
#if DECLITEND
|
||||
#define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)])
|
||||
#define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)])
|
||||
#define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
|
||||
#else
|
||||
#define DFBYTE(df, off) ((df)->bytes[off])
|
||||
#define DFWORD(df, off) ((df)->words[off])
|
||||
#define DFWWORD(dfw, off) ((dfw)->words[off])
|
||||
#endif
|
||||
|
||||
/* Tests for sign or specials, directly on DECFLOATs */
|
||||
#define DFISSIGNED(df) ((DFWORD(df, 0)&0x80000000)!=0)
|
||||
#define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000)
|
||||
#define DFISINF(df) ((DFWORD(df, 0)&0x7c000000)==0x78000000)
|
||||
#define DFISNAN(df) ((DFWORD(df, 0)&0x7c000000)==0x7c000000)
|
||||
#define DFISQNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7c000000)
|
||||
#define DFISSNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7e000000)
|
||||
|
||||
/* Shared lookup tables */
|
||||
extern const uInt DECCOMBMSD[64]; /* Combination field -> MSD */
|
||||
extern const uInt DECCOMBFROM[48]; /* exp+msd -> Combination */
|
||||
|
||||
/* Private generic (utility) routine */
|
||||
#if DECCHECK || DECTRACE
|
||||
extern void decShowNum(const bcdnum *, const char *);
|
||||
#endif
|
||||
|
||||
/* Format-dependent macros and constants */
|
||||
#if defined(DECPMAX)
|
||||
|
||||
/* Useful constants */
|
||||
#define DECPMAX9 (ROUNDUP(DECPMAX, 9)/9) /* 'Pmax' in 10**9s */
|
||||
/* Top words for a zero */
|
||||
#define SINGLEZERO 0x22500000
|
||||
#define DOUBLEZERO 0x22380000
|
||||
#define QUADZERO 0x22080000
|
||||
/* [ZEROWORD is defined to be one of these in the DFISZERO macro] */
|
||||
|
||||
/* Format-dependent common tests: */
|
||||
/* DFISZERO -- test for (any) zero */
|
||||
/* DFISCCZERO -- test for coefficient continuation being zero */
|
||||
/* DFISCC01 -- test for coefficient contains only 0s and 1s */
|
||||
/* DFISINT -- test for finite and exponent q=0 */
|
||||
/* DFISUINT01 -- test for sign=0, finite, exponent q=0, and */
|
||||
/* MSD=0 or 1 */
|
||||
/* ZEROWORD is also defined here. */
|
||||
/* */
|
||||
/* In DFISZERO the first test checks the least-significant word */
|
||||
/* (most likely to be non-zero); the penultimate tests MSD and */
|
||||
/* DPDs in the signword, and the final test excludes specials and */
|
||||
/* MSD>7. DFISINT similarly has to allow for the two forms of */
|
||||
/* MSD codes. DFISUINT01 only has to allow for one form of MSD */
|
||||
/* code. */
|
||||
#if DECPMAX==7
|
||||
#define ZEROWORD SINGLEZERO
|
||||
/* [test macros not needed except for Zero] */
|
||||
#define DFISZERO(df) ((DFWORD(df, 0)&0x1c0fffff)==0 \
|
||||
&& (DFWORD(df, 0)&0x60000000)!=0x60000000)
|
||||
#elif DECPMAX==16
|
||||
#define ZEROWORD DOUBLEZERO
|
||||
#define DFISZERO(df) ((DFWORD(df, 1)==0 \
|
||||
&& (DFWORD(df, 0)&0x1c03ffff)==0 \
|
||||
&& (DFWORD(df, 0)&0x60000000)!=0x60000000))
|
||||
#define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000 \
|
||||
||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000)
|
||||
#define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000)
|
||||
#define DFISCCZERO(df) (DFWORD(df, 1)==0 \
|
||||
&& (DFWORD(df, 0)&0x0003ffff)==0)
|
||||
#define DFISCC01(df) ((DFWORD(df, 0)&~0xfffc9124)==0 \
|
||||
&& (DFWORD(df, 1)&~0x49124491)==0)
|
||||
#elif DECPMAX==34
|
||||
#define ZEROWORD QUADZERO
|
||||
#define DFISZERO(df) ((DFWORD(df, 3)==0 \
|
||||
&& DFWORD(df, 2)==0 \
|
||||
&& DFWORD(df, 1)==0 \
|
||||
&& (DFWORD(df, 0)&0x1c003fff)==0 \
|
||||
&& (DFWORD(df, 0)&0x60000000)!=0x60000000))
|
||||
#define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000 \
|
||||
||(DFWORD(df, 0)&0x7bffc000)==0x6a080000)
|
||||
#define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000)
|
||||
#define DFISCCZERO(df) (DFWORD(df, 3)==0 \
|
||||
&& DFWORD(df, 2)==0 \
|
||||
&& DFWORD(df, 1)==0 \
|
||||
&& (DFWORD(df, 0)&0x00003fff)==0)
|
||||
|
||||
#define DFISCC01(df) ((DFWORD(df, 0)&~0xffffc912)==0 \
|
||||
&& (DFWORD(df, 1)&~0x44912449)==0 \
|
||||
&& (DFWORD(df, 2)&~0x12449124)==0 \
|
||||
&& (DFWORD(df, 3)&~0x49124491)==0)
|
||||
#endif
|
||||
|
||||
/* Macros to test if a certain 10 bits of a uInt or pair of uInts */
|
||||
/* are a canonical declet [higher or lower bits are ignored]. */
|
||||
/* declet is at offset 0 (from the right) in a uInt: */
|
||||
#define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e)
|
||||
/* declet is at offset k (a multiple of 2) in a uInt: */
|
||||
#define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0 \
|
||||
|| ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
|
||||
/* declet is at offset k (a multiple of 2) in a pair of uInts: */
|
||||
/* [the top 2 bits will always be in the more-significant uInt] */
|
||||
#define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0 \
|
||||
|| ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k))) \
|
||||
|| ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
|
||||
|
||||
/* Macro to test whether a full-length (length DECPMAX) BCD8 */
|
||||
/* coefficient, starting at uByte u, is all zeros */
|
||||
/* Test just the LSWord first, then the remainder as a sequence */
|
||||
/* of tests in order to avoid same-level use of UBTOUI */
|
||||
#if DECPMAX==7
|
||||
#define ISCOEFFZERO(u) ( \
|
||||
UBTOUI((u)+DECPMAX-4)==0 \
|
||||
&& UBTOUS((u)+DECPMAX-6)==0 \
|
||||
&& *(u)==0)
|
||||
#elif DECPMAX==16
|
||||
#define ISCOEFFZERO(u) ( \
|
||||
UBTOUI((u)+DECPMAX-4)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-8)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-12)==0 \
|
||||
&& UBTOUI(u)==0)
|
||||
#elif DECPMAX==34
|
||||
#define ISCOEFFZERO(u) ( \
|
||||
UBTOUI((u)+DECPMAX-4)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-8)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-12)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-16)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-20)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-24)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-28)==0 \
|
||||
&& UBTOUI((u)+DECPMAX-32)==0 \
|
||||
&& UBTOUS(u)==0)
|
||||
#endif
|
||||
|
||||
/* Macros and masks for the sign, exponent continuation, and MSD */
|
||||
/* Get the sign as DECFLOAT_Sign or 0 */
|
||||
#define GETSIGN(df) (DFWORD(df, 0)&0x80000000)
|
||||
/* Get the exponent continuation from a decFloat *df as an Int */
|
||||
#define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))
|
||||
/* Ditto, from the next-wider format */
|
||||
#define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))
|
||||
/* Get the biased exponent similarly */
|
||||
#define GETEXP(df) ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df)))
|
||||
/* Get the unbiased exponent similarly */
|
||||
#define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)
|
||||
/* Get the MSD similarly (as uInt) */
|
||||
#define GETMSD(df) (DECCOMBMSD[DFWORD((df), 0)>>26])
|
||||
|
||||
/* Compile-time computes of the exponent continuation field masks */
|
||||
/* full exponent continuation field: */
|
||||
#define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
|
||||
/* same, not including its first digit (the qNaN/sNaN selector): */
|
||||
#define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
|
||||
|
||||
/* Macros to decode the coefficient in a finite decFloat *df into */
|
||||
/* a BCD string (uByte *bcdin) of length DECPMAX uBytes. */
|
||||
|
||||
/* In-line sequence to convert least significant 10 bits of uInt */
|
||||
/* dpd to three BCD8 digits starting at uByte u. Note that an */
|
||||
/* extra byte is written to the right of the three digits because */
|
||||
/* four bytes are moved at a time for speed; the alternative */
|
||||
/* macro moves exactly three bytes (usually slower). */
|
||||
#define dpd2bcd8(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 4)
|
||||
#define dpd2bcd83(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 3)
|
||||
|
||||
/* Decode the declets. After extracting each one, it is decoded */
|
||||
/* to BCD8 using a table lookup (also used for variable-length */
|
||||
/* decode). Each DPD decode is 3 bytes BCD8 plus a one-byte */
|
||||
/* length which is not used, here). Fixed-length 4-byte moves */
|
||||
/* are fast, however, almost everywhere, and so are used except */
|
||||
/* for the final three bytes (to avoid overrun). The code below */
|
||||
/* is 36 instructions for Doubles and about 70 for Quads, even */
|
||||
/* on IA32. */
|
||||
|
||||
/* Two macros are defined for each format: */
|
||||
/* GETCOEFF extracts the coefficient of the current format */
|
||||
/* GETWCOEFF extracts the coefficient of the next-wider format. */
|
||||
/* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */
|
||||
|
||||
#if DECPMAX==7
|
||||
#define GETCOEFF(df, bcd) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
*(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
|
||||
dpd2bcd8(bcd+1, sourhi>>10); \
|
||||
dpd2bcd83(bcd+4, sourhi);}
|
||||
#define GETWCOEFF(df, bcd) { \
|
||||
uInt sourhi=DFWWORD(df, 0); \
|
||||
uInt sourlo=DFWWORD(df, 1); \
|
||||
*(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
|
||||
dpd2bcd8(bcd+1, sourhi>>8); \
|
||||
dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
|
||||
dpd2bcd8(bcd+7, sourlo>>20); \
|
||||
dpd2bcd8(bcd+10, sourlo>>10); \
|
||||
dpd2bcd83(bcd+13, sourlo);}
|
||||
|
||||
#elif DECPMAX==16
|
||||
#define GETCOEFF(df, bcd) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
uInt sourlo=DFWORD(df, 1); \
|
||||
*(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
|
||||
dpd2bcd8(bcd+1, sourhi>>8); \
|
||||
dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
|
||||
dpd2bcd8(bcd+7, sourlo>>20); \
|
||||
dpd2bcd8(bcd+10, sourlo>>10); \
|
||||
dpd2bcd83(bcd+13, sourlo);}
|
||||
#define GETWCOEFF(df, bcd) { \
|
||||
uInt sourhi=DFWWORD(df, 0); \
|
||||
uInt sourmh=DFWWORD(df, 1); \
|
||||
uInt sourml=DFWWORD(df, 2); \
|
||||
uInt sourlo=DFWWORD(df, 3); \
|
||||
*(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
|
||||
dpd2bcd8(bcd+1, sourhi>>4); \
|
||||
dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
|
||||
dpd2bcd8(bcd+7, sourmh>>16); \
|
||||
dpd2bcd8(bcd+10, sourmh>>6); \
|
||||
dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
|
||||
dpd2bcd8(bcd+16, sourml>>18); \
|
||||
dpd2bcd8(bcd+19, sourml>>8); \
|
||||
dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
|
||||
dpd2bcd8(bcd+25, sourlo>>20); \
|
||||
dpd2bcd8(bcd+28, sourlo>>10); \
|
||||
dpd2bcd83(bcd+31, sourlo);}
|
||||
|
||||
#elif DECPMAX==34
|
||||
#define GETCOEFF(df, bcd) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
uInt sourmh=DFWORD(df, 1); \
|
||||
uInt sourml=DFWORD(df, 2); \
|
||||
uInt sourlo=DFWORD(df, 3); \
|
||||
*(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
|
||||
dpd2bcd8(bcd+1, sourhi>>4); \
|
||||
dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
|
||||
dpd2bcd8(bcd+7, sourmh>>16); \
|
||||
dpd2bcd8(bcd+10, sourmh>>6); \
|
||||
dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
|
||||
dpd2bcd8(bcd+16, sourml>>18); \
|
||||
dpd2bcd8(bcd+19, sourml>>8); \
|
||||
dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
|
||||
dpd2bcd8(bcd+25, sourlo>>20); \
|
||||
dpd2bcd8(bcd+28, sourlo>>10); \
|
||||
dpd2bcd83(bcd+31, sourlo);}
|
||||
|
||||
#define GETWCOEFF(df, bcd) {??} /* [should never be used] */
|
||||
#endif
|
||||
|
||||
/* Macros to decode the coefficient in a finite decFloat *df into */
|
||||
/* a base-billion uInt array, with the least-significant */
|
||||
/* 0-999999999 'digit' at offset 0. */
|
||||
|
||||
/* Decode the declets. After extracting each one, it is decoded */
|
||||
/* to binary using a table lookup. Three tables are used; one */
|
||||
/* the usual DPD to binary, the other two pre-multiplied by 1000 */
|
||||
/* and 1000000 to avoid multiplication during decode. These */
|
||||
/* tables can also be used for multiplying up the MSD as the DPD */
|
||||
/* code for 0 through 9 is the identity. */
|
||||
#define DPD2BIN0 DPD2BIN /* for prettier code */
|
||||
|
||||
#if DECPMAX==7
|
||||
#define GETCOEFFBILL(df, buf) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
(buf)[0]=DPD2BIN0[sourhi&0x3ff] \
|
||||
+DPD2BINK[(sourhi>>10)&0x3ff] \
|
||||
+DPD2BINM[DECCOMBMSD[sourhi>>26]];}
|
||||
|
||||
#elif DECPMAX==16
|
||||
#define GETCOEFFBILL(df, buf) { \
|
||||
uInt sourhi, sourlo; \
|
||||
sourlo=DFWORD(df, 1); \
|
||||
(buf)[0]=DPD2BIN0[sourlo&0x3ff] \
|
||||
+DPD2BINK[(sourlo>>10)&0x3ff] \
|
||||
+DPD2BINM[(sourlo>>20)&0x3ff]; \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff] \
|
||||
+DPD2BINK[(sourhi>>8)&0x3ff] \
|
||||
+DPD2BINM[DECCOMBMSD[sourhi>>26]];}
|
||||
|
||||
#elif DECPMAX==34
|
||||
#define GETCOEFFBILL(df, buf) { \
|
||||
uInt sourhi, sourmh, sourml, sourlo; \
|
||||
sourlo=DFWORD(df, 3); \
|
||||
(buf)[0]=DPD2BIN0[sourlo&0x3ff] \
|
||||
+DPD2BINK[(sourlo>>10)&0x3ff] \
|
||||
+DPD2BINM[(sourlo>>20)&0x3ff]; \
|
||||
sourml=DFWORD(df, 2); \
|
||||
(buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff] \
|
||||
+DPD2BINK[(sourml>>8)&0x3ff] \
|
||||
+DPD2BINM[(sourml>>18)&0x3ff]; \
|
||||
sourmh=DFWORD(df, 1); \
|
||||
(buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff] \
|
||||
+DPD2BINK[(sourmh>>6)&0x3ff] \
|
||||
+DPD2BINM[(sourmh>>16)&0x3ff]; \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff] \
|
||||
+DPD2BINK[(sourhi>>4)&0x3ff] \
|
||||
+DPD2BINM[DECCOMBMSD[sourhi>>26]];}
|
||||
|
||||
#endif
|
||||
|
||||
/* Macros to decode the coefficient in a finite decFloat *df into */
|
||||
/* a base-thousand uInt array (of size DECLETS+1, to allow for */
|
||||
/* the MSD), with the least-significant 0-999 'digit' at offset 0.*/
|
||||
|
||||
/* Decode the declets. After extracting each one, it is decoded */
|
||||
/* to binary using a table lookup. */
|
||||
#if DECPMAX==7
|
||||
#define GETCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
(buf)[0]=DPD2BIN[sourhi&0x3ff]; \
|
||||
(buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff]; \
|
||||
(buf)[2]=DECCOMBMSD[sourhi>>26];}
|
||||
|
||||
#elif DECPMAX==16
|
||||
#define GETCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi, sourlo; \
|
||||
sourlo=DFWORD(df, 1); \
|
||||
(buf)[0]=DPD2BIN[sourlo&0x3ff]; \
|
||||
(buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
|
||||
(buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \
|
||||
(buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff]; \
|
||||
(buf)[5]=DECCOMBMSD[sourhi>>26];}
|
||||
|
||||
#elif DECPMAX==34
|
||||
#define GETCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi, sourmh, sourml, sourlo; \
|
||||
sourlo=DFWORD(df, 3); \
|
||||
(buf)[0]=DPD2BIN[sourlo&0x3ff]; \
|
||||
(buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
|
||||
(buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
|
||||
sourml=DFWORD(df, 2); \
|
||||
(buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \
|
||||
(buf)[4]=DPD2BIN[(sourml>>8)&0x3ff]; \
|
||||
(buf)[5]=DPD2BIN[(sourml>>18)&0x3ff]; \
|
||||
sourmh=DFWORD(df, 1); \
|
||||
(buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
|
||||
(buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff]; \
|
||||
(buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff]; \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
|
||||
(buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff]; \
|
||||
(buf)[11]=DECCOMBMSD[sourhi>>26];}
|
||||
#endif
|
||||
|
||||
|
||||
/* Macros to decode the coefficient in a finite decFloat *df and */
|
||||
/* add to a base-thousand uInt array (as for GETCOEFFTHOU). */
|
||||
/* After the addition then most significant 'digit' in the array */
|
||||
/* might have a value larger then 10 (with a maximum of 19). */
|
||||
#if DECPMAX==7
|
||||
#define ADDCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi=DFWORD(df, 0); \
|
||||
(buf)[0]+=DPD2BIN[sourhi&0x3ff]; \
|
||||
if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
|
||||
(buf)[1]+=DPD2BIN[(sourhi>>10)&0x3ff]; \
|
||||
if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
|
||||
(buf)[2]+=DECCOMBMSD[sourhi>>26];}
|
||||
|
||||
#elif DECPMAX==16
|
||||
#define ADDCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi, sourlo; \
|
||||
sourlo=DFWORD(df, 1); \
|
||||
(buf)[0]+=DPD2BIN[sourlo&0x3ff]; \
|
||||
if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
|
||||
(buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \
|
||||
if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
|
||||
(buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \
|
||||
if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[3]+=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \
|
||||
if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \
|
||||
(buf)[4]+=DPD2BIN[(sourhi>>8)&0x3ff]; \
|
||||
if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \
|
||||
(buf)[5]+=DECCOMBMSD[sourhi>>26];}
|
||||
|
||||
#elif DECPMAX==34
|
||||
#define ADDCOEFFTHOU(df, buf) { \
|
||||
uInt sourhi, sourmh, sourml, sourlo; \
|
||||
sourlo=DFWORD(df, 3); \
|
||||
(buf)[0]+=DPD2BIN[sourlo&0x3ff]; \
|
||||
if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
|
||||
(buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \
|
||||
if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
|
||||
(buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \
|
||||
if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \
|
||||
sourml=DFWORD(df, 2); \
|
||||
(buf)[3]+=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \
|
||||
if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \
|
||||
(buf)[4]+=DPD2BIN[(sourml>>8)&0x3ff]; \
|
||||
if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \
|
||||
(buf)[5]+=DPD2BIN[(sourml>>18)&0x3ff]; \
|
||||
if (buf[5]>999) {buf[5]-=1000; buf[6]++;} \
|
||||
sourmh=DFWORD(df, 1); \
|
||||
(buf)[6]+=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
|
||||
if (buf[6]>999) {buf[6]-=1000; buf[7]++;} \
|
||||
(buf)[7]+=DPD2BIN[(sourmh>>6)&0x3ff]; \
|
||||
if (buf[7]>999) {buf[7]-=1000; buf[8]++;} \
|
||||
(buf)[8]+=DPD2BIN[(sourmh>>16)&0x3ff]; \
|
||||
if (buf[8]>999) {buf[8]-=1000; buf[9]++;} \
|
||||
sourhi=DFWORD(df, 0); \
|
||||
(buf)[9]+=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
|
||||
if (buf[9]>999) {buf[9]-=1000; buf[10]++;} \
|
||||
(buf)[10]+=DPD2BIN[(sourhi>>4)&0x3ff]; \
|
||||
if (buf[10]>999) {buf[10]-=1000; buf[11]++;} \
|
||||
(buf)[11]+=DECCOMBMSD[sourhi>>26];}
|
||||
#endif
|
||||
|
||||
|
||||
/* Set a decFloat to the maximum positive finite number (Nmax) */
|
||||
#if DECPMAX==7
|
||||
#define DFSETNMAX(df) \
|
||||
{DFWORD(df, 0)=0x77f3fcff;}
|
||||
#elif DECPMAX==16
|
||||
#define DFSETNMAX(df) \
|
||||
{DFWORD(df, 0)=0x77fcff3f; \
|
||||
DFWORD(df, 1)=0xcff3fcff;}
|
||||
#elif DECPMAX==34
|
||||
#define DFSETNMAX(df) \
|
||||
{DFWORD(df, 0)=0x77ffcff3; \
|
||||
DFWORD(df, 1)=0xfcff3fcf; \
|
||||
DFWORD(df, 2)=0xf3fcff3f; \
|
||||
DFWORD(df, 3)=0xcff3fcff;}
|
||||
#endif
|
||||
|
||||
/* [end of format-dependent macros and constants] */
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error decNumberLocal included more than once
|
||||
#endif
|
@ -0,0 +1,220 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Packed Decimal conversion module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2002. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises the routines for Packed Decimal format */
|
||||
/* numbers. Conversions are supplied to and from decNumber, which in */
|
||||
/* turn supports: */
|
||||
/* conversions to and from string */
|
||||
/* arithmetic routines */
|
||||
/* utilities. */
|
||||
/* Conversions from decNumber to and from densely packed decimal */
|
||||
/* formats are provided by the decimal32 through decimal128 modules. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#include <string.h> // for NULL
|
||||
#include "decNumber.h" // base number library
|
||||
#include "decPacked.h" // packed decimal
|
||||
#include "decNumberLocal.h" // decNumber local types, etc.
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decPackedFromNumber -- convert decNumber to BCD Packed Decimal */
|
||||
/* */
|
||||
/* bcd is the BCD bytes */
|
||||
/* length is the length of the BCD array */
|
||||
/* scale is the scale result */
|
||||
/* dn is the decNumber */
|
||||
/* returns bcd, or NULL if error */
|
||||
/* */
|
||||
/* The number is converted to a BCD packed decimal byte array, */
|
||||
/* right aligned in the bcd array, whose length is indicated by the */
|
||||
/* second parameter. The final 4-bit nibble in the array will be a */
|
||||
/* sign nibble, C (1100) for + and D (1101) for -. Unused bytes and */
|
||||
/* nibbles to the left of the number are set to 0. */
|
||||
/* */
|
||||
/* scale is set to the scale of the number (this is the exponent, */
|
||||
/* negated). To force the number to a specified scale, first use the */
|
||||
/* decNumberRescale routine, which will round and change the exponent */
|
||||
/* as necessary. */
|
||||
/* */
|
||||
/* If there is an error (that is, the decNumber has too many digits */
|
||||
/* to fit in length bytes, or it is a NaN or Infinity), NULL is */
|
||||
/* returned and the bcd and scale results are unchanged. Otherwise */
|
||||
/* bcd is returned. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,
|
||||
const decNumber *dn) {
|
||||
const Unit *up=dn->lsu; // Unit array pointer
|
||||
uByte obyte, *out; // current output byte, and where it goes
|
||||
Int indigs=dn->digits; // digits processed
|
||||
uInt cut=DECDPUN; // downcounter per Unit
|
||||
uInt u=*up; // work
|
||||
uInt nib; // ..
|
||||
#if DECDPUN<=4
|
||||
uInt temp; // ..
|
||||
#endif
|
||||
|
||||
if (dn->digits>length*2-1 // too long ..
|
||||
||(dn->bits & DECSPECIAL)) return NULL; // .. or special -- hopeless
|
||||
|
||||
if (dn->bits&DECNEG) obyte=DECPMINUS; // set the sign ..
|
||||
else obyte=DECPPLUS;
|
||||
*scale=-dn->exponent; // .. and scale
|
||||
|
||||
// loop from lowest (rightmost) byte
|
||||
out=bcd+length-1; // -> final byte
|
||||
for (; out>=bcd; out--) {
|
||||
if (indigs>0) {
|
||||
if (cut==0) {
|
||||
up++;
|
||||
u=*up;
|
||||
cut=DECDPUN;
|
||||
}
|
||||
#if DECDPUN<=4
|
||||
temp=(u*6554)>>16; // fast /10
|
||||
nib=u-X10(temp);
|
||||
u=temp;
|
||||
#else
|
||||
nib=u%10; // cannot use *6554 trick :-(
|
||||
u=u/10;
|
||||
#endif
|
||||
obyte|=(nib<<4);
|
||||
indigs--;
|
||||
cut--;
|
||||
}
|
||||
*out=obyte;
|
||||
obyte=0; // assume 0
|
||||
if (indigs>0) {
|
||||
if (cut==0) {
|
||||
up++;
|
||||
u=*up;
|
||||
cut=DECDPUN;
|
||||
}
|
||||
#if DECDPUN<=4
|
||||
temp=(u*6554)>>16; // as above
|
||||
obyte=(uByte)(u-X10(temp));
|
||||
u=temp;
|
||||
#else
|
||||
obyte=(uByte)(u%10);
|
||||
u=u/10;
|
||||
#endif
|
||||
indigs--;
|
||||
cut--;
|
||||
}
|
||||
} // loop
|
||||
|
||||
return bcd;
|
||||
} // decPackedFromNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decPackedToNumber -- convert BCD Packed Decimal to a decNumber */
|
||||
/* */
|
||||
/* bcd is the BCD bytes */
|
||||
/* length is the length of the BCD array */
|
||||
/* scale is the scale associated with the BCD integer */
|
||||
/* dn is the decNumber [with space for length*2 digits] */
|
||||
/* returns dn, or NULL if error */
|
||||
/* */
|
||||
/* The BCD packed decimal byte array, together with an associated */
|
||||
/* scale, is converted to a decNumber. The BCD array is assumed full */
|
||||
/* of digits, and must be ended by a 4-bit sign nibble in the least */
|
||||
/* significant four bits of the final byte. */
|
||||
/* */
|
||||
/* The scale is used (negated) as the exponent of the decNumber. */
|
||||
/* Note that zeros may have a sign and/or a scale. */
|
||||
/* */
|
||||
/* The decNumber structure is assumed to have sufficient space to */
|
||||
/* hold the converted number (that is, up to length*2-1 digits), so */
|
||||
/* no error is possible unless the adjusted exponent is out of range, */
|
||||
/* no sign nibble was found, or a sign nibble was found before the */
|
||||
/* final nibble. In these error cases, NULL is returned and the */
|
||||
/* decNumber will be 0. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decNumber * decPackedToNumber(const uByte *bcd, Int length,
|
||||
const Int *scale, decNumber *dn) {
|
||||
const uByte *last=bcd+length-1; // -> last byte
|
||||
const uByte *first; // -> first non-zero byte
|
||||
uInt nib; // work nibble
|
||||
Unit *up=dn->lsu; // output pointer
|
||||
Int digits; // digits count
|
||||
Int cut=0; // phase of output
|
||||
|
||||
decNumberZero(dn); // default result
|
||||
last=&bcd[length-1];
|
||||
nib=*last & 0x0f; // get the sign
|
||||
if (nib==DECPMINUS || nib==DECPMINUSALT) dn->bits=DECNEG;
|
||||
else if (nib<=9) return NULL; // not a sign nibble
|
||||
|
||||
// skip leading zero bytes [final byte is always non-zero, due to sign]
|
||||
for (first=bcd; *first==0;) first++;
|
||||
digits=(last-first)*2+1; // calculate digits ..
|
||||
if ((*first & 0xf0)==0) digits--; // adjust for leading zero nibble
|
||||
if (digits!=0) dn->digits=digits; // count of actual digits [if 0,
|
||||
// leave as 1]
|
||||
|
||||
// check the adjusted exponent; note that scale could be unbounded
|
||||
dn->exponent=-*scale; // set the exponent
|
||||
if (*scale>=0) { // usual case
|
||||
if ((dn->digits-*scale-1)<-DECNUMMAXE) { // underflow
|
||||
decNumberZero(dn);
|
||||
return NULL;}
|
||||
}
|
||||
else { // -ve scale; +ve exponent
|
||||
// need to be careful to avoid wrap, here, also BADINT case
|
||||
if ((*scale<-DECNUMMAXE) // overflow even without digits
|
||||
|| ((dn->digits-*scale-1)>DECNUMMAXE)) { // overflow
|
||||
decNumberZero(dn);
|
||||
return NULL;}
|
||||
}
|
||||
if (digits==0) return dn; // result was zero
|
||||
|
||||
// copy the digits to the number's units, starting at the lsu
|
||||
// [unrolled]
|
||||
for (;;) { // forever
|
||||
// left nibble first
|
||||
nib=(unsigned)(*last & 0xf0)>>4;
|
||||
// got a digit, in nib
|
||||
if (nib>9) {decNumberZero(dn); return NULL;}
|
||||
|
||||
if (cut==0) *up=(Unit)nib;
|
||||
else *up=(Unit)(*up+nib*DECPOWERS[cut]);
|
||||
digits--;
|
||||
if (digits==0) break; // got them all
|
||||
cut++;
|
||||
if (cut==DECDPUN) {
|
||||
up++;
|
||||
cut=0;
|
||||
}
|
||||
last--; // ready for next
|
||||
nib=*last & 0x0f; // get right nibble
|
||||
if (nib>9) {decNumberZero(dn); return NULL;}
|
||||
|
||||
// got a digit, in nib
|
||||
if (cut==0) *up=(Unit)nib;
|
||||
else *up=(Unit)(*up+nib*DECPOWERS[cut]);
|
||||
digits--;
|
||||
if (digits==0) break; // got them all
|
||||
cut++;
|
||||
if (cut==DECDPUN) {
|
||||
up++;
|
||||
cut=0;
|
||||
}
|
||||
} // forever
|
||||
|
||||
return dn;
|
||||
} // decPackedToNumber
|
||||
|
@ -0,0 +1,52 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Packed Decimal conversion module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2005. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECPACKED)
|
||||
#define DECPACKED
|
||||
#define DECPNAME "decPacked" /* Short name */
|
||||
#define DECPFULLNAME "Packed Decimal conversions" /* Verbose name */
|
||||
#define DECPAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
#define DECPACKED_DefP 32 /* default precision */
|
||||
|
||||
#ifndef DECNUMDIGITS
|
||||
#define DECNUMDIGITS DECPACKED_DefP /* size if not already defined*/
|
||||
#endif
|
||||
#include "decNumber.h" /* context and number library */
|
||||
|
||||
/* Sign nibble constants */
|
||||
#if !defined(DECPPLUSALT)
|
||||
#define DECPPLUSALT 0x0A /* alternate plus nibble */
|
||||
#define DECPMINUSALT 0x0B /* alternate minus nibble */
|
||||
#define DECPPLUS 0x0C /* preferred plus nibble */
|
||||
#define DECPMINUS 0x0D /* preferred minus nibble */
|
||||
#define DECPPLUSALT2 0x0E /* alternate plus nibble */
|
||||
#define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* decPacked public routines */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Conversions */
|
||||
uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *,
|
||||
const decNumber *);
|
||||
decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *,
|
||||
decNumber *);
|
||||
|
||||
#endif
|
@ -0,0 +1,135 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decQuad.c -- decQuad operations module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises decQuad operations (including conversions) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
|
||||
/* Constant mappings for shared code */
|
||||
#define DECPMAX DECQUAD_Pmax
|
||||
#define DECEMIN DECQUAD_Emin
|
||||
#define DECEMAX DECQUAD_Emax
|
||||
#define DECEMAXD DECQUAD_EmaxD
|
||||
#define DECBYTES DECQUAD_Bytes
|
||||
#define DECSTRING DECQUAD_String
|
||||
#define DECECONL DECQUAD_EconL
|
||||
#define DECBIAS DECQUAD_Bias
|
||||
#define DECLETS DECQUAD_Declets
|
||||
#define DECQTINY (-DECQUAD_Bias)
|
||||
|
||||
/* Type and function mappings for shared code */
|
||||
#define decFloat decQuad // Type name
|
||||
|
||||
// Utilities and conversions (binary results, extractors, etc.)
|
||||
#define decFloatFromBCD decQuadFromBCD
|
||||
#define decFloatFromInt32 decQuadFromInt32
|
||||
#define decFloatFromPacked decQuadFromPacked
|
||||
#define decFloatFromPackedChecked decQuadFromPackedChecked
|
||||
#define decFloatFromString decQuadFromString
|
||||
#define decFloatFromUInt32 decQuadFromUInt32
|
||||
#define decFloatFromWider decQuadFromWider
|
||||
#define decFloatGetCoefficient decQuadGetCoefficient
|
||||
#define decFloatGetExponent decQuadGetExponent
|
||||
#define decFloatSetCoefficient decQuadSetCoefficient
|
||||
#define decFloatSetExponent decQuadSetExponent
|
||||
#define decFloatShow decQuadShow
|
||||
#define decFloatToBCD decQuadToBCD
|
||||
#define decFloatToEngString decQuadToEngString
|
||||
#define decFloatToInt32 decQuadToInt32
|
||||
#define decFloatToInt32Exact decQuadToInt32Exact
|
||||
#define decFloatToPacked decQuadToPacked
|
||||
#define decFloatToString decQuadToString
|
||||
#define decFloatToUInt32 decQuadToUInt32
|
||||
#define decFloatToUInt32Exact decQuadToUInt32Exact
|
||||
#define decFloatToWider decQuadToWider
|
||||
#define decFloatZero decQuadZero
|
||||
|
||||
// Computational (result is a decFloat)
|
||||
#define decFloatAbs decQuadAbs
|
||||
#define decFloatAdd decQuadAdd
|
||||
#define decFloatAnd decQuadAnd
|
||||
#define decFloatDivide decQuadDivide
|
||||
#define decFloatDivideInteger decQuadDivideInteger
|
||||
#define decFloatFMA decQuadFMA
|
||||
#define decFloatInvert decQuadInvert
|
||||
#define decFloatLogB decQuadLogB
|
||||
#define decFloatMax decQuadMax
|
||||
#define decFloatMaxMag decQuadMaxMag
|
||||
#define decFloatMin decQuadMin
|
||||
#define decFloatMinMag decQuadMinMag
|
||||
#define decFloatMinus decQuadMinus
|
||||
#define decFloatMultiply decQuadMultiply
|
||||
#define decFloatNextMinus decQuadNextMinus
|
||||
#define decFloatNextPlus decQuadNextPlus
|
||||
#define decFloatNextToward decQuadNextToward
|
||||
#define decFloatOr decQuadOr
|
||||
#define decFloatPlus decQuadPlus
|
||||
#define decFloatQuantize decQuadQuantize
|
||||
#define decFloatReduce decQuadReduce
|
||||
#define decFloatRemainder decQuadRemainder
|
||||
#define decFloatRemainderNear decQuadRemainderNear
|
||||
#define decFloatRotate decQuadRotate
|
||||
#define decFloatScaleB decQuadScaleB
|
||||
#define decFloatShift decQuadShift
|
||||
#define decFloatSubtract decQuadSubtract
|
||||
#define decFloatToIntegralValue decQuadToIntegralValue
|
||||
#define decFloatToIntegralExact decQuadToIntegralExact
|
||||
#define decFloatXor decQuadXor
|
||||
|
||||
// Comparisons
|
||||
#define decFloatCompare decQuadCompare
|
||||
#define decFloatCompareSignal decQuadCompareSignal
|
||||
#define decFloatCompareTotal decQuadCompareTotal
|
||||
#define decFloatCompareTotalMag decQuadCompareTotalMag
|
||||
|
||||
// Copies
|
||||
#define decFloatCanonical decQuadCanonical
|
||||
#define decFloatCopy decQuadCopy
|
||||
#define decFloatCopyAbs decQuadCopyAbs
|
||||
#define decFloatCopyNegate decQuadCopyNegate
|
||||
#define decFloatCopySign decQuadCopySign
|
||||
|
||||
// Non-computational
|
||||
#define decFloatClass decQuadClass
|
||||
#define decFloatClassString decQuadClassString
|
||||
#define decFloatDigits decQuadDigits
|
||||
#define decFloatIsCanonical decQuadIsCanonical
|
||||
#define decFloatIsFinite decQuadIsFinite
|
||||
#define decFloatIsInfinite decQuadIsInfinite
|
||||
#define decFloatIsInteger decQuadIsInteger
|
||||
#define decFloatIsLogical decQuadIsLogical
|
||||
#define decFloatIsNaN decQuadIsNaN
|
||||
#define decFloatIsNegative decQuadIsNegative
|
||||
#define decFloatIsNormal decQuadIsNormal
|
||||
#define decFloatIsPositive decQuadIsPositive
|
||||
#define decFloatIsSignaling decQuadIsSignaling
|
||||
#define decFloatIsSignalling decQuadIsSignalling
|
||||
#define decFloatIsSigned decQuadIsSigned
|
||||
#define decFloatIsSubnormal decQuadIsSubnormal
|
||||
#define decFloatIsZero decQuadIsZero
|
||||
#define decFloatRadix decQuadRadix
|
||||
#define decFloatSameQuantum decQuadSameQuantum
|
||||
#define decFloatVersion decQuadVersion
|
||||
|
||||
/* And now the code itself */
|
||||
#include "decContext.h" // public includes
|
||||
#include "decQuad.h" // ..
|
||||
#include "decNumberLocal.h" // local includes (need DECPMAX)
|
||||
#include "decCommon.c" // non-arithmetic decFloat routines
|
||||
#include "decBasic.c" // basic formats routines
|
||||
|
@ -0,0 +1,177 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decQuad.h -- Decimal 128-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2010. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This include file is always included by decSingle and decDouble, */
|
||||
/* and therefore also holds useful constants used by all three. */
|
||||
|
||||
#if !defined(DECQUAD)
|
||||
#define DECQUAD
|
||||
|
||||
#define DECQUADNAME "decimalQuad" /* Short name */
|
||||
#define DECQUADTITLE "Decimal 128-bit datum" /* Verbose name */
|
||||
#define DECQUADAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
/* parameters for decQuads */
|
||||
#define DECQUAD_Bytes 16 /* length */
|
||||
#define DECQUAD_Pmax 34 /* maximum precision (digits) */
|
||||
#define DECQUAD_Emin -6143 /* minimum adjusted exponent */
|
||||
#define DECQUAD_Emax 6144 /* maximum adjusted exponent */
|
||||
#define DECQUAD_EmaxD 4 /* maximum exponent digits */
|
||||
#define DECQUAD_Bias 6176 /* bias for the exponent */
|
||||
#define DECQUAD_String 43 /* maximum string length, +1 */
|
||||
#define DECQUAD_EconL 12 /* exponent continuation length */
|
||||
#define DECQUAD_Declets 11 /* count of declets */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
|
||||
|
||||
/* Required include */
|
||||
#include "decContext.h"
|
||||
|
||||
/* The decQuad decimal 128-bit type, accessible by all sizes */
|
||||
typedef union {
|
||||
uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */
|
||||
uint16_t shorts[DECQUAD_Bytes/2];
|
||||
uint32_t words[DECQUAD_Bytes/4];
|
||||
#if DECUSE64
|
||||
uint64_t longs[DECQUAD_Bytes/8];
|
||||
#endif
|
||||
} decQuad;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Shared constants */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* sign and special values [top 32-bits; last two bits are don't-care
|
||||
for Infinity on input, last bit don't-care for NaNs] */
|
||||
#define DECFLOAT_Sign 0x80000000 /* 1 00000 00 Sign */
|
||||
#define DECFLOAT_NaN 0x7c000000 /* 0 11111 00 NaN generic */
|
||||
#define DECFLOAT_qNaN 0x7c000000 /* 0 11111 00 qNaN */
|
||||
#define DECFLOAT_sNaN 0x7e000000 /* 0 11111 10 sNaN */
|
||||
#define DECFLOAT_Inf 0x78000000 /* 0 11110 00 Infinity */
|
||||
#define DECFLOAT_MinSp 0x78000000 /* minimum special value */
|
||||
/* [specials are all >=MinSp] */
|
||||
/* Sign nibble constants */
|
||||
#if !defined(DECPPLUSALT)
|
||||
#define DECPPLUSALT 0x0A /* alternate plus nibble */
|
||||
#define DECPMINUSALT 0x0B /* alternate minus nibble */
|
||||
#define DECPPLUS 0x0C /* preferred plus nibble */
|
||||
#define DECPMINUS 0x0D /* preferred minus nibble */
|
||||
#define DECPPLUSALT2 0x0E /* alternate plus nibble */
|
||||
#define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines -- implemented as decFloat routines in common files */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Utilities and conversions, extractors, etc.) */
|
||||
extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
|
||||
extern decQuad * decQuadFromInt32(decQuad *, int32_t);
|
||||
extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
|
||||
extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);
|
||||
extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
|
||||
extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
|
||||
extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *);
|
||||
extern int32_t decQuadGetExponent(const decQuad *);
|
||||
extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);
|
||||
extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);
|
||||
extern void decQuadShow(const decQuad *, const char *);
|
||||
extern int32_t decQuadToBCD(const decQuad *, int32_t *, uint8_t *);
|
||||
extern char * decQuadToEngString(const decQuad *, char *);
|
||||
extern int32_t decQuadToInt32(const decQuad *, decContext *, enum rounding);
|
||||
extern int32_t decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);
|
||||
extern int32_t decQuadToPacked(const decQuad *, int32_t *, uint8_t *);
|
||||
extern char * decQuadToString(const decQuad *, char *);
|
||||
extern uint32_t decQuadToUInt32(const decQuad *, decContext *, enum rounding);
|
||||
extern uint32_t decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);
|
||||
extern decQuad * decQuadZero(decQuad *);
|
||||
|
||||
/* Computational (result is a decQuad) */
|
||||
extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);
|
||||
extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
|
||||
/* Comparisons */
|
||||
extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);
|
||||
extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);
|
||||
extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);
|
||||
|
||||
/* Copies */
|
||||
extern decQuad * decQuadCanonical(decQuad *, const decQuad *);
|
||||
extern decQuad * decQuadCopy(decQuad *, const decQuad *);
|
||||
extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);
|
||||
extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);
|
||||
extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);
|
||||
|
||||
/* Non-computational */
|
||||
extern enum decClass decQuadClass(const decQuad *);
|
||||
extern const char * decQuadClassString(const decQuad *);
|
||||
extern uint32_t decQuadDigits(const decQuad *);
|
||||
extern uint32_t decQuadIsCanonical(const decQuad *);
|
||||
extern uint32_t decQuadIsFinite(const decQuad *);
|
||||
extern uint32_t decQuadIsInteger(const decQuad *);
|
||||
extern uint32_t decQuadIsLogical(const decQuad *);
|
||||
extern uint32_t decQuadIsInfinite(const decQuad *);
|
||||
extern uint32_t decQuadIsNaN(const decQuad *);
|
||||
extern uint32_t decQuadIsNegative(const decQuad *);
|
||||
extern uint32_t decQuadIsNormal(const decQuad *);
|
||||
extern uint32_t decQuadIsPositive(const decQuad *);
|
||||
extern uint32_t decQuadIsSignaling(const decQuad *);
|
||||
extern uint32_t decQuadIsSignalling(const decQuad *);
|
||||
extern uint32_t decQuadIsSigned(const decQuad *);
|
||||
extern uint32_t decQuadIsSubnormal(const decQuad *);
|
||||
extern uint32_t decQuadIsZero(const decQuad *);
|
||||
extern uint32_t decQuadRadix(const decQuad *);
|
||||
extern uint32_t decQuadSameQuantum(const decQuad *, const decQuad *);
|
||||
extern const char * decQuadVersion(void);
|
||||
|
||||
/* decNumber conversions; these are implemented as macros so as not */
|
||||
/* to force a dependency on decimal128 and decNumber in decQuad. */
|
||||
/* decQuadFromNumber returns a decimal128 * to avoid warnings. */
|
||||
#define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn)
|
||||
#define decQuadFromNumber(dq, dn, set) decimal128FromNumber((decimal128 *)(dq), dn, set)
|
||||
|
||||
#endif
|
@ -0,0 +1,71 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decSingle.c -- decSingle operations module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises decSingle operations (including conversions) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#include "decContext.h" // public includes
|
||||
#include "decSingle.h" // public includes
|
||||
|
||||
/* Constant mappings for shared code */
|
||||
#define DECPMAX DECSINGLE_Pmax
|
||||
#define DECEMIN DECSINGLE_Emin
|
||||
#define DECEMAX DECSINGLE_Emax
|
||||
#define DECEMAXD DECSINGLE_EmaxD
|
||||
#define DECBYTES DECSINGLE_Bytes
|
||||
#define DECSTRING DECSINGLE_String
|
||||
#define DECECONL DECSINGLE_EconL
|
||||
#define DECBIAS DECSINGLE_Bias
|
||||
#define DECLETS DECSINGLE_Declets
|
||||
#define DECQTINY (-DECSINGLE_Bias)
|
||||
// parameters of next-wider format
|
||||
#define DECWBYTES DECDOUBLE_Bytes
|
||||
#define DECWPMAX DECDOUBLE_Pmax
|
||||
#define DECWECONL DECDOUBLE_EconL
|
||||
#define DECWBIAS DECDOUBLE_Bias
|
||||
|
||||
/* Type and function mappings for shared code */
|
||||
#define decFloat decSingle // Type name
|
||||
#define decFloatWider decDouble // Type name
|
||||
|
||||
// Utility (binary results, extractors, etc.)
|
||||
#define decFloatFromBCD decSingleFromBCD
|
||||
#define decFloatFromPacked decSingleFromPacked
|
||||
#define decFloatFromPackedChecked decSingleFromPackedChecked
|
||||
#define decFloatFromString decSingleFromString
|
||||
#define decFloatFromWider decSingleFromWider
|
||||
#define decFloatGetCoefficient decSingleGetCoefficient
|
||||
#define decFloatGetExponent decSingleGetExponent
|
||||
#define decFloatSetCoefficient decSingleSetCoefficient
|
||||
#define decFloatSetExponent decSingleSetExponent
|
||||
#define decFloatShow decSingleShow
|
||||
#define decFloatToBCD decSingleToBCD
|
||||
#define decFloatToEngString decSingleToEngString
|
||||
#define decFloatToPacked decSingleToPacked
|
||||
#define decFloatToString decSingleToString
|
||||
#define decFloatToWider decSingleToWider
|
||||
#define decFloatZero decSingleZero
|
||||
|
||||
// Non-computational
|
||||
#define decFloatRadix decSingleRadix
|
||||
#define decFloatVersion decSingleVersion
|
||||
|
||||
#include "decNumberLocal.h" // local includes (need DECPMAX)
|
||||
#include "decCommon.c" // non-basic decFloat routines
|
||||
// [Do not include decBasic.c for decimal32]
|
||||
|
@ -0,0 +1,86 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decSingle.h -- Decimal 32-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is included in the package as decNumber.pdf. This */
|
||||
/* document is also available in HTML, together with specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECSINGLE)
|
||||
#define DECSINGLE
|
||||
|
||||
#define DECSINGLENAME "decSingle" /* Short name */
|
||||
#define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */
|
||||
#define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
/* parameters for decSingles */
|
||||
#define DECSINGLE_Bytes 4 /* length */
|
||||
#define DECSINGLE_Pmax 7 /* maximum precision (digits) */
|
||||
#define DECSINGLE_Emin -95 /* minimum adjusted exponent */
|
||||
#define DECSINGLE_Emax 96 /* maximum adjusted exponent */
|
||||
#define DECSINGLE_EmaxD 3 /* maximum exponent digits */
|
||||
#define DECSINGLE_Bias 101 /* bias for the exponent */
|
||||
#define DECSINGLE_String 16 /* maximum string length, +1 */
|
||||
#define DECSINGLE_EconL 6 /* exponent continuation length */
|
||||
#define DECSINGLE_Declets 2 /* count of declets */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
|
||||
|
||||
/* Required includes */
|
||||
#include "decContext.h"
|
||||
#include "decQuad.h"
|
||||
#include "decDouble.h"
|
||||
|
||||
/* The decSingle decimal 32-bit type, accessible by all sizes */
|
||||
typedef union {
|
||||
uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */
|
||||
uint16_t shorts[DECSINGLE_Bytes/2];
|
||||
uint32_t words[DECSINGLE_Bytes/4];
|
||||
} decSingle;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines -- implemented as decFloat routines in common files */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Utilities (binary argument(s) or result, extractors, etc.) */
|
||||
extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
|
||||
extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
|
||||
extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);
|
||||
extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
|
||||
extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
|
||||
extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *);
|
||||
extern int32_t decSingleGetExponent(const decSingle *);
|
||||
extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
|
||||
extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
|
||||
extern void decSingleShow(const decSingle *, const char *);
|
||||
extern int32_t decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
|
||||
extern char * decSingleToEngString(const decSingle *, char *);
|
||||
extern int32_t decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
|
||||
extern char * decSingleToString(const decSingle *, char *);
|
||||
extern decDouble * decSingleToWider(const decSingle *, decDouble *);
|
||||
extern decSingle * decSingleZero(decSingle *);
|
||||
|
||||
/* (No Arithmetic routines for decSingle) */
|
||||
|
||||
/* Non-computational */
|
||||
extern uint32_t decSingleRadix(const decSingle *);
|
||||
extern const char * decSingleVersion(void);
|
||||
|
||||
/* decNumber conversions; these are implemented as macros so as not */
|
||||
/* to force a dependency on decimal32 and decNumber in decSingle. */
|
||||
/* decSingleFromNumber returns a decimal32 * to avoid warnings. */
|
||||
#define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)
|
||||
#define decSingleFromNumber(dq, dn, set) decimal32FromNumber((decimal32 *)(dq), dn, set)
|
||||
|
||||
#endif
|
@ -0,0 +1,553 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 128-bit format module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises the routines for decimal128 format numbers. */
|
||||
/* Conversions are supplied to and from decNumber and String. */
|
||||
/* */
|
||||
/* This is used when decNumber provides operations, either for all */
|
||||
/* operations or as a proxy between decNumber and decSingle. */
|
||||
/* */
|
||||
/* Error handling is the same as decNumber (qv.). */
|
||||
/* ------------------------------------------------------------------ */
|
||||
#include <string.h> // [for memset/memcpy]
|
||||
#include <stdio.h> // [for printf]
|
||||
|
||||
#define DECNUMDIGITS 34 // make decNumbers with space for 34
|
||||
#include "decNumber.h" // base number library
|
||||
#include "decNumberLocal.h" // decNumber local types, etc.
|
||||
#include "decimal128.h" // our primary include
|
||||
|
||||
/* Utility routines and tables [in decimal64.c] */
|
||||
// DPD2BIN and the reverse are renamed to prevent link-time conflict
|
||||
// if decQuad is also built in the same executable
|
||||
#define DPD2BIN DPD2BINx
|
||||
#define BIN2DPD BIN2DPDx
|
||||
extern const uInt COMBEXP[32], COMBMSD[32];
|
||||
extern const uShort DPD2BIN[1024];
|
||||
extern const uShort BIN2DPD[1000]; // [not used]
|
||||
extern const uByte BIN2CHAR[4001];
|
||||
|
||||
extern void decDigitsFromDPD(decNumber *, const uInt *, Int);
|
||||
extern void decDigitsToDPD(const decNumber *, uInt *, Int);
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
void decimal128Show(const decimal128 *); // for debug
|
||||
extern void decNumberShow(const decNumber *); // ..
|
||||
#endif
|
||||
|
||||
/* Useful macro */
|
||||
// Clear a structure (e.g., a decNumber)
|
||||
#define DEC_clear(d) memset(d, 0, sizeof(*d))
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal128FromNumber -- convert decNumber to decimal128 */
|
||||
/* */
|
||||
/* ds is the target decimal128 */
|
||||
/* dn is the source number (assumed valid) */
|
||||
/* set is the context, used only for reporting errors */
|
||||
/* */
|
||||
/* The set argument is used only for status reporting and for the */
|
||||
/* rounding mode (used if the coefficient is more than DECIMAL128_Pmax*/
|
||||
/* digits or an overflow is detected). If the exponent is out of the */
|
||||
/* valid range then Overflow or Underflow will be raised. */
|
||||
/* After Underflow a subnormal result is possible. */
|
||||
/* */
|
||||
/* DEC_Clamped is set if the number has to be 'folded down' to fit, */
|
||||
/* by reducing its exponent and multiplying the coefficient by a */
|
||||
/* power of ten, or if the exponent on a zero had to be clamped. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn,
|
||||
decContext *set) {
|
||||
uInt status=0; // status accumulator
|
||||
Int ae; // adjusted exponent
|
||||
decNumber dw; // work
|
||||
decContext dc; // ..
|
||||
uInt comb, exp; // ..
|
||||
uInt uiwork; // for macros
|
||||
uInt targar[4]={0,0,0,0}; // target 128-bit
|
||||
#define targhi targar[3] // name the word with the sign
|
||||
#define targmh targar[2] // name the words
|
||||
#define targml targar[1] // ..
|
||||
#define targlo targar[0] // ..
|
||||
|
||||
// If the number has too many digits, or the exponent could be
|
||||
// out of range then reduce the number under the appropriate
|
||||
// constraints. This could push the number to Infinity or zero,
|
||||
// so this check and rounding must be done before generating the
|
||||
// decimal128]
|
||||
ae=dn->exponent+dn->digits-1; // [0 if special]
|
||||
if (dn->digits>DECIMAL128_Pmax // too many digits
|
||||
|| ae>DECIMAL128_Emax // likely overflow
|
||||
|| ae<DECIMAL128_Emin) { // likely underflow
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL128); // [no traps]
|
||||
dc.round=set->round; // use supplied rounding
|
||||
decNumberPlus(&dw, dn, &dc); // (round and check)
|
||||
// [this changes -0 to 0, so enforce the sign...]
|
||||
dw.bits|=dn->bits&DECNEG;
|
||||
status=dc.status; // save status
|
||||
dn=&dw; // use the work number
|
||||
} // maybe out of range
|
||||
|
||||
if (dn->bits&DECSPECIAL) { // a special value
|
||||
if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24;
|
||||
else { // sNaN or qNaN
|
||||
if ((*dn->lsu!=0 || dn->digits>1) // non-zero coefficient
|
||||
&& (dn->digits<DECIMAL128_Pmax)) { // coefficient fits
|
||||
decDigitsToDPD(dn, targar, 0);
|
||||
}
|
||||
if (dn->bits&DECNAN) targhi|=DECIMAL_NaN<<24;
|
||||
else targhi|=DECIMAL_sNaN<<24;
|
||||
} // a NaN
|
||||
} // special
|
||||
|
||||
else { // is finite
|
||||
if (decNumberIsZero(dn)) { // is a zero
|
||||
// set and clamp exponent
|
||||
if (dn->exponent<-DECIMAL128_Bias) {
|
||||
exp=0; // low clamp
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
else {
|
||||
exp=dn->exponent+DECIMAL128_Bias; // bias exponent
|
||||
if (exp>DECIMAL128_Ehigh) { // top clamp
|
||||
exp=DECIMAL128_Ehigh;
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
}
|
||||
comb=(exp>>9) & 0x18; // msd=0, exp top 2 bits ..
|
||||
}
|
||||
else { // non-zero finite number
|
||||
uInt msd; // work
|
||||
Int pad=0; // coefficient pad digits
|
||||
|
||||
// the dn is known to fit, but it may need to be padded
|
||||
exp=(uInt)(dn->exponent+DECIMAL128_Bias); // bias exponent
|
||||
if (exp>DECIMAL128_Ehigh) { // fold-down case
|
||||
pad=exp-DECIMAL128_Ehigh;
|
||||
exp=DECIMAL128_Ehigh; // [to maximum]
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
|
||||
// [fastpath for common case is not a win, here]
|
||||
decDigitsToDPD(dn, targar, pad);
|
||||
// save and clear the top digit
|
||||
msd=targhi>>14;
|
||||
targhi&=0x00003fff;
|
||||
|
||||
// create the combination field
|
||||
if (msd>=8) comb=0x18 | ((exp>>11) & 0x06) | (msd & 0x01);
|
||||
else comb=((exp>>9) & 0x18) | msd;
|
||||
}
|
||||
targhi|=comb<<26; // add combination field ..
|
||||
targhi|=(exp&0xfff)<<14; // .. and exponent continuation
|
||||
} // finite
|
||||
|
||||
if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit
|
||||
|
||||
// now write to storage; this is endian
|
||||
if (DECLITEND) {
|
||||
// lo -> hi
|
||||
UBFROMUI(d128->bytes, targlo);
|
||||
UBFROMUI(d128->bytes+4, targml);
|
||||
UBFROMUI(d128->bytes+8, targmh);
|
||||
UBFROMUI(d128->bytes+12, targhi);
|
||||
}
|
||||
else {
|
||||
// hi -> lo
|
||||
UBFROMUI(d128->bytes, targhi);
|
||||
UBFROMUI(d128->bytes+4, targmh);
|
||||
UBFROMUI(d128->bytes+8, targml);
|
||||
UBFROMUI(d128->bytes+12, targlo);
|
||||
}
|
||||
|
||||
if (status!=0) decContextSetStatus(set, status); // pass on status
|
||||
// decimal128Show(d128);
|
||||
return d128;
|
||||
} // decimal128FromNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal128ToNumber -- convert decimal128 to decNumber */
|
||||
/* d128 is the source decimal128 */
|
||||
/* dn is the target number, with appropriate space */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) {
|
||||
uInt msd; // coefficient MSD
|
||||
uInt exp; // exponent top two bits
|
||||
uInt comb; // combination field
|
||||
Int need; // work
|
||||
uInt uiwork; // for macros
|
||||
uInt sourar[4]; // source 128-bit
|
||||
#define sourhi sourar[3] // name the word with the sign
|
||||
#define sourmh sourar[2] // and the mid-high word
|
||||
#define sourml sourar[1] // and the mod-low word
|
||||
#define sourlo sourar[0] // and the lowest word
|
||||
|
||||
// load source from storage; this is endian
|
||||
if (DECLITEND) {
|
||||
sourlo=UBTOUI(d128->bytes ); // directly load the low int
|
||||
sourml=UBTOUI(d128->bytes+4 ); // then the mid-low
|
||||
sourmh=UBTOUI(d128->bytes+8 ); // then the mid-high
|
||||
sourhi=UBTOUI(d128->bytes+12); // then the high int
|
||||
}
|
||||
else {
|
||||
sourhi=UBTOUI(d128->bytes ); // directly load the high int
|
||||
sourmh=UBTOUI(d128->bytes+4 ); // then the mid-high
|
||||
sourml=UBTOUI(d128->bytes+8 ); // then the mid-low
|
||||
sourlo=UBTOUI(d128->bytes+12); // then the low int
|
||||
}
|
||||
|
||||
comb=(sourhi>>26)&0x1f; // combination field
|
||||
|
||||
decNumberZero(dn); // clean number
|
||||
if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative
|
||||
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) { // is a special
|
||||
if (msd==0) {
|
||||
dn->bits|=DECINF;
|
||||
return dn; // no coefficient needed
|
||||
}
|
||||
else if (sourhi&0x02000000) dn->bits|=DECSNAN;
|
||||
else dn->bits|=DECNAN;
|
||||
msd=0; // no top digit
|
||||
}
|
||||
else { // is a finite number
|
||||
dn->exponent=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; // unbiased
|
||||
}
|
||||
|
||||
// get the coefficient
|
||||
sourhi&=0x00003fff; // clean coefficient continuation
|
||||
if (msd) { // non-zero msd
|
||||
sourhi|=msd<<14; // prefix to coefficient
|
||||
need=12; // process 12 declets
|
||||
}
|
||||
else { // msd=0
|
||||
if (sourhi) need=11; // declets to process
|
||||
else if (sourmh) need=10;
|
||||
else if (sourml) need=7;
|
||||
else if (sourlo) need=4;
|
||||
else return dn; // easy: coefficient is 0
|
||||
} //msd=0
|
||||
|
||||
decDigitsFromDPD(dn, sourar, need); // process declets
|
||||
// decNumberShow(dn);
|
||||
return dn;
|
||||
} // decimal128ToNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-scientific-string -- conversion to numeric string */
|
||||
/* to-engineering-string -- conversion to numeric string */
|
||||
/* */
|
||||
/* decimal128ToString(d128, string); */
|
||||
/* decimal128ToEngString(d128, string); */
|
||||
/* */
|
||||
/* d128 is the decimal128 format number to convert */
|
||||
/* string is the string where the result will be laid out */
|
||||
/* */
|
||||
/* string must be at least 24 characters */
|
||||
/* */
|
||||
/* No error is possible, and no status can be set. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
char * decimal128ToEngString(const decimal128 *d128, char *string){
|
||||
decNumber dn; // work
|
||||
decimal128ToNumber(d128, &dn);
|
||||
decNumberToEngString(&dn, string);
|
||||
return string;
|
||||
} // decimal128ToEngString
|
||||
|
||||
char * decimal128ToString(const decimal128 *d128, char *string){
|
||||
uInt msd; // coefficient MSD
|
||||
Int exp; // exponent top two bits or full
|
||||
uInt comb; // combination field
|
||||
char *cstart; // coefficient start
|
||||
char *c; // output pointer in string
|
||||
const uByte *u; // work
|
||||
char *s, *t; // .. (source, target)
|
||||
Int dpd; // ..
|
||||
Int pre, e; // ..
|
||||
uInt uiwork; // for macros
|
||||
|
||||
uInt sourar[4]; // source 128-bit
|
||||
#define sourhi sourar[3] // name the word with the sign
|
||||
#define sourmh sourar[2] // and the mid-high word
|
||||
#define sourml sourar[1] // and the mod-low word
|
||||
#define sourlo sourar[0] // and the lowest word
|
||||
|
||||
// load source from storage; this is endian
|
||||
if (DECLITEND) {
|
||||
sourlo=UBTOUI(d128->bytes ); // directly load the low int
|
||||
sourml=UBTOUI(d128->bytes+4 ); // then the mid-low
|
||||
sourmh=UBTOUI(d128->bytes+8 ); // then the mid-high
|
||||
sourhi=UBTOUI(d128->bytes+12); // then the high int
|
||||
}
|
||||
else {
|
||||
sourhi=UBTOUI(d128->bytes ); // directly load the high int
|
||||
sourmh=UBTOUI(d128->bytes+4 ); // then the mid-high
|
||||
sourml=UBTOUI(d128->bytes+8 ); // then the mid-low
|
||||
sourlo=UBTOUI(d128->bytes+12); // then the low int
|
||||
}
|
||||
|
||||
c=string; // where result will go
|
||||
if (((Int)sourhi)<0) *c++='-'; // handle sign
|
||||
|
||||
comb=(sourhi>>26)&0x1f; // combination field
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) {
|
||||
if (msd==0) { // infinity
|
||||
strcpy(c, "Inf");
|
||||
strcpy(c+3, "inity");
|
||||
return string; // easy
|
||||
}
|
||||
if (sourhi&0x02000000) *c++='s'; // sNaN
|
||||
strcpy(c, "NaN"); // complete word
|
||||
c+=3; // step past
|
||||
if (sourlo==0 && sourml==0 && sourmh==0
|
||||
&& (sourhi&0x0003ffff)==0) return string; // zero payload
|
||||
// otherwise drop through to add integer; set correct exp
|
||||
exp=0; msd=0; // setup for following code
|
||||
}
|
||||
else exp=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; // unbiased
|
||||
|
||||
// convert 34 digits of significand to characters
|
||||
cstart=c; // save start of coefficient
|
||||
if (msd) *c++='0'+(char)msd; // non-zero most significant digit
|
||||
|
||||
// Now decode the declets. After extracting each one, it is
|
||||
// decoded to binary and then to a 4-char sequence by table lookup;
|
||||
// the 4-chars are a 1-char length (significant digits, except 000
|
||||
// has length 0). This allows us to left-align the first declet
|
||||
// with non-zero content, then remaining ones are full 3-char
|
||||
// length. We use fixed-length memcpys because variable-length
|
||||
// causes a subroutine call in GCC. (These are length 4 for speed
|
||||
// and are safe because the array has an extra terminator byte.)
|
||||
#define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \
|
||||
if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \
|
||||
else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;}
|
||||
dpd=(sourhi>>4)&0x3ff; // declet 1
|
||||
dpd2char;
|
||||
dpd=((sourhi&0xf)<<6) | (sourmh>>26); // declet 2
|
||||
dpd2char;
|
||||
dpd=(sourmh>>16)&0x3ff; // declet 3
|
||||
dpd2char;
|
||||
dpd=(sourmh>>6)&0x3ff; // declet 4
|
||||
dpd2char;
|
||||
dpd=((sourmh&0x3f)<<4) | (sourml>>28); // declet 5
|
||||
dpd2char;
|
||||
dpd=(sourml>>18)&0x3ff; // declet 6
|
||||
dpd2char;
|
||||
dpd=(sourml>>8)&0x3ff; // declet 7
|
||||
dpd2char;
|
||||
dpd=((sourml&0xff)<<2) | (sourlo>>30); // declet 8
|
||||
dpd2char;
|
||||
dpd=(sourlo>>20)&0x3ff; // declet 9
|
||||
dpd2char;
|
||||
dpd=(sourlo>>10)&0x3ff; // declet 10
|
||||
dpd2char;
|
||||
dpd=(sourlo)&0x3ff; // declet 11
|
||||
dpd2char;
|
||||
|
||||
if (c==cstart) *c++='0'; // all zeros -- make 0
|
||||
|
||||
if (exp==0) { // integer or NaN case -- easy
|
||||
*c='\0'; // terminate
|
||||
return string;
|
||||
}
|
||||
|
||||
/* non-0 exponent */
|
||||
e=0; // assume no E
|
||||
pre=c-cstart+exp;
|
||||
// [here, pre-exp is the digits count (==1 for zero)]
|
||||
if (exp>0 || pre<-5) { // need exponential form
|
||||
e=pre-1; // calculate E value
|
||||
pre=1; // assume one digit before '.'
|
||||
} // exponential form
|
||||
|
||||
/* modify the coefficient, adding 0s, '.', and E+nn as needed */
|
||||
s=c-1; // source (LSD)
|
||||
if (pre>0) { // ddd.ddd (plain), perhaps with E
|
||||
char *dotat=cstart+pre;
|
||||
if (dotat<c) { // if embedded dot needed...
|
||||
t=c; // target
|
||||
for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap
|
||||
*t='.'; // insert the dot
|
||||
c++; // length increased by one
|
||||
}
|
||||
|
||||
// finally add the E-part, if needed; it will never be 0, and has
|
||||
// a maximum length of 4 digits
|
||||
if (e!=0) {
|
||||
*c++='E'; // starts with E
|
||||
*c++='+'; // assume positive
|
||||
if (e<0) {
|
||||
*(c-1)='-'; // oops, need '-'
|
||||
e=-e; // uInt, please
|
||||
}
|
||||
if (e<1000) { // 3 (or fewer) digits case
|
||||
u=&BIN2CHAR[e*4]; // -> length byte
|
||||
memcpy(c, u+4-*u, 4); // copy fixed 4 characters [is safe]
|
||||
c+=*u; // bump pointer appropriately
|
||||
}
|
||||
else { // 4-digits
|
||||
Int thou=((e>>3)*1049)>>17; // e/1000
|
||||
Int rem=e-(1000*thou); // e%1000
|
||||
*c++='0'+(char)thou;
|
||||
u=&BIN2CHAR[rem*4]; // -> length byte
|
||||
memcpy(c, u+1, 4); // copy fixed 3+1 characters [is safe]
|
||||
c+=3; // bump pointer, always 3 digits
|
||||
}
|
||||
}
|
||||
*c='\0'; // add terminator
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // pre>0
|
||||
|
||||
/* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */
|
||||
t=c+1-pre;
|
||||
*(t+1)='\0'; // can add terminator now
|
||||
for (; s>=cstart; s--, t--) *t=*s; // shift whole coefficient right
|
||||
c=cstart;
|
||||
*c++='0'; // always starts with 0.
|
||||
*c++='.';
|
||||
for (; pre<0; pre++) *c++='0'; // add any 0's after '.'
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // decimal128ToString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-number -- conversion from numeric string */
|
||||
/* */
|
||||
/* decimal128FromString(result, string, set); */
|
||||
/* */
|
||||
/* result is the decimal128 format number which gets the result of */
|
||||
/* the conversion */
|
||||
/* *string is the character string which should contain a valid */
|
||||
/* number (which may be a special value) */
|
||||
/* set is the context */
|
||||
/* */
|
||||
/* The context is supplied to this routine is used for error handling */
|
||||
/* (setting of status and traps) and for the rounding mode, only. */
|
||||
/* If an error occurs, the result will be a valid decimal128 NaN. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal128 * decimal128FromString(decimal128 *result, const char *string,
|
||||
decContext *set) {
|
||||
decContext dc; // work
|
||||
decNumber dn; // ..
|
||||
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL128); // no traps, please
|
||||
dc.round=set->round; // use supplied rounding
|
||||
|
||||
decNumberFromString(&dn, string, &dc); // will round if needed
|
||||
decimal128FromNumber(result, &dn, &dc);
|
||||
if (dc.status!=0) { // something happened
|
||||
decContextSetStatus(set, dc.status); // .. pass it on
|
||||
}
|
||||
return result;
|
||||
} // decimal128FromString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal128IsCanonical -- test whether encoding is canonical */
|
||||
/* d128 is the source decimal128 */
|
||||
/* returns 1 if the encoding of d128 is canonical, 0 otherwise */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decimal128IsCanonical(const decimal128 *d128) {
|
||||
decNumber dn; // work
|
||||
decimal128 canon; // ..
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL128);
|
||||
decimal128ToNumber(d128, &dn);
|
||||
decimal128FromNumber(&canon, &dn, &dc);// canon will now be canonical
|
||||
return memcmp(d128, &canon, DECIMAL128_Bytes)==0;
|
||||
} // decimal128IsCanonical
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal128Canonical -- copy an encoding, ensuring it is canonical */
|
||||
/* d128 is the source decimal128 */
|
||||
/* result is the target (may be the same decimal128) */
|
||||
/* returns result */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) {
|
||||
decNumber dn; // work
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL128);
|
||||
decimal128ToNumber(d128, &dn);
|
||||
decimal128FromNumber(result, &dn, &dc);// result will now be canonical
|
||||
return result;
|
||||
} // decimal128Canonical
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
/* Macros for accessing decimal128 fields. These assume the argument
|
||||
is a reference (pointer) to the decimal128 structure, and the
|
||||
decimal128 is in network byte order (big-endian) */
|
||||
// Get sign
|
||||
#define decimal128Sign(d) ((unsigned)(d)->bytes[0]>>7)
|
||||
|
||||
// Get combination field
|
||||
#define decimal128Comb(d) (((d)->bytes[0] & 0x7c)>>2)
|
||||
|
||||
// Get exponent continuation [does not remove bias]
|
||||
#define decimal128ExpCon(d) ((((d)->bytes[0] & 0x03)<<10) \
|
||||
| ((unsigned)(d)->bytes[1]<<2) \
|
||||
| ((unsigned)(d)->bytes[2]>>6))
|
||||
|
||||
// Set sign [this assumes sign previously 0]
|
||||
#define decimal128SetSign(d, b) { \
|
||||
(d)->bytes[0]|=((unsigned)(b)<<7);}
|
||||
|
||||
// Set exponent continuation [does not apply bias]
|
||||
// This assumes range has been checked and exponent previously 0;
|
||||
// type of exponent must be unsigned
|
||||
#define decimal128SetExpCon(d, e) { \
|
||||
(d)->bytes[0]|=(uByte)((e)>>10); \
|
||||
(d)->bytes[1] =(uByte)(((e)&0x3fc)>>2); \
|
||||
(d)->bytes[2]|=(uByte)(((e)&0x03)<<6);}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal128Show -- display a decimal128 in hexadecimal [debug aid] */
|
||||
/* d128 -- the number to show */
|
||||
/* ------------------------------------------------------------------ */
|
||||
// Also shows sign/cob/expconfields extracted
|
||||
void decimal128Show(const decimal128 *d128) {
|
||||
char buf[DECIMAL128_Bytes*2+1];
|
||||
Int i, j=0;
|
||||
|
||||
if (DECLITEND) {
|
||||
for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d128->bytes[15-i]);
|
||||
}
|
||||
printf(" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
|
||||
d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f,
|
||||
((d128->bytes[15]&0x3)<<10)|(d128->bytes[14]<<2)|
|
||||
(d128->bytes[13]>>6));
|
||||
}
|
||||
else {
|
||||
for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d128->bytes[i]);
|
||||
}
|
||||
printf(" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
|
||||
decimal128Sign(d128), decimal128Comb(d128),
|
||||
decimal128ExpCon(d128));
|
||||
}
|
||||
} // decimal128Show
|
||||
#endif
|
@ -0,0 +1,81 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 128-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2005. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECIMAL128)
|
||||
#define DECIMAL128
|
||||
#define DEC128NAME "decimal128" /* Short name */
|
||||
#define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */
|
||||
#define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
/* parameters for decimal128s */
|
||||
#define DECIMAL128_Bytes 16 /* length */
|
||||
#define DECIMAL128_Pmax 34 /* maximum precision (digits) */
|
||||
#define DECIMAL128_Emax 6144 /* maximum adjusted exponent */
|
||||
#define DECIMAL128_Emin -6143 /* minimum adjusted exponent */
|
||||
#define DECIMAL128_Bias 6176 /* bias for the exponent */
|
||||
#define DECIMAL128_String 43 /* maximum string length, +1 */
|
||||
#define DECIMAL128_EconL 12 /* exp. continuation length */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
|
||||
|
||||
/* check enough digits, if pre-defined */
|
||||
#if defined(DECNUMDIGITS)
|
||||
#if (DECNUMDIGITS<DECIMAL128_Pmax)
|
||||
#error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DECNUMDIGITS
|
||||
#define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/
|
||||
#endif
|
||||
#ifndef DECNUMBER
|
||||
#include "decNumber.h" /* context and number library */
|
||||
#endif
|
||||
|
||||
/* Decimal 128-bit type, accessible by bytes */
|
||||
typedef struct {
|
||||
uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/
|
||||
} decimal128;
|
||||
|
||||
/* special values [top byte excluding sign bit; last two bits are */
|
||||
/* don't-care for Infinity on input, last bit don't-care for NaN] */
|
||||
#if !defined(DECIMAL_NaN)
|
||||
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
|
||||
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
|
||||
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* String conversions */
|
||||
decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
|
||||
char * decimal128ToString(const decimal128 *, char *);
|
||||
char * decimal128ToEngString(const decimal128 *, char *);
|
||||
|
||||
/* decNumber conversions */
|
||||
decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
|
||||
decContext *);
|
||||
decNumber * decimal128ToNumber(const decimal128 *, decNumber *);
|
||||
|
||||
/* Format-dependent utilities */
|
||||
uint32_t decimal128IsCanonical(const decimal128 *);
|
||||
decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);
|
||||
|
||||
#endif
|
@ -0,0 +1,476 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 32-bit format module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises the routines for decimal32 format numbers. */
|
||||
/* Conversions are supplied to and from decNumber and String. */
|
||||
/* */
|
||||
/* This is used when decNumber provides operations, either for all */
|
||||
/* operations or as a proxy between decNumber and decSingle. */
|
||||
/* */
|
||||
/* Error handling is the same as decNumber (qv.). */
|
||||
/* ------------------------------------------------------------------ */
|
||||
#include <string.h> // [for memset/memcpy]
|
||||
#include <stdio.h> // [for printf]
|
||||
|
||||
#define DECNUMDIGITS 7 // make decNumbers with space for 7
|
||||
#include "decNumber.h" // base number library
|
||||
#include "decNumberLocal.h" // decNumber local types, etc.
|
||||
#include "decimal32.h" // our primary include
|
||||
|
||||
/* Utility tables and routines [in decimal64.c] */
|
||||
// DPD2BIN and the reverse are renamed to prevent link-time conflict
|
||||
// if decQuad is also built in the same executable
|
||||
#define DPD2BIN DPD2BINx
|
||||
#define BIN2DPD BIN2DPDx
|
||||
extern const uInt COMBEXP[32], COMBMSD[32];
|
||||
extern const uShort DPD2BIN[1024];
|
||||
extern const uShort BIN2DPD[1000];
|
||||
extern const uByte BIN2CHAR[4001];
|
||||
|
||||
extern void decDigitsToDPD(const decNumber *, uInt *, Int);
|
||||
extern void decDigitsFromDPD(decNumber *, const uInt *, Int);
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
void decimal32Show(const decimal32 *); // for debug
|
||||
extern void decNumberShow(const decNumber *); // ..
|
||||
#endif
|
||||
|
||||
/* Useful macro */
|
||||
// Clear a structure (e.g., a decNumber)
|
||||
#define DEC_clear(d) memset(d, 0, sizeof(*d))
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal32FromNumber -- convert decNumber to decimal32 */
|
||||
/* */
|
||||
/* ds is the target decimal32 */
|
||||
/* dn is the source number (assumed valid) */
|
||||
/* set is the context, used only for reporting errors */
|
||||
/* */
|
||||
/* The set argument is used only for status reporting and for the */
|
||||
/* rounding mode (used if the coefficient is more than DECIMAL32_Pmax */
|
||||
/* digits or an overflow is detected). If the exponent is out of the */
|
||||
/* valid range then Overflow or Underflow will be raised. */
|
||||
/* After Underflow a subnormal result is possible. */
|
||||
/* */
|
||||
/* DEC_Clamped is set if the number has to be 'folded down' to fit, */
|
||||
/* by reducing its exponent and multiplying the coefficient by a */
|
||||
/* power of ten, or if the exponent on a zero had to be clamped. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn,
|
||||
decContext *set) {
|
||||
uInt status=0; // status accumulator
|
||||
Int ae; // adjusted exponent
|
||||
decNumber dw; // work
|
||||
decContext dc; // ..
|
||||
uInt comb, exp; // ..
|
||||
uInt uiwork; // for macros
|
||||
uInt targ=0; // target 32-bit
|
||||
|
||||
// If the number has too many digits, or the exponent could be
|
||||
// out of range then reduce the number under the appropriate
|
||||
// constraints. This could push the number to Infinity or zero,
|
||||
// so this check and rounding must be done before generating the
|
||||
// decimal32]
|
||||
ae=dn->exponent+dn->digits-1; // [0 if special]
|
||||
if (dn->digits>DECIMAL32_Pmax // too many digits
|
||||
|| ae>DECIMAL32_Emax // likely overflow
|
||||
|| ae<DECIMAL32_Emin) { // likely underflow
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL32); // [no traps]
|
||||
dc.round=set->round; // use supplied rounding
|
||||
decNumberPlus(&dw, dn, &dc); // (round and check)
|
||||
// [this changes -0 to 0, so enforce the sign...]
|
||||
dw.bits|=dn->bits&DECNEG;
|
||||
status=dc.status; // save status
|
||||
dn=&dw; // use the work number
|
||||
} // maybe out of range
|
||||
|
||||
if (dn->bits&DECSPECIAL) { // a special value
|
||||
if (dn->bits&DECINF) targ=DECIMAL_Inf<<24;
|
||||
else { // sNaN or qNaN
|
||||
if ((*dn->lsu!=0 || dn->digits>1) // non-zero coefficient
|
||||
&& (dn->digits<DECIMAL32_Pmax)) { // coefficient fits
|
||||
decDigitsToDPD(dn, &targ, 0);
|
||||
}
|
||||
if (dn->bits&DECNAN) targ|=DECIMAL_NaN<<24;
|
||||
else targ|=DECIMAL_sNaN<<24;
|
||||
} // a NaN
|
||||
} // special
|
||||
|
||||
else { // is finite
|
||||
if (decNumberIsZero(dn)) { // is a zero
|
||||
// set and clamp exponent
|
||||
if (dn->exponent<-DECIMAL32_Bias) {
|
||||
exp=0; // low clamp
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
else {
|
||||
exp=dn->exponent+DECIMAL32_Bias; // bias exponent
|
||||
if (exp>DECIMAL32_Ehigh) { // top clamp
|
||||
exp=DECIMAL32_Ehigh;
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
}
|
||||
comb=(exp>>3) & 0x18; // msd=0, exp top 2 bits ..
|
||||
}
|
||||
else { // non-zero finite number
|
||||
uInt msd; // work
|
||||
Int pad=0; // coefficient pad digits
|
||||
|
||||
// the dn is known to fit, but it may need to be padded
|
||||
exp=(uInt)(dn->exponent+DECIMAL32_Bias); // bias exponent
|
||||
if (exp>DECIMAL32_Ehigh) { // fold-down case
|
||||
pad=exp-DECIMAL32_Ehigh;
|
||||
exp=DECIMAL32_Ehigh; // [to maximum]
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
|
||||
// fastpath common case
|
||||
if (DECDPUN==3 && pad==0) {
|
||||
targ=BIN2DPD[dn->lsu[0]];
|
||||
if (dn->digits>3) targ|=(uInt)(BIN2DPD[dn->lsu[1]])<<10;
|
||||
msd=(dn->digits==7 ? dn->lsu[2] : 0);
|
||||
}
|
||||
else { // general case
|
||||
decDigitsToDPD(dn, &targ, pad);
|
||||
// save and clear the top digit
|
||||
msd=targ>>20;
|
||||
targ&=0x000fffff;
|
||||
}
|
||||
|
||||
// create the combination field
|
||||
if (msd>=8) comb=0x18 | ((exp>>5) & 0x06) | (msd & 0x01);
|
||||
else comb=((exp>>3) & 0x18) | msd;
|
||||
}
|
||||
targ|=comb<<26; // add combination field ..
|
||||
targ|=(exp&0x3f)<<20; // .. and exponent continuation
|
||||
} // finite
|
||||
|
||||
if (dn->bits&DECNEG) targ|=0x80000000; // add sign bit
|
||||
|
||||
// now write to storage; this is endian
|
||||
UBFROMUI(d32->bytes, targ); // directly store the int
|
||||
|
||||
if (status!=0) decContextSetStatus(set, status); // pass on status
|
||||
// decimal32Show(d32);
|
||||
return d32;
|
||||
} // decimal32FromNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal32ToNumber -- convert decimal32 to decNumber */
|
||||
/* d32 is the source decimal32 */
|
||||
/* dn is the target number, with appropriate space */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) {
|
||||
uInt msd; // coefficient MSD
|
||||
uInt exp; // exponent top two bits
|
||||
uInt comb; // combination field
|
||||
uInt sour; // source 32-bit
|
||||
uInt uiwork; // for macros
|
||||
|
||||
// load source from storage; this is endian
|
||||
sour=UBTOUI(d32->bytes); // directly load the int
|
||||
|
||||
comb=(sour>>26)&0x1f; // combination field
|
||||
|
||||
decNumberZero(dn); // clean number
|
||||
if (sour&0x80000000) dn->bits=DECNEG; // set sign if negative
|
||||
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) { // is a special
|
||||
if (msd==0) {
|
||||
dn->bits|=DECINF;
|
||||
return dn; // no coefficient needed
|
||||
}
|
||||
else if (sour&0x02000000) dn->bits|=DECSNAN;
|
||||
else dn->bits|=DECNAN;
|
||||
msd=0; // no top digit
|
||||
}
|
||||
else { // is a finite number
|
||||
dn->exponent=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; // unbiased
|
||||
}
|
||||
|
||||
// get the coefficient
|
||||
sour&=0x000fffff; // clean coefficient continuation
|
||||
if (msd) { // non-zero msd
|
||||
sour|=msd<<20; // prefix to coefficient
|
||||
decDigitsFromDPD(dn, &sour, 3); // process 3 declets
|
||||
return dn;
|
||||
}
|
||||
// msd=0
|
||||
if (!sour) return dn; // easy: coefficient is 0
|
||||
if (sour&0x000ffc00) // need 2 declets?
|
||||
decDigitsFromDPD(dn, &sour, 2); // process 2 declets
|
||||
else
|
||||
decDigitsFromDPD(dn, &sour, 1); // process 1 declet
|
||||
return dn;
|
||||
} // decimal32ToNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-scientific-string -- conversion to numeric string */
|
||||
/* to-engineering-string -- conversion to numeric string */
|
||||
/* */
|
||||
/* decimal32ToString(d32, string); */
|
||||
/* decimal32ToEngString(d32, string); */
|
||||
/* */
|
||||
/* d32 is the decimal32 format number to convert */
|
||||
/* string is the string where the result will be laid out */
|
||||
/* */
|
||||
/* string must be at least 24 characters */
|
||||
/* */
|
||||
/* No error is possible, and no status can be set. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
char * decimal32ToEngString(const decimal32 *d32, char *string){
|
||||
decNumber dn; // work
|
||||
decimal32ToNumber(d32, &dn);
|
||||
decNumberToEngString(&dn, string);
|
||||
return string;
|
||||
} // decimal32ToEngString
|
||||
|
||||
char * decimal32ToString(const decimal32 *d32, char *string){
|
||||
uInt msd; // coefficient MSD
|
||||
Int exp; // exponent top two bits or full
|
||||
uInt comb; // combination field
|
||||
char *cstart; // coefficient start
|
||||
char *c; // output pointer in string
|
||||
const uByte *u; // work
|
||||
char *s, *t; // .. (source, target)
|
||||
Int dpd; // ..
|
||||
Int pre, e; // ..
|
||||
uInt uiwork; // for macros
|
||||
uInt sour; // source 32-bit
|
||||
|
||||
// load source from storage; this is endian
|
||||
sour=UBTOUI(d32->bytes); // directly load the int
|
||||
|
||||
c=string; // where result will go
|
||||
if (((Int)sour)<0) *c++='-'; // handle sign
|
||||
|
||||
comb=(sour>>26)&0x1f; // combination field
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) {
|
||||
if (msd==0) { // infinity
|
||||
strcpy(c, "Inf");
|
||||
strcpy(c+3, "inity");
|
||||
return string; // easy
|
||||
}
|
||||
if (sour&0x02000000) *c++='s'; // sNaN
|
||||
strcpy(c, "NaN"); // complete word
|
||||
c+=3; // step past
|
||||
if ((sour&0x000fffff)==0) return string; // zero payload
|
||||
// otherwise drop through to add integer; set correct exp
|
||||
exp=0; msd=0; // setup for following code
|
||||
}
|
||||
else exp=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; // unbiased
|
||||
|
||||
// convert 7 digits of significand to characters
|
||||
cstart=c; // save start of coefficient
|
||||
if (msd) *c++='0'+(char)msd; // non-zero most significant digit
|
||||
|
||||
// Now decode the declets. After extracting each one, it is
|
||||
// decoded to binary and then to a 4-char sequence by table lookup;
|
||||
// the 4-chars are a 1-char length (significant digits, except 000
|
||||
// has length 0). This allows us to left-align the first declet
|
||||
// with non-zero content, then remaining ones are full 3-char
|
||||
// length. We use fixed-length memcpys because variable-length
|
||||
// causes a subroutine call in GCC. (These are length 4 for speed
|
||||
// and are safe because the array has an extra terminator byte.)
|
||||
#define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \
|
||||
if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \
|
||||
else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;}
|
||||
|
||||
dpd=(sour>>10)&0x3ff; // declet 1
|
||||
dpd2char;
|
||||
dpd=(sour)&0x3ff; // declet 2
|
||||
dpd2char;
|
||||
|
||||
if (c==cstart) *c++='0'; // all zeros -- make 0
|
||||
|
||||
if (exp==0) { // integer or NaN case -- easy
|
||||
*c='\0'; // terminate
|
||||
return string;
|
||||
}
|
||||
|
||||
/* non-0 exponent */
|
||||
e=0; // assume no E
|
||||
pre=c-cstart+exp;
|
||||
// [here, pre-exp is the digits count (==1 for zero)]
|
||||
if (exp>0 || pre<-5) { // need exponential form
|
||||
e=pre-1; // calculate E value
|
||||
pre=1; // assume one digit before '.'
|
||||
} // exponential form
|
||||
|
||||
/* modify the coefficient, adding 0s, '.', and E+nn as needed */
|
||||
s=c-1; // source (LSD)
|
||||
if (pre>0) { // ddd.ddd (plain), perhaps with E
|
||||
char *dotat=cstart+pre;
|
||||
if (dotat<c) { // if embedded dot needed...
|
||||
t=c; // target
|
||||
for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap
|
||||
*t='.'; // insert the dot
|
||||
c++; // length increased by one
|
||||
}
|
||||
|
||||
// finally add the E-part, if needed; it will never be 0, and has
|
||||
// a maximum length of 3 digits (E-101 case)
|
||||
if (e!=0) {
|
||||
*c++='E'; // starts with E
|
||||
*c++='+'; // assume positive
|
||||
if (e<0) {
|
||||
*(c-1)='-'; // oops, need '-'
|
||||
e=-e; // uInt, please
|
||||
}
|
||||
u=&BIN2CHAR[e*4]; // -> length byte
|
||||
memcpy(c, u+4-*u, 4); // copy fixed 4 characters [is safe]
|
||||
c+=*u; // bump pointer appropriately
|
||||
}
|
||||
*c='\0'; // add terminator
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // pre>0
|
||||
|
||||
/* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */
|
||||
t=c+1-pre;
|
||||
*(t+1)='\0'; // can add terminator now
|
||||
for (; s>=cstart; s--, t--) *t=*s; // shift whole coefficient right
|
||||
c=cstart;
|
||||
*c++='0'; // always starts with 0.
|
||||
*c++='.';
|
||||
for (; pre<0; pre++) *c++='0'; // add any 0's after '.'
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // decimal32ToString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-number -- conversion from numeric string */
|
||||
/* */
|
||||
/* decimal32FromString(result, string, set); */
|
||||
/* */
|
||||
/* result is the decimal32 format number which gets the result of */
|
||||
/* the conversion */
|
||||
/* *string is the character string which should contain a valid */
|
||||
/* number (which may be a special value) */
|
||||
/* set is the context */
|
||||
/* */
|
||||
/* The context is supplied to this routine is used for error handling */
|
||||
/* (setting of status and traps) and for the rounding mode, only. */
|
||||
/* If an error occurs, the result will be a valid decimal32 NaN. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal32 * decimal32FromString(decimal32 *result, const char *string,
|
||||
decContext *set) {
|
||||
decContext dc; // work
|
||||
decNumber dn; // ..
|
||||
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL32); // no traps, please
|
||||
dc.round=set->round; // use supplied rounding
|
||||
|
||||
decNumberFromString(&dn, string, &dc); // will round if needed
|
||||
decimal32FromNumber(result, &dn, &dc);
|
||||
if (dc.status!=0) { // something happened
|
||||
decContextSetStatus(set, dc.status); // .. pass it on
|
||||
}
|
||||
return result;
|
||||
} // decimal32FromString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal32IsCanonical -- test whether encoding is canonical */
|
||||
/* d32 is the source decimal32 */
|
||||
/* returns 1 if the encoding of d32 is canonical, 0 otherwise */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decimal32IsCanonical(const decimal32 *d32) {
|
||||
decNumber dn; // work
|
||||
decimal32 canon; // ..
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL32);
|
||||
decimal32ToNumber(d32, &dn);
|
||||
decimal32FromNumber(&canon, &dn, &dc);// canon will now be canonical
|
||||
return memcmp(d32, &canon, DECIMAL32_Bytes)==0;
|
||||
} // decimal32IsCanonical
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal32Canonical -- copy an encoding, ensuring it is canonical */
|
||||
/* d32 is the source decimal32 */
|
||||
/* result is the target (may be the same decimal32) */
|
||||
/* returns result */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) {
|
||||
decNumber dn; // work
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL32);
|
||||
decimal32ToNumber(d32, &dn);
|
||||
decimal32FromNumber(result, &dn, &dc);// result will now be canonical
|
||||
return result;
|
||||
} // decimal32Canonical
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
/* Macros for accessing decimal32 fields. These assume the argument
|
||||
is a reference (pointer) to the decimal32 structure, and the
|
||||
decimal32 is in network byte order (big-endian) */
|
||||
// Get sign
|
||||
#define decimal32Sign(d) ((unsigned)(d)->bytes[0]>>7)
|
||||
|
||||
// Get combination field
|
||||
#define decimal32Comb(d) (((d)->bytes[0] & 0x7c)>>2)
|
||||
|
||||
// Get exponent continuation [does not remove bias]
|
||||
#define decimal32ExpCon(d) ((((d)->bytes[0] & 0x03)<<4) \
|
||||
| ((unsigned)(d)->bytes[1]>>4))
|
||||
|
||||
// Set sign [this assumes sign previously 0]
|
||||
#define decimal32SetSign(d, b) { \
|
||||
(d)->bytes[0]|=((unsigned)(b)<<7);}
|
||||
|
||||
// Set exponent continuation [does not apply bias]
|
||||
// This assumes range has been checked and exponent previously 0;
|
||||
// type of exponent must be unsigned
|
||||
#define decimal32SetExpCon(d, e) { \
|
||||
(d)->bytes[0]|=(uByte)((e)>>4); \
|
||||
(d)->bytes[1]|=(uByte)(((e)&0x0F)<<4);}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal32Show -- display a decimal32 in hexadecimal [debug aid] */
|
||||
/* d32 -- the number to show */
|
||||
/* ------------------------------------------------------------------ */
|
||||
// Also shows sign/cob/expconfields extracted - valid bigendian only
|
||||
void decimal32Show(const decimal32 *d32) {
|
||||
char buf[DECIMAL32_Bytes*2+1];
|
||||
Int i, j=0;
|
||||
|
||||
if (DECLITEND) {
|
||||
for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d32->bytes[3-i]);
|
||||
}
|
||||
printf(" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
|
||||
d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f,
|
||||
((d32->bytes[3]&0x3)<<4)| (d32->bytes[2]>>4));
|
||||
}
|
||||
else {
|
||||
for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d32->bytes[i]);
|
||||
}
|
||||
printf(" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
|
||||
decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32));
|
||||
}
|
||||
} // decimal32Show
|
||||
#endif
|
@ -0,0 +1,81 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 32-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2006. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECIMAL32)
|
||||
#define DECIMAL32
|
||||
#define DEC32NAME "decimal32" /* Short name */
|
||||
#define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
|
||||
#define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
/* parameters for decimal32s */
|
||||
#define DECIMAL32_Bytes 4 /* length */
|
||||
#define DECIMAL32_Pmax 7 /* maximum precision (digits) */
|
||||
#define DECIMAL32_Emax 96 /* maximum adjusted exponent */
|
||||
#define DECIMAL32_Emin -95 /* minimum adjusted exponent */
|
||||
#define DECIMAL32_Bias 101 /* bias for the exponent */
|
||||
#define DECIMAL32_String 15 /* maximum string length, +1 */
|
||||
#define DECIMAL32_EconL 6 /* exp. continuation length */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
|
||||
|
||||
/* check enough digits, if pre-defined */
|
||||
#if defined(DECNUMDIGITS)
|
||||
#if (DECNUMDIGITS<DECIMAL32_Pmax)
|
||||
#error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DECNUMDIGITS
|
||||
#define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/
|
||||
#endif
|
||||
#ifndef DECNUMBER
|
||||
#include "decNumber.h" /* context and number library */
|
||||
#endif
|
||||
|
||||
/* Decimal 32-bit type, accessible by bytes */
|
||||
typedef struct {
|
||||
uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/
|
||||
} decimal32;
|
||||
|
||||
/* special values [top byte excluding sign bit; last two bits are */
|
||||
/* don't-care for Infinity on input, last bit don't-care for NaN] */
|
||||
#if !defined(DECIMAL_NaN)
|
||||
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
|
||||
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
|
||||
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* String conversions */
|
||||
decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
|
||||
char * decimal32ToString(const decimal32 *, char *);
|
||||
char * decimal32ToEngString(const decimal32 *, char *);
|
||||
|
||||
/* decNumber conversions */
|
||||
decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,
|
||||
decContext *);
|
||||
decNumber * decimal32ToNumber(const decimal32 *, decNumber *);
|
||||
|
||||
/* Format-dependent utilities */
|
||||
uint32_t decimal32IsCanonical(const decimal32 *);
|
||||
decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);
|
||||
|
||||
#endif
|
@ -0,0 +1,839 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 64-bit format module */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2009. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* This module comprises the routines for decimal64 format numbers. */
|
||||
/* Conversions are supplied to and from decNumber and String. */
|
||||
/* */
|
||||
/* This is used when decNumber provides operations, either for all */
|
||||
/* operations or as a proxy between decNumber and decSingle. */
|
||||
/* */
|
||||
/* Error handling is the same as decNumber (qv.). */
|
||||
/* ------------------------------------------------------------------ */
|
||||
#include <string.h> // [for memset/memcpy]
|
||||
#include <stdio.h> // [for printf]
|
||||
|
||||
#define DECNUMDIGITS 16 // make decNumbers with space for 16
|
||||
#include "decNumber.h" // base number library
|
||||
#include "decNumberLocal.h" // decNumber local types, etc.
|
||||
#include "decimal64.h" // our primary include
|
||||
|
||||
/* Utility routines and tables [in decimal64.c]; externs for C++ */
|
||||
// DPD2BIN and the reverse are renamed to prevent link-time conflict
|
||||
// if decQuad is also built in the same executable
|
||||
#define DPD2BIN DPD2BINx
|
||||
#define BIN2DPD BIN2DPDx
|
||||
extern const uInt COMBEXP[32], COMBMSD[32];
|
||||
extern const uShort DPD2BIN[1024];
|
||||
extern const uShort BIN2DPD[1000];
|
||||
extern const uByte BIN2CHAR[4001];
|
||||
|
||||
extern void decDigitsFromDPD(decNumber *, const uInt *, Int);
|
||||
extern void decDigitsToDPD(const decNumber *, uInt *, Int);
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
void decimal64Show(const decimal64 *); // for debug
|
||||
extern void decNumberShow(const decNumber *); // ..
|
||||
#endif
|
||||
|
||||
/* Useful macro */
|
||||
// Clear a structure (e.g., a decNumber)
|
||||
#define DEC_clear(d) memset(d, 0, sizeof(*d))
|
||||
|
||||
/* define and include the tables to use for conversions */
|
||||
#define DEC_BIN2CHAR 1
|
||||
#define DEC_DPD2BIN 1
|
||||
#define DEC_BIN2DPD 1 // used for all sizes
|
||||
#include "decDPD.h" // lookup tables
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal64FromNumber -- convert decNumber to decimal64 */
|
||||
/* */
|
||||
/* ds is the target decimal64 */
|
||||
/* dn is the source number (assumed valid) */
|
||||
/* set is the context, used only for reporting errors */
|
||||
/* */
|
||||
/* The set argument is used only for status reporting and for the */
|
||||
/* rounding mode (used if the coefficient is more than DECIMAL64_Pmax */
|
||||
/* digits or an overflow is detected). If the exponent is out of the */
|
||||
/* valid range then Overflow or Underflow will be raised. */
|
||||
/* After Underflow a subnormal result is possible. */
|
||||
/* */
|
||||
/* DEC_Clamped is set if the number has to be 'folded down' to fit, */
|
||||
/* by reducing its exponent and multiplying the coefficient by a */
|
||||
/* power of ten, or if the exponent on a zero had to be clamped. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn,
|
||||
decContext *set) {
|
||||
uInt status=0; // status accumulator
|
||||
Int ae; // adjusted exponent
|
||||
decNumber dw; // work
|
||||
decContext dc; // ..
|
||||
uInt comb, exp; // ..
|
||||
uInt uiwork; // for macros
|
||||
uInt targar[2]={0, 0}; // target 64-bit
|
||||
#define targhi targar[1] // name the word with the sign
|
||||
#define targlo targar[0] // and the other
|
||||
|
||||
// If the number has too many digits, or the exponent could be
|
||||
// out of range then reduce the number under the appropriate
|
||||
// constraints. This could push the number to Infinity or zero,
|
||||
// so this check and rounding must be done before generating the
|
||||
// decimal64]
|
||||
ae=dn->exponent+dn->digits-1; // [0 if special]
|
||||
if (dn->digits>DECIMAL64_Pmax // too many digits
|
||||
|| ae>DECIMAL64_Emax // likely overflow
|
||||
|| ae<DECIMAL64_Emin) { // likely underflow
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL64); // [no traps]
|
||||
dc.round=set->round; // use supplied rounding
|
||||
decNumberPlus(&dw, dn, &dc); // (round and check)
|
||||
// [this changes -0 to 0, so enforce the sign...]
|
||||
dw.bits|=dn->bits&DECNEG;
|
||||
status=dc.status; // save status
|
||||
dn=&dw; // use the work number
|
||||
} // maybe out of range
|
||||
|
||||
if (dn->bits&DECSPECIAL) { // a special value
|
||||
if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24;
|
||||
else { // sNaN or qNaN
|
||||
if ((*dn->lsu!=0 || dn->digits>1) // non-zero coefficient
|
||||
&& (dn->digits<DECIMAL64_Pmax)) { // coefficient fits
|
||||
decDigitsToDPD(dn, targar, 0);
|
||||
}
|
||||
if (dn->bits&DECNAN) targhi|=DECIMAL_NaN<<24;
|
||||
else targhi|=DECIMAL_sNaN<<24;
|
||||
} // a NaN
|
||||
} // special
|
||||
|
||||
else { // is finite
|
||||
if (decNumberIsZero(dn)) { // is a zero
|
||||
// set and clamp exponent
|
||||
if (dn->exponent<-DECIMAL64_Bias) {
|
||||
exp=0; // low clamp
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
else {
|
||||
exp=dn->exponent+DECIMAL64_Bias; // bias exponent
|
||||
if (exp>DECIMAL64_Ehigh) { // top clamp
|
||||
exp=DECIMAL64_Ehigh;
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
}
|
||||
comb=(exp>>5) & 0x18; // msd=0, exp top 2 bits ..
|
||||
}
|
||||
else { // non-zero finite number
|
||||
uInt msd; // work
|
||||
Int pad=0; // coefficient pad digits
|
||||
|
||||
// the dn is known to fit, but it may need to be padded
|
||||
exp=(uInt)(dn->exponent+DECIMAL64_Bias); // bias exponent
|
||||
if (exp>DECIMAL64_Ehigh) { // fold-down case
|
||||
pad=exp-DECIMAL64_Ehigh;
|
||||
exp=DECIMAL64_Ehigh; // [to maximum]
|
||||
status|=DEC_Clamped;
|
||||
}
|
||||
|
||||
// fastpath common case
|
||||
if (DECDPUN==3 && pad==0) {
|
||||
uInt dpd[6]={0,0,0,0,0,0};
|
||||
uInt i;
|
||||
Int d=dn->digits;
|
||||
for (i=0; d>0; i++, d-=3) dpd[i]=BIN2DPD[dn->lsu[i]];
|
||||
targlo =dpd[0];
|
||||
targlo|=dpd[1]<<10;
|
||||
targlo|=dpd[2]<<20;
|
||||
if (dn->digits>6) {
|
||||
targlo|=dpd[3]<<30;
|
||||
targhi =dpd[3]>>2;
|
||||
targhi|=dpd[4]<<8;
|
||||
}
|
||||
msd=dpd[5]; // [did not really need conversion]
|
||||
}
|
||||
else { // general case
|
||||
decDigitsToDPD(dn, targar, pad);
|
||||
// save and clear the top digit
|
||||
msd=targhi>>18;
|
||||
targhi&=0x0003ffff;
|
||||
}
|
||||
|
||||
// create the combination field
|
||||
if (msd>=8) comb=0x18 | ((exp>>7) & 0x06) | (msd & 0x01);
|
||||
else comb=((exp>>5) & 0x18) | msd;
|
||||
}
|
||||
targhi|=comb<<26; // add combination field ..
|
||||
targhi|=(exp&0xff)<<18; // .. and exponent continuation
|
||||
} // finite
|
||||
|
||||
if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit
|
||||
|
||||
// now write to storage; this is now always endian
|
||||
if (DECLITEND) {
|
||||
// lo int then hi
|
||||
UBFROMUI(d64->bytes, targar[0]);
|
||||
UBFROMUI(d64->bytes+4, targar[1]);
|
||||
}
|
||||
else {
|
||||
// hi int then lo
|
||||
UBFROMUI(d64->bytes, targar[1]);
|
||||
UBFROMUI(d64->bytes+4, targar[0]);
|
||||
}
|
||||
|
||||
if (status!=0) decContextSetStatus(set, status); // pass on status
|
||||
// decimal64Show(d64);
|
||||
return d64;
|
||||
} // decimal64FromNumber
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal64ToNumber -- convert decimal64 to decNumber */
|
||||
/* d64 is the source decimal64 */
|
||||
/* dn is the target number, with appropriate space */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) {
|
||||
uInt msd; // coefficient MSD
|
||||
uInt exp; // exponent top two bits
|
||||
uInt comb; // combination field
|
||||
Int need; // work
|
||||
uInt uiwork; // for macros
|
||||
uInt sourar[2]; // source 64-bit
|
||||
#define sourhi sourar[1] // name the word with the sign
|
||||
#define sourlo sourar[0] // and the lower word
|
||||
|
||||
// load source from storage; this is endian
|
||||
if (DECLITEND) {
|
||||
sourlo=UBTOUI(d64->bytes ); // directly load the low int
|
||||
sourhi=UBTOUI(d64->bytes+4); // then the high int
|
||||
}
|
||||
else {
|
||||
sourhi=UBTOUI(d64->bytes ); // directly load the high int
|
||||
sourlo=UBTOUI(d64->bytes+4); // then the low int
|
||||
}
|
||||
|
||||
comb=(sourhi>>26)&0x1f; // combination field
|
||||
|
||||
decNumberZero(dn); // clean number
|
||||
if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative
|
||||
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) { // is a special
|
||||
if (msd==0) {
|
||||
dn->bits|=DECINF;
|
||||
return dn; // no coefficient needed
|
||||
}
|
||||
else if (sourhi&0x02000000) dn->bits|=DECSNAN;
|
||||
else dn->bits|=DECNAN;
|
||||
msd=0; // no top digit
|
||||
}
|
||||
else { // is a finite number
|
||||
dn->exponent=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias; // unbiased
|
||||
}
|
||||
|
||||
// get the coefficient
|
||||
sourhi&=0x0003ffff; // clean coefficient continuation
|
||||
if (msd) { // non-zero msd
|
||||
sourhi|=msd<<18; // prefix to coefficient
|
||||
need=6; // process 6 declets
|
||||
}
|
||||
else { // msd=0
|
||||
if (!sourhi) { // top word 0
|
||||
if (!sourlo) return dn; // easy: coefficient is 0
|
||||
need=3; // process at least 3 declets
|
||||
if (sourlo&0xc0000000) need++; // process 4 declets
|
||||
// [could reduce some more, here]
|
||||
}
|
||||
else { // some bits in top word, msd=0
|
||||
need=4; // process at least 4 declets
|
||||
if (sourhi&0x0003ff00) need++; // top declet!=0, process 5
|
||||
}
|
||||
} //msd=0
|
||||
|
||||
decDigitsFromDPD(dn, sourar, need); // process declets
|
||||
return dn;
|
||||
} // decimal64ToNumber
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-scientific-string -- conversion to numeric string */
|
||||
/* to-engineering-string -- conversion to numeric string */
|
||||
/* */
|
||||
/* decimal64ToString(d64, string); */
|
||||
/* decimal64ToEngString(d64, string); */
|
||||
/* */
|
||||
/* d64 is the decimal64 format number to convert */
|
||||
/* string is the string where the result will be laid out */
|
||||
/* */
|
||||
/* string must be at least 24 characters */
|
||||
/* */
|
||||
/* No error is possible, and no status can be set. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
char * decimal64ToEngString(const decimal64 *d64, char *string){
|
||||
decNumber dn; // work
|
||||
decimal64ToNumber(d64, &dn);
|
||||
decNumberToEngString(&dn, string);
|
||||
return string;
|
||||
} // decimal64ToEngString
|
||||
|
||||
char * decimal64ToString(const decimal64 *d64, char *string){
|
||||
uInt msd; // coefficient MSD
|
||||
Int exp; // exponent top two bits or full
|
||||
uInt comb; // combination field
|
||||
char *cstart; // coefficient start
|
||||
char *c; // output pointer in string
|
||||
const uByte *u; // work
|
||||
char *s, *t; // .. (source, target)
|
||||
Int dpd; // ..
|
||||
Int pre, e; // ..
|
||||
uInt uiwork; // for macros
|
||||
|
||||
uInt sourar[2]; // source 64-bit
|
||||
#define sourhi sourar[1] // name the word with the sign
|
||||
#define sourlo sourar[0] // and the lower word
|
||||
|
||||
// load source from storage; this is endian
|
||||
if (DECLITEND) {
|
||||
sourlo=UBTOUI(d64->bytes ); // directly load the low int
|
||||
sourhi=UBTOUI(d64->bytes+4); // then the high int
|
||||
}
|
||||
else {
|
||||
sourhi=UBTOUI(d64->bytes ); // directly load the high int
|
||||
sourlo=UBTOUI(d64->bytes+4); // then the low int
|
||||
}
|
||||
|
||||
c=string; // where result will go
|
||||
if (((Int)sourhi)<0) *c++='-'; // handle sign
|
||||
|
||||
comb=(sourhi>>26)&0x1f; // combination field
|
||||
msd=COMBMSD[comb]; // decode the combination field
|
||||
exp=COMBEXP[comb]; // ..
|
||||
|
||||
if (exp==3) {
|
||||
if (msd==0) { // infinity
|
||||
strcpy(c, "Inf");
|
||||
strcpy(c+3, "inity");
|
||||
return string; // easy
|
||||
}
|
||||
if (sourhi&0x02000000) *c++='s'; // sNaN
|
||||
strcpy(c, "NaN"); // complete word
|
||||
c+=3; // step past
|
||||
if (sourlo==0 && (sourhi&0x0003ffff)==0) return string; // zero payload
|
||||
// otherwise drop through to add integer; set correct exp
|
||||
exp=0; msd=0; // setup for following code
|
||||
}
|
||||
else exp=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias;
|
||||
|
||||
// convert 16 digits of significand to characters
|
||||
cstart=c; // save start of coefficient
|
||||
if (msd) *c++='0'+(char)msd; // non-zero most significant digit
|
||||
|
||||
// Now decode the declets. After extracting each one, it is
|
||||
// decoded to binary and then to a 4-char sequence by table lookup;
|
||||
// the 4-chars are a 1-char length (significant digits, except 000
|
||||
// has length 0). This allows us to left-align the first declet
|
||||
// with non-zero content, then remaining ones are full 3-char
|
||||
// length. We use fixed-length memcpys because variable-length
|
||||
// causes a subroutine call in GCC. (These are length 4 for speed
|
||||
// and are safe because the array has an extra terminator byte.)
|
||||
#define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \
|
||||
if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \
|
||||
else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;}
|
||||
|
||||
dpd=(sourhi>>8)&0x3ff; // declet 1
|
||||
dpd2char;
|
||||
dpd=((sourhi&0xff)<<2) | (sourlo>>30); // declet 2
|
||||
dpd2char;
|
||||
dpd=(sourlo>>20)&0x3ff; // declet 3
|
||||
dpd2char;
|
||||
dpd=(sourlo>>10)&0x3ff; // declet 4
|
||||
dpd2char;
|
||||
dpd=(sourlo)&0x3ff; // declet 5
|
||||
dpd2char;
|
||||
|
||||
if (c==cstart) *c++='0'; // all zeros -- make 0
|
||||
|
||||
if (exp==0) { // integer or NaN case -- easy
|
||||
*c='\0'; // terminate
|
||||
return string;
|
||||
}
|
||||
|
||||
/* non-0 exponent */
|
||||
e=0; // assume no E
|
||||
pre=c-cstart+exp;
|
||||
// [here, pre-exp is the digits count (==1 for zero)]
|
||||
if (exp>0 || pre<-5) { // need exponential form
|
||||
e=pre-1; // calculate E value
|
||||
pre=1; // assume one digit before '.'
|
||||
} // exponential form
|
||||
|
||||
/* modify the coefficient, adding 0s, '.', and E+nn as needed */
|
||||
s=c-1; // source (LSD)
|
||||
if (pre>0) { // ddd.ddd (plain), perhaps with E
|
||||
char *dotat=cstart+pre;
|
||||
if (dotat<c) { // if embedded dot needed...
|
||||
t=c; // target
|
||||
for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap
|
||||
*t='.'; // insert the dot
|
||||
c++; // length increased by one
|
||||
}
|
||||
|
||||
// finally add the E-part, if needed; it will never be 0, and has
|
||||
// a maximum length of 3 digits
|
||||
if (e!=0) {
|
||||
*c++='E'; // starts with E
|
||||
*c++='+'; // assume positive
|
||||
if (e<0) {
|
||||
*(c-1)='-'; // oops, need '-'
|
||||
e=-e; // uInt, please
|
||||
}
|
||||
u=&BIN2CHAR[e*4]; // -> length byte
|
||||
memcpy(c, u+4-*u, 4); // copy fixed 4 characters [is safe]
|
||||
c+=*u; // bump pointer appropriately
|
||||
}
|
||||
*c='\0'; // add terminator
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // pre>0
|
||||
|
||||
/* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */
|
||||
t=c+1-pre;
|
||||
*(t+1)='\0'; // can add terminator now
|
||||
for (; s>=cstart; s--, t--) *t=*s; // shift whole coefficient right
|
||||
c=cstart;
|
||||
*c++='0'; // always starts with 0.
|
||||
*c++='.';
|
||||
for (; pre<0; pre++) *c++='0'; // add any 0's after '.'
|
||||
//printf("res %s\n", string);
|
||||
return string;
|
||||
} // decimal64ToString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* to-number -- conversion from numeric string */
|
||||
/* */
|
||||
/* decimal64FromString(result, string, set); */
|
||||
/* */
|
||||
/* result is the decimal64 format number which gets the result of */
|
||||
/* the conversion */
|
||||
/* *string is the character string which should contain a valid */
|
||||
/* number (which may be a special value) */
|
||||
/* set is the context */
|
||||
/* */
|
||||
/* The context is supplied to this routine is used for error handling */
|
||||
/* (setting of status and traps) and for the rounding mode, only. */
|
||||
/* If an error occurs, the result will be a valid decimal64 NaN. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal64 * decimal64FromString(decimal64 *result, const char *string,
|
||||
decContext *set) {
|
||||
decContext dc; // work
|
||||
decNumber dn; // ..
|
||||
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL64); // no traps, please
|
||||
dc.round=set->round; // use supplied rounding
|
||||
|
||||
decNumberFromString(&dn, string, &dc); // will round if needed
|
||||
|
||||
decimal64FromNumber(result, &dn, &dc);
|
||||
if (dc.status!=0) { // something happened
|
||||
decContextSetStatus(set, dc.status); // .. pass it on
|
||||
}
|
||||
return result;
|
||||
} // decimal64FromString
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal64IsCanonical -- test whether encoding is canonical */
|
||||
/* d64 is the source decimal64 */
|
||||
/* returns 1 if the encoding of d64 is canonical, 0 otherwise */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
uInt decimal64IsCanonical(const decimal64 *d64) {
|
||||
decNumber dn; // work
|
||||
decimal64 canon; // ..
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL64);
|
||||
decimal64ToNumber(d64, &dn);
|
||||
decimal64FromNumber(&canon, &dn, &dc);// canon will now be canonical
|
||||
return memcmp(d64, &canon, DECIMAL64_Bytes)==0;
|
||||
} // decimal64IsCanonical
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal64Canonical -- copy an encoding, ensuring it is canonical */
|
||||
/* d64 is the source decimal64 */
|
||||
/* result is the target (may be the same decimal64) */
|
||||
/* returns result */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
decimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) {
|
||||
decNumber dn; // work
|
||||
decContext dc; // ..
|
||||
decContextDefault(&dc, DEC_INIT_DECIMAL64);
|
||||
decimal64ToNumber(d64, &dn);
|
||||
decimal64FromNumber(result, &dn, &dc);// result will now be canonical
|
||||
return result;
|
||||
} // decimal64Canonical
|
||||
|
||||
#if DECTRACE || DECCHECK
|
||||
/* Macros for accessing decimal64 fields. These assume the
|
||||
argument is a reference (pointer) to the decimal64 structure,
|
||||
and the decimal64 is in network byte order (big-endian) */
|
||||
// Get sign
|
||||
#define decimal64Sign(d) ((unsigned)(d)->bytes[0]>>7)
|
||||
|
||||
// Get combination field
|
||||
#define decimal64Comb(d) (((d)->bytes[0] & 0x7c)>>2)
|
||||
|
||||
// Get exponent continuation [does not remove bias]
|
||||
#define decimal64ExpCon(d) ((((d)->bytes[0] & 0x03)<<6) \
|
||||
| ((unsigned)(d)->bytes[1]>>2))
|
||||
|
||||
// Set sign [this assumes sign previously 0]
|
||||
#define decimal64SetSign(d, b) { \
|
||||
(d)->bytes[0]|=((unsigned)(b)<<7);}
|
||||
|
||||
// Set exponent continuation [does not apply bias]
|
||||
// This assumes range has been checked and exponent previously 0;
|
||||
// type of exponent must be unsigned
|
||||
#define decimal64SetExpCon(d, e) { \
|
||||
(d)->bytes[0]|=(uByte)((e)>>6); \
|
||||
(d)->bytes[1]|=(uByte)(((e)&0x3F)<<2);}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decimal64Show -- display a decimal64 in hexadecimal [debug aid] */
|
||||
/* d64 -- the number to show */
|
||||
/* ------------------------------------------------------------------ */
|
||||
// Also shows sign/cob/expconfields extracted
|
||||
void decimal64Show(const decimal64 *d64) {
|
||||
char buf[DECIMAL64_Bytes*2+1];
|
||||
Int i, j=0;
|
||||
|
||||
if (DECLITEND) {
|
||||
for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d64->bytes[7-i]);
|
||||
}
|
||||
printf(" D64> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
|
||||
d64->bytes[7]>>7, (d64->bytes[7]>>2)&0x1f,
|
||||
((d64->bytes[7]&0x3)<<6)| (d64->bytes[6]>>2));
|
||||
}
|
||||
else { // big-endian
|
||||
for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
|
||||
sprintf(&buf[j], "%02x", d64->bytes[i]);
|
||||
}
|
||||
printf(" D64> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
|
||||
decimal64Sign(d64), decimal64Comb(d64), decimal64ExpCon(d64));
|
||||
}
|
||||
} // decimal64Show
|
||||
#endif
|
||||
|
||||
/* ================================================================== */
|
||||
/* Shared utility routines and tables */
|
||||
/* ================================================================== */
|
||||
// define and include the conversion tables to use for shared code
|
||||
#if DECDPUN==3
|
||||
#define DEC_DPD2BIN 1
|
||||
#else
|
||||
#define DEC_DPD2BCD 1
|
||||
#endif
|
||||
#include "decDPD.h" // lookup tables
|
||||
|
||||
// The maximum number of decNumberUnits needed for a working copy of
|
||||
// the units array is the ceiling of digits/DECDPUN, where digits is
|
||||
// the maximum number of digits in any of the formats for which this
|
||||
// is used. decimal128.h must not be included in this module, so, as
|
||||
// a very special case, that number is defined as a literal here.
|
||||
#define DECMAX754 34
|
||||
#define DECMAXUNITS ((DECMAX754+DECDPUN-1)/DECDPUN)
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Combination field lookup tables (uInts to save measurable work) */
|
||||
/* */
|
||||
/* COMBEXP - 2-bit most-significant-bits of exponent */
|
||||
/* [11 if an Infinity or NaN] */
|
||||
/* COMBMSD - 4-bit most-significant-digit */
|
||||
/* [0=Infinity, 1=NaN if COMBEXP=11] */
|
||||
/* */
|
||||
/* Both are indexed by the 5-bit combination field (0-31) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
const uInt COMBEXP[32]={0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2,
|
||||
0, 0, 1, 1, 2, 2, 3, 3};
|
||||
const uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7,
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 8, 9, 8, 9, 0, 1};
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decDigitsToDPD -- pack coefficient into DPD form */
|
||||
/* */
|
||||
/* dn is the source number (assumed valid, max DECMAX754 digits) */
|
||||
/* targ is 1, 2, or 4-element uInt array, which the caller must */
|
||||
/* have cleared to zeros */
|
||||
/* shift is the number of 0 digits to add on the right (normally 0) */
|
||||
/* */
|
||||
/* The coefficient must be known small enough to fit. The full */
|
||||
/* coefficient is copied, including the leading 'odd' digit. This */
|
||||
/* digit is retrieved and packed into the combination field by the */
|
||||
/* caller. */
|
||||
/* */
|
||||
/* The target uInts are altered only as necessary to receive the */
|
||||
/* digits of the decNumber. When more than one uInt is needed, they */
|
||||
/* are filled from left to right (that is, the uInt at offset 0 will */
|
||||
/* end up with the least-significant digits). */
|
||||
/* */
|
||||
/* shift is used for 'fold-down' padding. */
|
||||
/* */
|
||||
/* No error is possible. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
#if DECDPUN<=4
|
||||
// Constant multipliers for divide-by-power-of five using reciprocal
|
||||
// multiply, after removing powers of 2 by shifting, and final shift
|
||||
// of 17 [we only need up to **4]
|
||||
static const uInt multies[]={131073, 26215, 5243, 1049, 210};
|
||||
// QUOT10 -- macro to return the quotient of unit u divided by 10**n
|
||||
#define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
|
||||
#endif
|
||||
void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
|
||||
Int cut; // work
|
||||
Int n; // output bunch counter
|
||||
Int digits=dn->digits; // digit countdown
|
||||
uInt dpd; // densely packed decimal value
|
||||
uInt bin; // binary value 0-999
|
||||
uInt *uout=targ; // -> current output uInt
|
||||
uInt uoff=0; // -> current output offset [from right]
|
||||
const Unit *inu=dn->lsu; // -> current input unit
|
||||
Unit uar[DECMAXUNITS]; // working copy of units, iff shifted
|
||||
#if DECDPUN!=3 // not fast path
|
||||
Unit in; // current unit
|
||||
#endif
|
||||
|
||||
if (shift!=0) { // shift towards most significant required
|
||||
// shift the units array to the left by pad digits and copy
|
||||
// [this code is a special case of decShiftToMost, which could
|
||||
// be used instead if exposed and the array were copied first]
|
||||
const Unit *source; // ..
|
||||
Unit *target, *first; // ..
|
||||
uInt next=0; // work
|
||||
|
||||
source=dn->lsu+D2U(digits)-1; // where msu comes from
|
||||
target=uar+D2U(digits)-1+D2U(shift);// where upper part of first cut goes
|
||||
cut=DECDPUN-MSUDIGITS(shift); // where to slice
|
||||
if (cut==0) { // unit-boundary case
|
||||
for (; source>=dn->lsu; source--, target--) *target=*source;
|
||||
}
|
||||
else {
|
||||
first=uar+D2U(digits+shift)-1; // where msu will end up
|
||||
for (; source>=dn->lsu; source--, target--) {
|
||||
// split the source Unit and accumulate remainder for next
|
||||
#if DECDPUN<=4
|
||||
uInt quot=QUOT10(*source, cut);
|
||||
uInt rem=*source-quot*DECPOWERS[cut];
|
||||
next+=quot;
|
||||
#else
|
||||
uInt rem=*source%DECPOWERS[cut];
|
||||
next+=*source/DECPOWERS[cut];
|
||||
#endif
|
||||
if (target<=first) *target=(Unit)next; // write to target iff valid
|
||||
next=rem*DECPOWERS[DECDPUN-cut]; // save remainder for next Unit
|
||||
}
|
||||
} // shift-move
|
||||
// propagate remainder to one below and clear the rest
|
||||
for (; target>=uar; target--) {
|
||||
*target=(Unit)next;
|
||||
next=0;
|
||||
}
|
||||
digits+=shift; // add count (shift) of zeros added
|
||||
inu=uar; // use units in working array
|
||||
}
|
||||
|
||||
/* now densely pack the coefficient into DPD declets */
|
||||
|
||||
#if DECDPUN!=3 // not fast path
|
||||
in=*inu; // current unit
|
||||
cut=0; // at lowest digit
|
||||
bin=0; // [keep compiler quiet]
|
||||
#endif
|
||||
|
||||
for(n=0; digits>0; n++) { // each output bunch
|
||||
#if DECDPUN==3 // fast path, 3-at-a-time
|
||||
bin=*inu; // 3 digits ready for convert
|
||||
digits-=3; // [may go negative]
|
||||
inu++; // may need another
|
||||
|
||||
#else // must collect digit-by-digit
|
||||
Unit dig; // current digit
|
||||
Int j; // digit-in-declet count
|
||||
for (j=0; j<3; j++) {
|
||||
#if DECDPUN<=4
|
||||
Unit temp=(Unit)((uInt)(in*6554)>>16);
|
||||
dig=(Unit)(in-X10(temp));
|
||||
in=temp;
|
||||
#else
|
||||
dig=in%10;
|
||||
in=in/10;
|
||||
#endif
|
||||
if (j==0) bin=dig;
|
||||
else if (j==1) bin+=X10(dig);
|
||||
else /* j==2 */ bin+=X100(dig);
|
||||
digits--;
|
||||
if (digits==0) break; // [also protects *inu below]
|
||||
cut++;
|
||||
if (cut==DECDPUN) {inu++; in=*inu; cut=0;}
|
||||
}
|
||||
#endif
|
||||
// here there are 3 digits in bin, or have used all input digits
|
||||
|
||||
dpd=BIN2DPD[bin];
|
||||
|
||||
// write declet to uInt array
|
||||
*uout|=dpd<<uoff;
|
||||
uoff+=10;
|
||||
if (uoff<32) continue; // no uInt boundary cross
|
||||
uout++;
|
||||
uoff-=32;
|
||||
*uout|=dpd>>(10-uoff); // collect top bits
|
||||
} // n declets
|
||||
return;
|
||||
} // decDigitsToDPD
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* decDigitsFromDPD -- unpack a format's coefficient */
|
||||
/* */
|
||||
/* dn is the target number, with 7, 16, or 34-digit space. */
|
||||
/* sour is a 1, 2, or 4-element uInt array containing only declets */
|
||||
/* declets is the number of (right-aligned) declets in sour to */
|
||||
/* be processed. This may be 1 more than the obvious number in */
|
||||
/* a format, as any top digit is prefixed to the coefficient */
|
||||
/* continuation field. It also may be as small as 1, as the */
|
||||
/* caller may pre-process leading zero declets. */
|
||||
/* */
|
||||
/* When doing the 'extra declet' case care is taken to avoid writing */
|
||||
/* extra digits when there are leading zeros, as these could overflow */
|
||||
/* the units array when DECDPUN is not 3. */
|
||||
/* */
|
||||
/* The target uInts are used only as necessary to process declets */
|
||||
/* declets into the decNumber. When more than one uInt is needed, */
|
||||
/* they are used from left to right (that is, the uInt at offset 0 */
|
||||
/* provides the least-significant digits). */
|
||||
/* */
|
||||
/* dn->digits is set, but not the sign or exponent. */
|
||||
/* No error is possible [the redundant 888 codes are allowed]. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) {
|
||||
|
||||
uInt dpd; // collector for 10 bits
|
||||
Int n; // counter
|
||||
Unit *uout=dn->lsu; // -> current output unit
|
||||
Unit *last=uout; // will be unit containing msd
|
||||
const uInt *uin=sour; // -> current input uInt
|
||||
uInt uoff=0; // -> current input offset [from right]
|
||||
|
||||
#if DECDPUN!=3
|
||||
uInt bcd; // BCD result
|
||||
uInt nibble; // work
|
||||
Unit out=0; // accumulator
|
||||
Int cut=0; // power of ten in current unit
|
||||
#endif
|
||||
#if DECDPUN>4
|
||||
uInt const *pow; // work
|
||||
#endif
|
||||
|
||||
// Expand the densely-packed integer, right to left
|
||||
for (n=declets-1; n>=0; n--) { // count down declets of 10 bits
|
||||
dpd=*uin>>uoff;
|
||||
uoff+=10;
|
||||
if (uoff>32) { // crossed uInt boundary
|
||||
uin++;
|
||||
uoff-=32; // [if using this code for wider, check this]
|
||||
dpd|=*uin<<(10-uoff); // get waiting bits
|
||||
}
|
||||
dpd&=0x3ff; // clear uninteresting bits
|
||||
|
||||
#if DECDPUN==3
|
||||
if (dpd==0) *uout=0;
|
||||
else {
|
||||
*uout=DPD2BIN[dpd]; // convert 10 bits to binary 0-999
|
||||
last=uout; // record most significant unit
|
||||
}
|
||||
uout++;
|
||||
} // n
|
||||
|
||||
#else // DECDPUN!=3
|
||||
if (dpd==0) { // fastpath [e.g., leading zeros]
|
||||
// write out three 0 digits (nibbles); out may have digit(s)
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
if (n==0) break; // [as below, works even if MSD=0]
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
continue;
|
||||
}
|
||||
|
||||
bcd=DPD2BCD[dpd]; // convert 10 bits to 12 bits BCD
|
||||
|
||||
// now accumulate the 3 BCD nibbles into units
|
||||
nibble=bcd & 0x00f;
|
||||
if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
bcd>>=4;
|
||||
|
||||
// if this is the last declet and the remaining nibbles in bcd
|
||||
// are 00 then process no more nibbles, because this could be
|
||||
// the 'odd' MSD declet and writing any more Units would then
|
||||
// overflow the unit array
|
||||
if (n==0 && !bcd) break;
|
||||
|
||||
nibble=bcd & 0x00f;
|
||||
if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
bcd>>=4;
|
||||
|
||||
nibble=bcd & 0x00f;
|
||||
if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);
|
||||
cut++;
|
||||
if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}
|
||||
} // n
|
||||
if (cut!=0) { // some more left over
|
||||
*uout=out; // write out final unit
|
||||
if (out) last=uout; // and note if non-zero
|
||||
}
|
||||
#endif
|
||||
|
||||
// here, last points to the most significant unit with digits;
|
||||
// inspect it to get the final digits count -- this is essentially
|
||||
// the same code as decGetDigits in decNumber.c
|
||||
dn->digits=(last-dn->lsu)*DECDPUN+1; // floor of digits, plus
|
||||
// must be at least 1 digit
|
||||
#if DECDPUN>1
|
||||
if (*last<10) return; // common odd digit or 0
|
||||
dn->digits++; // must be 2 at least
|
||||
#if DECDPUN>2
|
||||
if (*last<100) return; // 10-99
|
||||
dn->digits++; // must be 3 at least
|
||||
#if DECDPUN>3
|
||||
if (*last<1000) return; // 100-999
|
||||
dn->digits++; // must be 4 at least
|
||||
#if DECDPUN>4
|
||||
for (pow=&DECPOWERS[4]; *last>=*pow; pow++) dn->digits++;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
} //decDigitsFromDPD
|
@ -0,0 +1,83 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Decimal 64-bit format module header */
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Copyright (c) IBM Corporation, 2000, 2005. All rights reserved. */
|
||||
/* */
|
||||
/* This software is made available under the terms of the */
|
||||
/* ICU License -- ICU 1.8.1 and later. */
|
||||
/* */
|
||||
/* The description and User's Guide ("The decNumber C Library") for */
|
||||
/* this software is called decNumber.pdf. This document is */
|
||||
/* available, together with arithmetic and format specifications, */
|
||||
/* testcases, and Web links, on the General Decimal Arithmetic page. */
|
||||
/* */
|
||||
/* Please send comments, suggestions, and corrections to the author: */
|
||||
/* mfc@uk.ibm.com */
|
||||
/* Mike Cowlishaw, IBM Fellow */
|
||||
/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#if !defined(DECIMAL64)
|
||||
#define DECIMAL64
|
||||
#define DEC64NAME "decimal64" /* Short name */
|
||||
#define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */
|
||||
#define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */
|
||||
|
||||
|
||||
/* parameters for decimal64s */
|
||||
#define DECIMAL64_Bytes 8 /* length */
|
||||
#define DECIMAL64_Pmax 16 /* maximum precision (digits) */
|
||||
#define DECIMAL64_Emax 384 /* maximum adjusted exponent */
|
||||
#define DECIMAL64_Emin -383 /* minimum adjusted exponent */
|
||||
#define DECIMAL64_Bias 398 /* bias for the exponent */
|
||||
#define DECIMAL64_String 24 /* maximum string length, +1 */
|
||||
#define DECIMAL64_EconL 8 /* exp. continuation length */
|
||||
/* highest biased exponent (Elimit-1) */
|
||||
#define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
|
||||
|
||||
/* check enough digits, if pre-defined */
|
||||
#if defined(DECNUMDIGITS)
|
||||
#if (DECNUMDIGITS<DECIMAL64_Pmax)
|
||||
#error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DECNUMDIGITS
|
||||
#define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/
|
||||
#endif
|
||||
#ifndef DECNUMBER
|
||||
#include "decNumber.h" /* context and number library */
|
||||
#endif
|
||||
|
||||
/* Decimal 64-bit type, accessible by bytes */
|
||||
typedef struct {
|
||||
uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/
|
||||
} decimal64;
|
||||
|
||||
/* special values [top byte excluding sign bit; last two bits are */
|
||||
/* don't-care for Infinity on input, last bit don't-care for NaN] */
|
||||
#if !defined(DECIMAL_NaN)
|
||||
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
|
||||
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
|
||||
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Routines */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* String conversions */
|
||||
decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
|
||||
char * decimal64ToString(const decimal64 *, char *);
|
||||
char * decimal64ToEngString(const decimal64 *, char *);
|
||||
|
||||
/* decNumber conversions */
|
||||
decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
|
||||
decContext *);
|
||||
decNumber * decimal64ToNumber(const decimal64 *, decNumber *);
|
||||
|
||||
/* Format-dependent utilities */
|
||||
uint32_t decimal64IsCanonical(const decimal64 *);
|
||||
decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);
|
||||
|
||||
#endif
|
@ -0,0 +1,44 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
include(../common.pri)
|
||||
|
||||
QT -= gui
|
||||
TEMPLATE = lib
|
||||
# decnumber library should always be static
|
||||
# regardless Qdecimal is static or dynamic
|
||||
CONFIG += static
|
||||
DEPENDPATH += .
|
||||
TARGET = decnumber
|
||||
DESTDIR = ../lib
|
||||
|
||||
|
||||
|
||||
# Input
|
||||
HEADERS += decContext.h \
|
||||
decDouble.h \
|
||||
decDPD.h \
|
||||
decimal128.h \
|
||||
decimal32.h \
|
||||
decimal64.h \
|
||||
decNumber.h \
|
||||
decNumberLocal.h \
|
||||
decPacked.h \
|
||||
decQuad.h \
|
||||
decSingle.h \
|
||||
decCommon.c \
|
||||
decBasic.c \
|
||||
Port_stdint.h \
|
||||
VCpp_stdint.h
|
||||
|
||||
SOURCES += decBasic.c \
|
||||
decCommon.c \
|
||||
decContext.c \
|
||||
decDouble.c \
|
||||
decimal128.c \
|
||||
decimal32.c \
|
||||
decimal64.c \
|
||||
decNumber.c \
|
||||
decPacked.c \
|
||||
decQuad.c \
|
||||
decSingle.c
|
@ -0,0 +1,172 @@
|
||||
|
||||
Dear Qt users,
|
||||
|
||||
I would like to announce initial public release of QDecimal library.
|
||||
|
||||
Most computers today support binary floating-point in hardware. While suitable
|
||||
for many purposes, binary floating-point arithmetic should not be used
|
||||
for financial, commercial, and user-centric applications because the
|
||||
decimal data used in these applications cannot be represented exactly
|
||||
using binary floating-point.
|
||||
|
||||
The General Decimal Arithmetic (GDA) specification aims to address
|
||||
deficiencies in the binary floating-point arithmetic, and defines a
|
||||
decimal arithmetic which meets the requirements of commercial,
|
||||
financial, and human-oriented applications. It also matches the
|
||||
decimal arithmetic in the IEEE 754-2008 Standard for Floating Point
|
||||
Arithmetic.
|
||||
|
||||
The decNumber library is full implementation of the GDA specification
|
||||
and also matches the decimal arithmetic in the IEEE 754-2008 Standard
|
||||
for Floating Point Arithmetic.
|
||||
|
||||
The QDecimal is a thin layer around IBM's decNumber library which
|
||||
implements the General Decimal Arithmetic Specification in ANSI C. [1]
|
||||
|
||||
The QDecimal/decNumberlibrary [2,3] fully implements the specification,
|
||||
and hence supports integer, fixed-point, and floating-point decimal
|
||||
numbers directly, including infinite, NaN (Not a Number), and
|
||||
subnormal values. Both arbitrary-precision and fixed-size
|
||||
representations are supported.
|
||||
|
||||
The aim of the QDecimal library [4] is to extend decNumber functionality
|
||||
to C++ language and Qt framework by using idioms, tecniques and best
|
||||
practices in both tecnologies. For instance, inline functions are used
|
||||
heavily to aid optimization, operator overloading and conversion
|
||||
operators are defined to aid type casting in between the types defined
|
||||
by QDecimal. Further these types are integrated with Qt object model
|
||||
by introducing them to Qt meta type system.
|
||||
|
||||
|
||||
CONTENTS
|
||||
Following classes are defined by QDecimal library:
|
||||
|
||||
QDecNumber (based on decNumber):
|
||||
----------
|
||||
decNumber module uses an arbitrary-precision decimal number
|
||||
representation designed for efficient computation in software and
|
||||
implements the arithmetic and logical operations, together with a
|
||||
number of conversions and utilities. Once a number is held as a
|
||||
decNumber, no further conversions are necessary to carry out
|
||||
arithmetic.
|
||||
|
||||
The decNumber representation is variable-length and machine-dependent
|
||||
(for example, it contains integers which may be big-endian or
|
||||
little-endian).
|
||||
|
||||
QDecNumber encapsulates decNumber and reimplements global functions
|
||||
that operates upon decNumber as member functions with the same name.
|
||||
|
||||
|
||||
QDecContext (based on decContext):
|
||||
-----------
|
||||
Most functions in the decNumber module take as an argument a
|
||||
decContext structure, which provides the context for operations
|
||||
(precision, rounding mode, etc.) and also controls the handling of
|
||||
exceptional conditions (corresponding to the flags and trap enablers
|
||||
in a hardware floating-point implementation).
|
||||
|
||||
QDecContext encapsulates decContext and provides decNumber library
|
||||
functions that operates upon decContext as member functions.
|
||||
|
||||
|
||||
QDecSingle (based on decSingle/decimal32):
|
||||
----------
|
||||
decimal32 is a 32-bit decimal floating-point representation which
|
||||
provides 7 decimal digits of precision in a compressed format.
|
||||
|
||||
decSingle module provides the functions for the decimal32 format; this
|
||||
format is intended for storage and interchange only and so the module
|
||||
provides utilities and conversions but no arithmetic functions.
|
||||
|
||||
QDecSingle encapsulates decSingle and provides decNumber library
|
||||
functions that operates upon decSingle as member functions with the
|
||||
same name.
|
||||
|
||||
|
||||
QDecDouble (based on decDouble/decimal64):
|
||||
----------
|
||||
decimal64 is a 64-bit decimal floating-point representation which
|
||||
provides 16 decimal digits of precision in a compressed format.
|
||||
|
||||
decDouble module provides the functions for the decimal64 format; this
|
||||
format is an IEEE 754 basic format and so a full set of arithmetic and
|
||||
other functions is included.
|
||||
|
||||
QDecDouble encapsulates decDouble and provides decNumber library
|
||||
functions that operates upon decSingle as member functions with the
|
||||
same name.
|
||||
|
||||
|
||||
QDecQuad (based on decQuad/decimal128):
|
||||
--------
|
||||
decimal128 is a 128-bit decimal floating-point representation which
|
||||
provides 34 decimal digits of precision in a compressed format.
|
||||
|
||||
decQuad module provides the functions for the decimal128 format; this
|
||||
format is an IEEE 754 basic format; it contains the same set of
|
||||
functions as decDouble.
|
||||
|
||||
QDecQuad encapsulates decQuad and provides decNumber library functions
|
||||
that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecPacked (based on decPacked):
|
||||
---------
|
||||
The decPacked format is the classic packed decimal format implemented
|
||||
by IBM S/360 and later machines, where each digit is encoded as a
|
||||
4-bit binary sequence (BCD) and a number is ended by a 4-bit sign
|
||||
indicator. The decPacked module accepts variable lengths, allowing for
|
||||
very large numbers (up to a billion digits), and also allows the
|
||||
specification of a scale.
|
||||
|
||||
QDecPacked augments decPacked by encapsulating reference counted byte
|
||||
array and scale of the decimal point as member variables, thus, freeing up
|
||||
user of this class from memory management and keeping track of scale value.
|
||||
|
||||
|
||||
LICENSE
|
||||
QDecimal is under the terms of the LGPL v2.1.
|
||||
decNumber is under the terms of ICU v1.8.1
|
||||
See COPYRIGHT file within the package for terms of the these licenses.
|
||||
Both licences allow commercial and non-commercial use of the software.
|
||||
|
||||
|
||||
PLATFORMS
|
||||
QDecimal should be usable in all platforms on which Qt 4.7.x or
|
||||
greater is supported:
|
||||
We regularly test on following platforms:
|
||||
Solaris 11 x86 (sstudio 12.2 CC 5.11)
|
||||
Linux x64 2.6.38 (Ubuntu 11.04 - gcc 4.5.2)
|
||||
Linux x86 2.6.38 (Ubuntu 11.04- gcc 4.5.2)
|
||||
Windows XP (msvc 2008)
|
||||
|
||||
|
||||
CREDITS
|
||||
We are grateful to Mike Cowlishaw et al. from IBM for making decNumber package
|
||||
available. Further, Mr. Cowlishaw has kindly helped us while making
|
||||
QDecimal production ready.
|
||||
|
||||
|
||||
REFERENCES
|
||||
[1] General Decimal Arithmetic Specification
|
||||
http://speleotrove.com/decimal/decarith.html
|
||||
|
||||
[2] The decNumber Library
|
||||
http://speleotrove.com/decimal/decnumber.html
|
||||
|
||||
[3] General Decimal Arithmetic
|
||||
http://speleotrove.com/decimal
|
||||
|
||||
[4] QDecimal Project Home
|
||||
http://code.google.com/p/qdecimal
|
||||
|
||||
|
||||
|
||||
Regards,
|
||||
Semih Cemiloglu
|
||||
|
||||
semih (at) cemiloglu.org
|
||||
PGP/GPG KeyId: FCEE9B7A on keyserver.pgp.com
|
||||
Fingerprint: ED8F48028DE03BE0A2C95E0FACC5043BFCEE9B7A
|
||||
|
@ -0,0 +1,55 @@
|
||||
|
||||
BUILDING
|
||||
~~~~~~~~
|
||||
We now have two options to build QDecimal project.
|
||||
A) SCons based build
|
||||
B) Qmake/Make based build.
|
||||
|
||||
SCons is now the preferred method of building.
|
||||
just type "scons" at the project root to build. type scons -h or -H to
|
||||
see full options for build.
|
||||
|
||||
|
||||
Qmake/Make based build is now deprecated, please use it as a last resort as
|
||||
it will be discontinued near future:
|
||||
|
||||
Unix
|
||||
~~~~
|
||||
qmake -r
|
||||
make
|
||||
|
||||
Use "make clean" to clean up intermediate (object etc.) files.
|
||||
Use "make distclean" to return to clean state.
|
||||
|
||||
Windows
|
||||
~~~~~~~
|
||||
qmake -r
|
||||
nmake
|
||||
|
||||
Use "nmake clean" to clean up intermediate (object etc.) files.
|
||||
Use "nmake distclean" to return to clean state.
|
||||
|
||||
TESTING
|
||||
~~~~~~~
|
||||
Execute the "qdecimal_test" application in the bin directory, ie. "cd bin".
|
||||
|
||||
To execute the subset of the tests, just run
|
||||
"qdecimal_test --testdir=tc_subset".
|
||||
|
||||
To execute the full set of the tests, just run
|
||||
"qdecimal_test --testdir=tc_full".
|
||||
|
||||
Full test would have only 2 expected (fma) failures, whereas subset
|
||||
test should not have any failure (grep -i fail / grep PASS).
|
||||
|
||||
SHARED LIBRARY
|
||||
~~~~~~~~~~~~~~
|
||||
a) Comment "CONFIG += static" line and uncomment the two lines
|
||||
beginning with "CONFIG += shared"
|
||||
in src/src.pro file.
|
||||
|
||||
b) In the client applications simply define QDECIMAL_SHARED macro as 1;
|
||||
that is "DEFINES += QDECIMAL_SHARED=1"
|
||||
|
||||
c) At run-time, PATH (Windows) or LD_LIBRARY_PATH (Unix) environment
|
||||
variables should be specified to locate the shared library.
|
@ -0,0 +1,113 @@
|
||||
* The QDecimal Library
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Overview
|
||||
~~~~~~~~
|
||||
|
||||
The QDecimal is a thin layer around IBM's decNumber library which implements the General Decimal Arithmetic Specification in ANSI C. [1]
|
||||
This specification defines a decimal arithmetic which meets the requirements of commercial, financial, and human-oriented applications. It also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic.
|
||||
The decNumber library also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic.
|
||||
|
||||
The QDecimal/decNumberlibrary [2] fully implements the specification, and hence supports integer, fixed-point, and floating-point decimal numbers directly, including infinite, NaN (Not a Number), and subnormal values. Both arbitrary-precision and fixed-size representations are supported.
|
||||
|
||||
|
||||
The aim of the QDecimal library is to extend decNumber functionality to C++ language and Qt framework by using idioms, tecniques and best practices in both tecnologies. For instance, inline functions are used heavily to aid optimization, operator overloading and conversion operators are defined to aid type casting in between the types defined by QDecimal. Further these types are integrated with Qt object model by introducing them to Qt meta type system.
|
||||
|
||||
Following classes are defined by QDecimal library:
|
||||
|
||||
|
||||
QDecNumber (based on decNumber):
|
||||
|
||||
decNumber module uses an arbitrary-precision decimal number representation designed for efficient computation in software and implements the arithmetic and logical operations, together with a number of conversions and utilities. Once a number is held as a decNumber, no further conversions are necessary to carry out arithmetic.
|
||||
The decNumber representation is variable-length and machine-dependent (for example, it contains integers which may be big-endian or little-endian).
|
||||
QDecNumber encapsulates decNumber and reimplements global functions that operates upon decNumber as member functions with the same name.
|
||||
|
||||
|
||||
QDecContext (based on decContext):
|
||||
|
||||
Most functions in the decNumber module take as an argument a decContext structure, which provides the context for operations (precision, rounding mode, etc.) and also controls the handling of exceptional conditions (corresponding to the flags and trap enablers in a hardware floating-point implementation).
|
||||
|
||||
|
||||
QDecSingle (based on decSingle/decimal32):
|
||||
|
||||
decimal32 is a 32-bit decimal floating-point representation which provides 7 decimal digits of precision in a compressed format.
|
||||
decSingle module provides the functions for the decimal32 format; this format is intended for storage and interchange only and so the module provides utilities and conversions but no arithmetic functions.
|
||||
QDecSingle encapsulates decSingle and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecDouble (based on decDouble/decimal64):
|
||||
|
||||
decimal64 is a 64-bit decimal floating-point representation which provides 16 decimal digits of precision in a compressed format.
|
||||
decDouble module provides the functions for the decimal64 format; this format is an IEEE 754 basic format and so a full set of arithmetic and other functions is included.
|
||||
QDecDouble encapsulates decDouble and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecQuad (based on decQuad/decimal128):
|
||||
|
||||
decimal128 is a 128-bit decimal floating-point representation which provides 34 decimal digits of precision in a compressed format.
|
||||
decQuad module provides the functions for the decimal128 format; this format is an IEEE 754 basic format; it contains the same set of functions as decDouble.
|
||||
QDecQuad encapsulates decQuad and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecPacked (based on decPacked):
|
||||
|
||||
The decPacked format is the classic packed decimal format implemented by IBM S/360 and later machines, where each digit is encoded as a 4-bit binary sequence (BCD) and a number is ended by a 4-bit sign indicator. The decPacked module accepts variable lengths, allowing for very large numbers (up to a billion digits), and also allows the specification of a scale.
|
||||
QDecPacked augments decPacked by encapsulating reference counted byte
|
||||
array and scale of the decimal point as members variables, thus, freeing up
|
||||
user of this class from memory management and keeping track of scale value.
|
||||
|
||||
|
||||
License
|
||||
~~~~~~~
|
||||
QDecimal is under the terms of the LGPL v2.1.
|
||||
decNumber is under the terms of ICU v1.8.1
|
||||
See COPYRIGHT file for terms of the these licenses.
|
||||
|
||||
Platforms
|
||||
~~~~~~~~~
|
||||
QDecimal should be usable in all platforms that Qt supports.
|
||||
We regularly test on following platforms:
|
||||
Solaris 11 x86 (sun studio 12.5)
|
||||
Linux (Ubuntu x64 - gcc)
|
||||
Linux (Ubuntu x86 - gcc)
|
||||
Windows XP (msvc 2008)
|
||||
|
||||
|
||||
Installation
|
||||
~~~~~~~~~~~~~~
|
||||
Read INSTALL.txt to build and install QDecimal.
|
||||
|
||||
Copyright
|
||||
~~~~~~~~~
|
||||
Copyright (C) 2012-2013 Semih Cemiloglu
|
||||
Copyright (c) IBM Corporation, 2000, 2010. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This 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 for more details (COPYRIGHT.txt).
|
||||
|
||||
The decNumber library has separate license terms, which is governed by
|
||||
ICU License -- ICU 1.8.1 and later.
|
||||
|
||||
|
||||
Credits
|
||||
~~~~~~~
|
||||
We are grateful to Mike Cowlishaw et al. from IBM for making decNumber package
|
||||
available. Mr. Cowlishaw has kindly helped while making QDecimal production
|
||||
ready.
|
||||
|
||||
|
||||
In memoriam
|
||||
~~~~~~~~~~~
|
||||
QDecimal library is dedicated to cherished memory of my late uncle:
|
||||
|
||||
Muharrem Saffet Bozkurt
|
||||
|
||||
He is sadly missed.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,100 @@
|
||||
/*
|
||||
This file contains NO source code, just some documentation for doxygen to
|
||||
parse.
|
||||
(c) Semih Cemiloglu
|
||||
*/
|
||||
|
||||
/*!
|
||||
\mainpage QDecimal - Decimal Arithmetic Library for Qt Framework
|
||||
|
||||
The QDecimal is a thin layer around IBM's decNumber library which implements the General Decimal Arithmetic Specification in ANSI C. [1]
|
||||
This specification defines a decimal arithmetic which meets the requirements of commercial, financial, and human-oriented applications. It also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic.
|
||||
The decNumber library also matches the decimal arithmetic in the IEEE 754 Standard for Floating Point Arithmetic.
|
||||
|
||||
The QDecimal/decNumberlibrary [2] fully implements the specification, and hence supports integer, fixed-point, and floating-point decimal numbers directly, including infinite, NaN (Not a Number), and subnormal values. Both arbitrary-precision and fixed-size representations are supported.
|
||||
|
||||
|
||||
The aim of the QDecimal library is to extend decNumber functionality to C++ language and Qt framework by using idioms, tecniques and best practices in both tecnologies. For instance, inline functions are used heavily to aid optimization, operator overloading and conversion operators are defined to aid type casting in between the types defined by QDecimal. Further these types are integrated with Qt object model by introducing them to Qt meta type system.
|
||||
|
||||
|
||||
Following classes are defined by QDecimal library:
|
||||
|
||||
|
||||
QDecNumber (based on decNumber):
|
||||
|
||||
decNumber module uses an arbitrary-precision decimal number representation designed for efficient computation in software and implements the arithmetic and logical operations, together with a number of conversions and utilities. Once a number is held as a decNumber, no further conversions are necessary to carry out arithmetic.
|
||||
The decNumber representation is variable-length and machine-dependent (for example, it contains integers which may be big-endian or little-endian).
|
||||
QDecNumber encapsulates decNumber and reimplements global functions that operates upon decNumber as member functions with the same name.
|
||||
|
||||
|
||||
QDecContext (based on decContext):
|
||||
|
||||
Most functions in the decNumber module take as an argument a decContext structure, which provides the context for operations (precision, rounding mode, etc.) and also controls the handling of exceptional conditions (corresponding to the flags and trap enablers in a hardware floating-point implementation).
|
||||
|
||||
|
||||
QDecSingle (based on decSingle/decimal32):
|
||||
|
||||
decimal32 is a 32-bit decimal floating-point representation which provides 7 decimal digits of precision in a compressed format.
|
||||
decSingle module provides the functions for the decimal32 format; this format is intended for storage and interchange only and so the module provides utilities and conversions but no arithmetic functions.
|
||||
QDecSingle encapsulates decSingle and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecDouble (based on decDouble/decimal64):
|
||||
|
||||
decimal64 is a 64-bit decimal floating-point representation which provides 16 decimal digits of precision in a compressed format.
|
||||
decDouble module provides the functions for the decimal64 format; this format is an IEEE 754 basic format and so a full set of arithmetic and other functions is included.
|
||||
QDecDouble encapsulates decDouble and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecQuad (based on decQuad/decimal128):
|
||||
|
||||
decimal128 is a 128-bit decimal floating-point representation which provides 34 decimal digits of precision in a compressed format.
|
||||
decQuad module provides the functions for the decimal128 format; this format is an IEEE 754 basic format; it contains the same set of functions as decDouble.
|
||||
QDecQuad encapsulates decQuad and provides decNumber library functions that operates upon decSingle as member functions with the same name.
|
||||
|
||||
|
||||
QDecPacked (based on decPacked):
|
||||
|
||||
The decPacked format is the classic packed decimal format implemented by IBM S/360 and later machines, where each digit is encoded as a 4-bit binary sequence (BCD) and a number is ended by a 4-bit sign indicator. The decPacked module accepts variable lengths, allowing for very large numbers (up to a billion digits), and also allows the specification of a scale.
|
||||
QDecPacked augments decPacked by encapsulating reference counted byte
|
||||
array and scale of the decimal point as members variables, thus, freeing up
|
||||
user of this class from memory management and keeping track of scale value.
|
||||
|
||||
\section license License
|
||||
|
||||
QDecimal is under the terms of the LGPL v2.1.
|
||||
|
||||
decNumber is under the terms of ICU v1.8.1
|
||||
|
||||
See COPYRIGHT file for terms of the these licenses.
|
||||
|
||||
\section platforms Platforms
|
||||
|
||||
QDecimal should be usable in all platforms that Qt supports.
|
||||
We regularly test on following platforms:
|
||||
|
||||
Solaris 11 x86 (sun studio 12.5)
|
||||
|
||||
Linux (Ubuntu x64 - gcc)
|
||||
|
||||
Linux (Ubuntu x86 - gcc)
|
||||
|
||||
Windows XP (msvc 2008)
|
||||
|
||||
|
||||
\section credits Credits
|
||||
|
||||
We are grateful to Mike Cowlishaw et al. from IBM for making decNumber package
|
||||
available.
|
||||
|
||||
\section references References
|
||||
|
||||
[1] <a href="http://speleotrove.com/decimal/decarith.html">General Decimal Arithmetic Specification</a>
|
||||
|
||||
[2] <a href="http://speleotrove.com/decimal/decnumber.html">The decNumber Library</a>
|
||||
|
||||
[3] <a href="http://speleotrove.com/decimal/">General Decimal Arithmetic</a>
|
||||
|
||||
[4] <a href="http://code.google.com/p/qdecimal/">QDecimal Project Home</a>
|
||||
|
||||
*/
|
@ -0,0 +1,8 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
|
||||
SUBDIRS = decnumber src test
|
@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.2.1, 2016-02-09T20:24:47. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{4077bda4-95d6-43f4-b485-ec6a1732d10d}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{94142068-0625-4819-93ea-3dc64f347f5e}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jony/Prg/build-qdecimal-Desktop-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jony/Prg/build-qdecimal-Desktop-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">test</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jony/Prg/qdecimal/test/test.pro</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">test/test.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">16</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">16</value>
|
||||
</data>
|
||||
</qtcreator>
|
@ -0,0 +1,220 @@
|
||||
#!python
|
||||
# -*-python-*-
|
||||
#
|
||||
# SCons extension library for large C/C++ projects.
|
||||
# Author: Semih Cemiloglu <semih.cemiloglu@gmail.com>
|
||||
# Initial: 2016-01-20
|
||||
# This file and all associated files have 'BSD License' copyright terms
|
||||
#
|
||||
|
||||
# Standard modules
|
||||
import os
|
||||
import sys
|
||||
import atexit
|
||||
import subprocess
|
||||
# Scons modules
|
||||
import SCons
|
||||
from SCons.Script import *
|
||||
|
||||
|
||||
|
||||
def getVersion():
|
||||
return SCons.__version__
|
||||
|
||||
def printBuildFailures():
|
||||
for bf in GetBuildFailures():
|
||||
print "%s failed: %s" % (bf.node, bf.errstr)
|
||||
|
||||
def findQtDir(defDir=None):
|
||||
""" Detect Qt version on the platform. """
|
||||
qtdir = os.environ.get('QT5DIR',None)
|
||||
if qtdir:
|
||||
return qtdir
|
||||
qtdir = os.environ.get('QTDIR',None)
|
||||
if qtdir:
|
||||
return qtdir
|
||||
return defDir
|
||||
|
||||
|
||||
def constructVariables(cfgFile=None):
|
||||
"""
|
||||
Construct variables from command line arguments given to scons
|
||||
ARGUMENTS and ARGLIST
|
||||
"""
|
||||
vars = Variables(cfgFile)
|
||||
vars.Add('verbose','Set to non-zero for verbose output', 0)
|
||||
vars.Add(EnumVariable('build_mode', 'Build mode', 'dbg',
|
||||
allowed_values=('dbg', 'rel'),
|
||||
map={'debug':'dbg', 'release':'rel'}))
|
||||
vars.Add(BoolVariable('use_plat', 'Use platform as build variant', 0))
|
||||
vars.Add(BoolVariable('run_tests', 'Run tests at the end', 0))
|
||||
vars.Add(PathVariable('build_dir',
|
||||
'Path to build directory',
|
||||
'sbuild',
|
||||
PathVariable.PathIsDirCreate))
|
||||
vars.Add(BoolVariable('dump', 'Dump contents of environment', 0))
|
||||
|
||||
# Add --prefix option to be able to specify installation directory
|
||||
# outside of prect directory tree.
|
||||
AddOption('--prefix',
|
||||
dest='prefix',
|
||||
type='string',
|
||||
default=None,
|
||||
nargs=1,
|
||||
action='store',
|
||||
metavar='DIR',
|
||||
help='installation prefix')
|
||||
|
||||
return vars
|
||||
|
||||
|
||||
def checkUnknownVariables(vars):
|
||||
"""
|
||||
Check if vars contains unknown variables for an environment.
|
||||
"""
|
||||
unknown = vars.UnknownVariables()
|
||||
if unknown:
|
||||
print "Unknown variables:", unknown.keys()
|
||||
#This should be warning only
|
||||
#Exit(1)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
def setupEnvironment(env):
|
||||
"""
|
||||
Prepare a scons construction environment for building.
|
||||
"""
|
||||
# Directories that build output will be generated into
|
||||
platform = sys.platform
|
||||
bld_mode = env['build_mode']
|
||||
bld_dir = env['build_dir']
|
||||
if env['use_plat']:
|
||||
bld_pdir = '%s/%s' % (bld_dir, platform)
|
||||
else:
|
||||
bld_pdir = bld_dir
|
||||
bld_vdir = '%s/%s' % (bld_pdir, bld_mode)
|
||||
|
||||
|
||||
# Store build directories and setup build output data structures
|
||||
env.AppendUnique(
|
||||
PRJ_BLD_DIR = Dir(bld_dir),
|
||||
PRJ_BLD_VDIR = Dir(bld_vdir),
|
||||
PRJ_BLD_BIN = Dir('%s/bin' % bld_vdir),
|
||||
PRJ_BLD_LIB = Dir('%s/lib' % bld_vdir),
|
||||
PRJ_EXES = {},
|
||||
PRJ_TSTS = {},
|
||||
PRJ_LIBS = {},
|
||||
PRJ_OBJS = {}
|
||||
)
|
||||
|
||||
# If project install location (prefix) is specified
|
||||
if env['PREFIX']:
|
||||
# Define installation locations
|
||||
env.AppendUnique(
|
||||
PRJ_INST_DIR = Dir(env['PREFIX']),
|
||||
PRJ_INST_BIN = Dir('%s/bin' % env['PREFIX']),
|
||||
PRJ_INST_LIB = Dir('%s/lib' % env['PREFIX'])
|
||||
)
|
||||
|
||||
# Baseline compile/link flags
|
||||
if platform == 'win32':
|
||||
if 'cl' in env['CC']:
|
||||
if env['build_mode'] == 'dbg':
|
||||
env.MergeFlags('-MTd -W1 -D_DEBUG -RTCs -Zi')
|
||||
else:
|
||||
env.MergeFlags('-MT -O1 -DNDEBUG')
|
||||
if env['verbose']:
|
||||
env.AppendUnique(CCFLAGS='-Bt')
|
||||
env.AppendUnique(LINKFLAGS=['-verbose:lib', '-time'])
|
||||
else:
|
||||
print "Unrecognized compiler: %s" % env['CC']
|
||||
elif 'linux' in platform:
|
||||
# Replace LINKCOM to position LINKFLAGS at the very end of
|
||||
# link command line
|
||||
env.Replace(LINKCOM='$LINK -o $TARGET $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS')
|
||||
env.AppendUnique(LINKFLAGS = ['-lm' ])
|
||||
env.AppendUnique(CCFLAGS = ['-fPIC','-DPIC'])
|
||||
if env['build_mode'] == 'dbg':
|
||||
env.MergeFlags('-g')
|
||||
else:
|
||||
env.MergeFlags('-O2 -w')
|
||||
if env['verbose']:
|
||||
env.AppendUnique(CCFLAGS='-v')
|
||||
else:
|
||||
# Warning only, rely on SCons to come up with meaningful defaults
|
||||
print "Unrecognized platform: %s" % platform
|
||||
|
||||
|
||||
# Inform user about the build mode
|
||||
print "Will build for %s mode..." % bld_mode
|
||||
# Help output to be shown to users
|
||||
Help("""
|
||||
Type: 'scons' to build all libraries and executables.
|
||||
""")
|
||||
# At the abnormal exit show information about build failures
|
||||
atexit.register(printBuildFailures)
|
||||
return 0
|
||||
|
||||
|
||||
def readSConscriptFiles(env, src_dirs):
|
||||
for sd in src_dirs:
|
||||
env.SConscript(
|
||||
'%s/SConscript' % sd,
|
||||
variant_dir='%s/%s' % (env['PRJ_BLD_VDIR'],sd),
|
||||
duplicate=0,
|
||||
exports='env'
|
||||
)
|
||||
|
||||
# Firstly, install project outputs to variant directories
|
||||
for lib in env['PRJ_LIBS'].values():
|
||||
env.Install("$PRJ_BLD_LIB", lib)
|
||||
for exe in env['PRJ_EXES'].values():
|
||||
env.Install("$PRJ_BLD_BIN", exe)
|
||||
for exe in env['PRJ_TSTS'].values():
|
||||
env.Install("$PRJ_BLD_BIN", exe)
|
||||
|
||||
# Add a 'install' target for project output files
|
||||
# This will support calls to scons with "install" target
|
||||
# scons --prefix=/path/to/gsl install
|
||||
if env['PREFIX']:
|
||||
env.Alias('install', env['PREFIX'])
|
||||
for lib in env['PRJ_LIBS'].values():
|
||||
env.Install("$PRJ_INST_LIB", lib)
|
||||
for exe in env['PRJ_EXES'].values():
|
||||
env.Install("$PRJ_INST_BIN", exe)
|
||||
# Note that we don't install test applications
|
||||
|
||||
|
||||
if env['dump']:
|
||||
print env.Dump()
|
||||
|
||||
if env['run_tests']:
|
||||
runTests(env)
|
||||
|
||||
|
||||
|
||||
def useProgress(mode=None, interval=5):
|
||||
"""
|
||||
use and show progress indicator when building
|
||||
"""
|
||||
if mode == 'target':
|
||||
Progress('Evaluating $TARGET\r')
|
||||
else:
|
||||
Progress(['-\r', '\\\r', '|\r', '/\r'], interval)
|
||||
|
||||
|
||||
|
||||
def runTests(env):
|
||||
for exe in env['PRJ_TSTS'].values():
|
||||
cmd = exe[0].abspath
|
||||
print "Executing: %s" % cmd
|
||||
rv = subprocess.call(cmd)
|
||||
if rv == 0:
|
||||
print "PASS: %s" % os.path.basename(cmd)
|
||||
else:
|
||||
print "FAIL: %s" % os.path.basename(cmd)
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,351 @@
|
||||
####################################
|
||||
The SCons qt5 tool
|
||||
####################################
|
||||
|
||||
Basics
|
||||
======
|
||||
This tool can be used to compile Qt projects, designed for versions 5.x.y and higher.
|
||||
It is not usable for Qt3 and older versions, since some of the helper tools
|
||||
(``moc``, ``uic``) behave different.
|
||||
|
||||
Install
|
||||
-------
|
||||
Installing it, requires you to copy (or, even better: checkout) the contents of the
|
||||
package's ``qt5`` folder to
|
||||
|
||||
#. "``/path_to_your_project/site_scons/site_tools/qt5``", if you need the Qt5 Tool in one project only, or
|
||||
#. "``~/.scons/site_scons/site_tools/qt5``", for a system-wide installation under your current login.
|
||||
|
||||
For more infos about this, please refer to
|
||||
|
||||
* the SCons User's Guide, sect. "Where to put your custom Builders and Tools" and
|
||||
* the SCons Tools Wiki page at `http://scons.org/wiki/ToolsIndex <http://scons.org/wiki/ToolsIndex/>`_.
|
||||
|
||||
How to activate
|
||||
---------------
|
||||
For activating the tool "qt5", you have to add its name to the Environment constructor,
|
||||
like this
|
||||
|
||||
::
|
||||
|
||||
env = Environment(tools=['default','qt5'])
|
||||
|
||||
|
||||
On its startup, the Qt5 tool tries to read the variable ``QT5DIR`` from the current
|
||||
Environment and ``os.environ``. If it is not set, the value of ``QTDIR`` (in
|
||||
Environment/``os.environ``) is used as a fallback.
|
||||
|
||||
So, you either have to explicitly give the path of your Qt5 installation to the
|
||||
Environment with
|
||||
|
||||
::
|
||||
|
||||
env['QT5DIR'] = '/usr/local/Trolltech/Qt-5.2.3'
|
||||
|
||||
|
||||
or set the ``QT5DIR`` as environment variable in your shell.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
Under Linux, "qt5" uses the system tool ``pkg-config`` for automatically
|
||||
setting the required compile and link flags of the single Qt5 modules (like QtCore,
|
||||
QtGui,...).
|
||||
This means that
|
||||
|
||||
#. you should have ``pkg-config`` installed, and
|
||||
#. you additionally have to set ``PKG_CONFIG_PATH`` in your shell environment, such
|
||||
that it points to $``QT5DIR/lib/pkgconfig`` (or $``QT5DIR/lib`` for some older versions).
|
||||
|
||||
Based on these two environment variables (``QT5DIR`` and ``PKG_CONFIG_PATH``),
|
||||
the "qt5" tool initializes all ``QT5_*``
|
||||
construction variables listed in the Reference manual. This happens when the tool
|
||||
is "detected" during Environment construction. As a consequence, the setup
|
||||
of the tool gets a two-stage process, if you want to override the values provided
|
||||
by your current shell settings:
|
||||
|
||||
::
|
||||
|
||||
# Stage 1: create plain environment
|
||||
qtEnv = Environment()
|
||||
# Set new vars
|
||||
qtEnv['QT5DIR'] = '/usr/local/Trolltech/Qt-5.2.3
|
||||
qtEnv['ENV']['PKG_CONFIG_PATH'] = '/usr/local/Trolltech/Qt-5.2.3/lib/pkgconfig'
|
||||
# Stage 2: add qt5 tool
|
||||
qtEnv.Tool('qt5')
|
||||
|
||||
|
||||
|
||||
|
||||
Suggested boilerplate
|
||||
=====================
|
||||
Based on the requirements above, we suggest a simple ready-to-go setup
|
||||
as follows:
|
||||
|
||||
SConstruct
|
||||
|
||||
::
|
||||
|
||||
# Detect Qt version
|
||||
qtdir = detectLatestQtDir()
|
||||
|
||||
# Create base environment
|
||||
baseEnv = Environment()
|
||||
#...further customization of base env
|
||||
|
||||
# Clone Qt environment
|
||||
qtEnv = baseEnv.Clone()
|
||||
# Set QT5DIR and PKG_CONFIG_PATH
|
||||
qtEnv['ENV']['PKG_CONFIG_PATH'] = os.path.join(qtdir, 'lib/pkgconfig')
|
||||
qtEnv['QT5DIR'] = qtdir
|
||||
# Add qt5 tool
|
||||
qtEnv.Tool('qt5')
|
||||
#...further customization of qt env
|
||||
|
||||
# Export environments
|
||||
Export('baseEnv qtEnv')
|
||||
|
||||
# Your other stuff...
|
||||
# ...including the call to your SConscripts
|
||||
|
||||
|
||||
In a SConscript
|
||||
|
||||
::
|
||||
|
||||
# Get the Qt5 environment
|
||||
Import('qtEnv')
|
||||
# Clone it
|
||||
env = qtEnv.clone()
|
||||
# Patch it
|
||||
env.Append(CCFLAGS=['-m32']) # or whatever
|
||||
# Use it
|
||||
env.StaticLibrary('foo', Glob('*.cpp'))
|
||||
|
||||
|
||||
The detection of the Qt directory could be as simple as directly assigning
|
||||
a fixed path
|
||||
|
||||
::
|
||||
|
||||
def detectLatestQtDir():
|
||||
return "/usr/local/qt5.3.2"
|
||||
|
||||
|
||||
or a little more sophisticated
|
||||
|
||||
::
|
||||
|
||||
# Tries to detect the path to the installation of Qt with
|
||||
# the highest version number
|
||||
def detectLatestQtDir():
|
||||
if sys.platform.startswith("linux"):
|
||||
# Simple check: inspect only '/usr/local/Trolltech'
|
||||
paths = glob.glob('/usr/local/Trolltech/*')
|
||||
if len(paths):
|
||||
paths.sort()
|
||||
return paths[-1]
|
||||
else:
|
||||
return ""
|
||||
else:
|
||||
# Simple check: inspect only 'C:\Qt'
|
||||
paths = glob.glob('C:\\Qt\\*')
|
||||
if len(paths):
|
||||
paths.sort()
|
||||
return paths[-1]
|
||||
else:
|
||||
return os.environ.get("QTDIR","")
|
||||
|
||||
|
||||
|
||||
A first project
|
||||
===============
|
||||
The following SConscript is for a simple project with
|
||||
some cxx files, using the QtCore, QtGui
|
||||
and QtNetwork modules:
|
||||
|
||||
::
|
||||
|
||||
Import('qtEnv')
|
||||
env = qtEnv.Clone()
|
||||
env.EnableQt5Modules([
|
||||
'QtGui',
|
||||
'QtCore',
|
||||
'QtNetwork'
|
||||
])
|
||||
# Add your CCFLAGS and CPPPATHs to env here...
|
||||
|
||||
env.Program('foo', Glob('*.cpp'))
|
||||
|
||||
|
||||
|
||||
MOC it up
|
||||
=========
|
||||
For the basic support of automocing, nothing needs to be
|
||||
done by the user. The tool usually detects the ``Q_OBJECT``
|
||||
macro and calls the "``moc``" executable accordingly.
|
||||
|
||||
If you don't want this, you can switch off the automocing
|
||||
by a
|
||||
|
||||
::
|
||||
|
||||
env['QT5_AUTOSCAN'] = 0
|
||||
|
||||
|
||||
in your SConscript file. Then, you have to moc your files
|
||||
explicitly, using the Moc5 builder.
|
||||
|
||||
You can also switch to an extended automoc strategy with
|
||||
|
||||
::
|
||||
|
||||
env['QT5_AUTOSCAN_STRATEGY'] = 1
|
||||
|
||||
|
||||
Please read the description of the ``QT5_AUTOSCAN_STRATEGY``
|
||||
variable in the Reference manual for details.
|
||||
|
||||
For debugging purposes, you can set the variable ``QT5_DEBUG``
|
||||
with
|
||||
|
||||
::
|
||||
|
||||
env['QT5_DEBUG'] = 1
|
||||
|
||||
|
||||
which outputs a lot of messages during automocing.
|
||||
|
||||
|
||||
Forms (.ui)
|
||||
===========
|
||||
The header files with setup code for your GUI classes, are not
|
||||
compiled automatically from your ``.ui`` files. You always
|
||||
have to call the Uic5 builder explicitly like
|
||||
|
||||
::
|
||||
|
||||
env.Uic5(Glob('*.ui'))
|
||||
env.Program('foo', Glob('*.cpp'))
|
||||
|
||||
|
||||
|
||||
Resource files (.qrc)
|
||||
=====================
|
||||
Resource files are not built automatically, you always
|
||||
have to add the names of the ``.qrc`` files to the source list
|
||||
for your program or library:
|
||||
|
||||
::
|
||||
|
||||
env.Program('foo', Glob('*.cpp')+Glob('*.qrc'))
|
||||
|
||||
|
||||
For each of the Resource input files, its prefix defines the
|
||||
name of the resulting resource. An appropriate "``-name``" option
|
||||
is added to the call of the ``rcc`` executable
|
||||
by default.
|
||||
|
||||
You can also call the Qrc5 builder explicitly as
|
||||
|
||||
::
|
||||
|
||||
qrccc = env.Qrc5('foo') # ['foo.qrc'] -> ['qrc_foo.cc']
|
||||
|
||||
|
||||
or (overriding the default suffix)
|
||||
|
||||
::
|
||||
|
||||
qrccc = env.Qrc5('myprefix_foo.cxx','foo.qrc') # -> ['qrc_myprefix_foo.cxx']
|
||||
|
||||
|
||||
and then add the resulting cxx file to the sources of your
|
||||
Program/Library:
|
||||
|
||||
::
|
||||
|
||||
env.Program('foo', Glob('*.cpp') + qrccc)
|
||||
|
||||
|
||||
|
||||
Translation files
|
||||
=================
|
||||
The update of the ``.ts`` files and the conversion to binary
|
||||
``.qm`` files is not done automatically. You have to call the
|
||||
corresponding builders on your own.
|
||||
|
||||
Example for updating a translation file:
|
||||
|
||||
::
|
||||
|
||||
env.Ts5('foo.ts','.') # -> ['foo.ts']
|
||||
|
||||
|
||||
By default, the ``.ts`` files are treated as *precious* targets. This means that
|
||||
they are not removed prior to a rebuild, but simply get updated. Additionally, they
|
||||
do not get cleaned on a "``scons -c``". If you want to delete the translation files
|
||||
on the "``-c``" SCons command, you can set the variable "``QT5_CLEAN_TS``" like this
|
||||
|
||||
::
|
||||
|
||||
env['QT5_CLEAN_TS']=1
|
||||
|
||||
|
||||
Example for releasing a translation file, i.e. compiling
|
||||
it to a ``.qm`` binary file:
|
||||
|
||||
::
|
||||
|
||||
env.Qm5('foo') # ['foo.ts'] -> ['foo.qm']
|
||||
|
||||
|
||||
or (overriding the output prefix)
|
||||
|
||||
::
|
||||
|
||||
env.Qm5('myprefix','foo') # ['foo.ts'] -> ['myprefix.qm']
|
||||
|
||||
|
||||
As an extension both, the Ts5() and Qm5 builder, support the definition of
|
||||
multiple targets. So, calling
|
||||
|
||||
::
|
||||
|
||||
env.Ts5(['app_en','app_de'], Glob('*.cpp'))
|
||||
|
||||
|
||||
and
|
||||
|
||||
::
|
||||
|
||||
env.Qm5(['app','copy'], Glob('*.ts'))
|
||||
|
||||
|
||||
should work fine.
|
||||
|
||||
Finally, two short notes about the support of directories for the Ts5() builder. You can
|
||||
pass an arbitrary mix of cxx files and subdirs to it, as in
|
||||
|
||||
::
|
||||
|
||||
env.Ts5('app_en',['sub1','appwindow.cpp','main.cpp']))
|
||||
|
||||
|
||||
where ``sub1`` is a folder that gets scanned recursively for cxx files by ``lupdate``.
|
||||
But like this, you lose all dependency information for the subdir, i.e. if a file
|
||||
inside the folder changes, the .ts file is not updated automatically! In this case
|
||||
you should tell SCons to always update the target:
|
||||
|
||||
::
|
||||
|
||||
ts = env.Ts5('app_en',['sub1','appwindow.cpp','main.cpp'])
|
||||
env.AlwaysBuild(ts)
|
||||
|
||||
|
||||
Last note: specifying the current folder "``.``" as input to Ts5() and storing the resulting
|
||||
.ts file in the same directory, leads to a dependency cycle! You then have to store the .ts
|
||||
and .qm files outside of the current folder, or use ``Glob('*.cpp'))`` instead.
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,131 @@
|
||||
/** \file DeciContext.cc
|
||||
* Definitions for the class QDecContext.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecContext.hh"
|
||||
//include <sstream>
|
||||
#include <QtGlobal>
|
||||
#include <QByteArray>
|
||||
#include <QTextStream>
|
||||
#include "QDecFwd.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
QDecContext::QDecContext(int32_t kind)
|
||||
{
|
||||
switch(kind) {
|
||||
case DEC_INIT_BASE:
|
||||
case DEC_INIT_DECIMAL32:
|
||||
case DEC_INIT_DECIMAL64:
|
||||
case DEC_INIT_DECIMAL128:
|
||||
// Above kinds must be specified
|
||||
break;
|
||||
|
||||
default:
|
||||
// Invalid kind
|
||||
throw("Invalid QDecContext kind");
|
||||
}
|
||||
|
||||
decContextDefault(&m_data, kind);
|
||||
|
||||
// No SIGFPE trap is allowed by default
|
||||
// as this will disrupt most calculations.
|
||||
m_data.traps = 0;
|
||||
|
||||
// By default allow maximum allowable precision
|
||||
setDigits(QDecNumDigits);
|
||||
}
|
||||
|
||||
|
||||
QByteArray QDecContext::statusFlags() const
|
||||
{
|
||||
uint32_t status = m_data.status;
|
||||
QByteArray str;
|
||||
QTextStream os(&str);
|
||||
//ostringstream os;
|
||||
const char sep = '|'; // Separator
|
||||
|
||||
if(status & DEC_Conversion_syntax)
|
||||
os << DEC_Condition_CS << sep;
|
||||
if(status & DEC_Division_by_zero)
|
||||
os << DEC_Condition_DZ << sep;
|
||||
if(status & DEC_Division_impossible)
|
||||
os << DEC_Condition_DI << sep;
|
||||
if(status & DEC_Division_undefined)
|
||||
os << DEC_Condition_DU << sep;
|
||||
if(status & DEC_Inexact)
|
||||
os << DEC_Condition_IE << sep;
|
||||
if(status & DEC_Invalid_context)
|
||||
os << DEC_Condition_IC << sep;
|
||||
if(status & DEC_Insufficient_storage)
|
||||
os << DEC_Condition_IS << sep;
|
||||
if(status & DEC_Invalid_operation)
|
||||
os << DEC_Condition_IO << sep;
|
||||
#if DECSUBSET
|
||||
if(status & DEC_Lost_digits)
|
||||
os << DEC_Condition_LD << sep;
|
||||
#endif
|
||||
if(status & DEC_Overflow)
|
||||
os << DEC_Condition_OV << sep;
|
||||
if(status & DEC_Clamped)
|
||||
os << DEC_Condition_PA << sep;
|
||||
if(status & DEC_Rounded)
|
||||
os << DEC_Condition_RO << sep;
|
||||
if(status & DEC_Subnormal)
|
||||
os << DEC_Condition_SU << sep;
|
||||
if(status & DEC_Underflow)
|
||||
os << DEC_Condition_UN << sep;
|
||||
if(0==status)
|
||||
os << DEC_Condition_ZE << sep;
|
||||
|
||||
os << "0x" << hex << status;
|
||||
|
||||
os.flush();
|
||||
//return os.str().c_str();
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
uint8_t QDecContext::extended() const
|
||||
{
|
||||
#if DECSUBSET
|
||||
return m_data.extended;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void QDecContext::setExtended(uint8_t ext)
|
||||
{
|
||||
#if DECSUBSET
|
||||
m_data.extended = ext;
|
||||
#else
|
||||
(void)ext; // To disable compiler warning
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecContext ctx)
|
||||
{
|
||||
char c = ' ';
|
||||
ts << "digits=" << ctx.digits()
|
||||
<< c << "emax=" << ctx.emax()
|
||||
<< c << "emin=" << ctx.emin()
|
||||
<< c << "extended=" << ctx.extended()
|
||||
<< c << "clamp=" << ctx.clamp()
|
||||
<< c << "round=" << ctx.round()
|
||||
<< c << "traps=" << ctx.traps()
|
||||
<< c << "status=" << ctx.status()
|
||||
<< c << ctx.statusToString();
|
||||
|
||||
return ts;
|
||||
}
|
@ -0,0 +1,251 @@
|
||||
#ifndef QDECCONTEXT_HH
|
||||
#define QDECCONTEXT_HH
|
||||
|
||||
/** \file QDecContext.hh
|
||||
* Declarations for the class QDecContext.
|
||||
*
|
||||
* (C) Copyright Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "decContext.h"
|
||||
}
|
||||
#include "QDecFwd.hh"
|
||||
|
||||
|
||||
// FORWARDS
|
||||
class QByteArray;
|
||||
class QTextStream;
|
||||
|
||||
/*! Default context type or kind, should be set to one of these:
|
||||
* DEC_INIT_BASE
|
||||
* DEC_INIT_DECIMAL32
|
||||
* DEC_INIT_DECIMAL64
|
||||
* DEC_INIT_DECIMAL128
|
||||
*/
|
||||
const int QDecContextDefKind = DEC_INIT_BASE;
|
||||
|
||||
|
||||
//! Maximum precision allowed in precision (digits) field
|
||||
const int32_t QDecMaxPrecision = 999999999;
|
||||
const int32_t QDecMaxExponent = 999999999;
|
||||
const int32_t QDecMinExponent = -999999999;
|
||||
|
||||
/*!
|
||||
\class QDecContext
|
||||
QDecContext encapsulates decContext structure as member and
|
||||
exposes free-standing functions as member functions.
|
||||
Most functions in the decNumber module take as an argument a
|
||||
decContext structure, which provides the context for operations
|
||||
(precision, rounding mode, etc.) and also controls the handling of
|
||||
exceptional conditions (corresponding to the flags and trap enablers
|
||||
in a hardware floating-point implementation).
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecContext
|
||||
{
|
||||
// MEMBERS
|
||||
//! Embedded decContext structure
|
||||
decContext m_data;
|
||||
|
||||
public:
|
||||
// TYPES
|
||||
typedef decContext* decContextPtr_t;
|
||||
typedef enum rounding Rounding_e;
|
||||
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecContext(int32_t kind = QDecContextDefKind);
|
||||
QDecContext(const decContext* cptr) : m_data(*cptr) {}
|
||||
QDecContext(const decContext& data) : m_data(data) {}
|
||||
// Default Copy Ctor and Dtor and Copy assignment are ok
|
||||
|
||||
|
||||
// ACCESSORS
|
||||
//! Get decContext member
|
||||
const decContext* data() const
|
||||
{ return &m_data; }
|
||||
|
||||
//! Get clamp flag of the context (IEEE exponent clamp)
|
||||
uint8_t clamp() const
|
||||
{ return m_data.clamp; }
|
||||
|
||||
//! Get digits field of the context (working precision)
|
||||
int32_t digits() const
|
||||
{ return m_data.digits; }
|
||||
|
||||
//! Get emax field of the context (maximum positive exponent)
|
||||
int32_t emax() const
|
||||
{ return m_data.emax; }
|
||||
|
||||
//! Get emin field of the context (minimum negative exponent)
|
||||
int32_t emin() const
|
||||
{ return m_data.emin; }
|
||||
|
||||
//! Get extended flag of the context (special values)
|
||||
uint8_t extended() const;
|
||||
|
||||
//! Get round field of the context (rounding mode)
|
||||
Rounding_e round() const
|
||||
{ return m_data.round; }
|
||||
|
||||
//! Get status flags of the context
|
||||
uint32_t status() const
|
||||
{ return m_data.status; }
|
||||
|
||||
//! Get trap-enabler flags of the context
|
||||
uint32_t traps() const
|
||||
{ return m_data.traps; }
|
||||
|
||||
|
||||
// MODIFIERS
|
||||
//! Get decContext member
|
||||
decContext* data()
|
||||
{ return &m_data; }
|
||||
|
||||
//! Set clamp flag of the context (IEEE exponent clamp)
|
||||
void setClamp(uint32_t clamp)
|
||||
{ m_data.clamp = clamp; }
|
||||
|
||||
//! Set digits field of the context (working precision)
|
||||
void setDigits(int32_t digits)
|
||||
{ m_data.digits = digits; }
|
||||
|
||||
//! Set emax field of the context (maximum positive exponent)
|
||||
void setEmax(int32_t emax)
|
||||
{ m_data.emax = emax; }
|
||||
|
||||
//! Set emin field of the context (minimum negative exponent)
|
||||
void setEmin(int32_t emin)
|
||||
{ m_data.emin = emin; }
|
||||
|
||||
//! Set extended flag of the context (special values)
|
||||
void setExtended(uint8_t ext);
|
||||
|
||||
//! This function is used to return the round (rounding mode) field
|
||||
//! of a decContext.
|
||||
void setRound(Rounding_e round)
|
||||
{ m_data.round = round; }
|
||||
|
||||
void setTraps(uint32_t traps)
|
||||
{ m_data.traps = traps; }
|
||||
|
||||
/*!
|
||||
This function is used to set one or more status bits in the status
|
||||
field of a decContext. If any of the bits being set have the
|
||||
corresponding bit set in the traps field, a trap is raised
|
||||
(regardless of whether the bit is already set in the status field).
|
||||
Only one trap is raised even if more than one bit is being set.
|
||||
*/
|
||||
void setStatus(uint32_t status = 0)
|
||||
{ m_data.status = status; }
|
||||
|
||||
//! This function is identical to setStatus except that
|
||||
//! the context traps field is ignored (i.e., no trap is raised).
|
||||
void setStatusQuiet(uint32_t status = 0)
|
||||
{ decContextSetStatusQuiet(&m_data, status); }
|
||||
|
||||
// ROUTINES
|
||||
//! This function is used to clear (set to zero) one or more status
|
||||
//! bits in the status field of a decContext.
|
||||
QDecContext& clearStatus(uint32_t status)
|
||||
{ decContextClearStatus(&m_data, status); return *this; }
|
||||
|
||||
//! This function is used to restore one or more status bits in
|
||||
//! the status field of a decContext from a saved status field.
|
||||
QDecContext& restoreStatus(uint32_t status, uint32_t mask)
|
||||
{ decContextRestoreStatus(&m_data, status, mask); return *this; }
|
||||
|
||||
/*!
|
||||
This function is used to initialize a decContext structure to
|
||||
default values. It is stongly recommended that this function always
|
||||
be used to initialize a decContext structure, even if most or all
|
||||
of the fields are to be set explicitly (in case new fields are added
|
||||
to a later version of the structure).
|
||||
*/
|
||||
QDecContext& setDefault(int32_t kind = QDecContextDefKind)
|
||||
{ decContextDefault(&m_data, kind); return *this; }
|
||||
|
||||
//! This function is used to save one or more status bits from
|
||||
//! the status field of a decContext.
|
||||
uint32_t saveStatus(uint32_t mask)
|
||||
{ return decContextSaveStatus(&m_data, mask); }
|
||||
|
||||
/*!
|
||||
This function is used to set a status bit in the status field of a
|
||||
decContext, using the name of the bit as returned by the
|
||||
decContextStatusToString function. If the bit being set has the
|
||||
corresponding bit set in the traps field, a trap is raised
|
||||
(regardless of whether the bit is already set in the status field).
|
||||
*/
|
||||
QDecContext& setStatusFromString(const char* str)
|
||||
{ decContextSetStatusFromString(&m_data, str); return *this; }
|
||||
|
||||
//! This function is identical to setStatusFromString except
|
||||
//! that the context traps field is ignored (i.e., no trap is raised).
|
||||
QDecContext& setStatusFromStringQuiet(const char* str)
|
||||
{ decContextSetStatusFromStringQuiet(&m_data, str); return *this; }
|
||||
|
||||
//! This function returns a pointer (char *) to a human-readable
|
||||
//! description of a status bit. The string pointed to will be a constant.
|
||||
const char* statusToString() const
|
||||
{ return decContextStatusToString(&m_data); }
|
||||
|
||||
//! This function is used to test one or more status bits in a context.
|
||||
uint32_t testStatus(uint32_t mask) //const
|
||||
{ return decContextTestStatus(&m_data, mask); }
|
||||
|
||||
//! This function is used to clear (set to zero) all the
|
||||
//! status bits in the status field of a decContext.
|
||||
QDecContext& zeroStatus()
|
||||
{ decContextZeroStatus(&m_data); return *this; }
|
||||
|
||||
|
||||
// UTILITY ROUTINES
|
||||
//! Get status flags (fields) in string form
|
||||
//! separated by | character
|
||||
QByteArray statusFlags() const;
|
||||
|
||||
//! Throw exception if status flags are set.
|
||||
void throwOnError() const
|
||||
{ if(m_data.status) throw(statusToString()); }
|
||||
|
||||
//! Type conversion operator to decContext*
|
||||
operator decContextPtr_t() { return &m_data; }
|
||||
|
||||
|
||||
// STATIC FUNCTIONS
|
||||
//! This function checks that the DECLITEND tuning
|
||||
//! parameter is set correctly.
|
||||
//! Returns 0 if the DECLITEND parameter is correct,
|
||||
//! 1 if it is incorrect and should be set to 1, and
|
||||
//! -1 if it is incorrect and should be set to 0.
|
||||
static int TestEndian()
|
||||
{ return decContextTestEndian(1 /*Quiet*/); }
|
||||
|
||||
//! This function is used to test one or more status
|
||||
//! bits in a saved status field.
|
||||
static uint32_t TestSavedStatus(uint32_t status, uint32_t mask)
|
||||
{ return decContextTestSavedStatus(status, mask); }
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
/*!
|
||||
QTextStream inserter to pretty-print QDecContext objects
|
||||
in the debug stream.
|
||||
*/
|
||||
QDECIMAL_EXPORT
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecContext);
|
||||
|
||||
|
||||
//! Convience macro to extract decContext structure or
|
||||
//! create one on stack to comply with callee signature.
|
||||
#define CXT(cptr) ( cptr ? cptr->data() : QDecContext().data() )
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,116 @@
|
||||
/** \file QDecDouble.cc
|
||||
* Definitions for the class QDecDouble.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecDouble.hh"
|
||||
extern "C" {
|
||||
#include "decimal64.h"
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include <QTextStream>
|
||||
#include "QDecNumber.hh"
|
||||
#include "QDecPacked.hh"
|
||||
#include "QDecSingle.hh"
|
||||
#include "QDecQuad.hh"
|
||||
|
||||
|
||||
QDecDouble& QDecDouble::fromDouble(double d)
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
_snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#else
|
||||
snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#endif
|
||||
|
||||
return fromString(str);
|
||||
}
|
||||
|
||||
QDecDouble& QDecDouble::fromHexString(const char* str)
|
||||
{
|
||||
QByteArray ba = QByteArray::fromHex(str);
|
||||
int size = sizeof(m_data);
|
||||
char* p = (char*)&m_data;
|
||||
int i = 0;
|
||||
int j = size-1;
|
||||
for(; i<size; i++,j--)
|
||||
p[j] = ba.at(i);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& QDecDouble::fromQDecSingle(const QDecSingle& s)
|
||||
{
|
||||
decSingleToWider(s.data(), &m_data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& QDecDouble::fromQDecNumber(const QDecNumber& n, QDecContext* c)
|
||||
{
|
||||
decDoubleFromNumber(&m_data, n.data(), CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& QDecDouble::fromQDecPacked(const QDecPacked& p)
|
||||
{
|
||||
fromQDecNumber(p.toQDecNumber());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& QDecDouble::fromWider(const QDecQuad& q, QDecContext* c)
|
||||
{
|
||||
decDoubleFromWider(&m_data, q.data(), CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
double QDecDouble::toDouble() const
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
decDoubleToString(&m_data, str);
|
||||
return strtod(str, 0);
|
||||
}
|
||||
|
||||
QDecSingle QDecDouble::toQDecSingle(QDecContext* c) const
|
||||
{
|
||||
decSingle s;
|
||||
return decSingleFromWider(&s, &m_data, CXT(c));
|
||||
}
|
||||
|
||||
QDecQuad QDecDouble::toQDecQuad() const
|
||||
{
|
||||
decQuad q;
|
||||
return decDoubleToWider(&m_data, &q);
|
||||
}
|
||||
|
||||
QDecPacked QDecDouble::toQDecPacked() const
|
||||
{
|
||||
return QDecPacked(toQDecNumber());
|
||||
}
|
||||
|
||||
QDecNumber QDecDouble::toQDecNumber() const
|
||||
{
|
||||
decNumber n;
|
||||
return decDoubleToNumber(&m_data, &n);
|
||||
}
|
||||
|
||||
QDecQuad QDecDouble::toWider() const
|
||||
{
|
||||
decQuad q;
|
||||
return decDoubleToWider(&m_data, &q);
|
||||
}
|
||||
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecDouble& d)
|
||||
{
|
||||
ts << d.toString();
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,454 @@
|
||||
#ifndef QDECDOUBLE_HH
|
||||
#define QDECDOUBLE_HH
|
||||
|
||||
/** \file QDecDouble.hh
|
||||
* Declarations for the class QDecDouble.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "QDecFwd.hh"
|
||||
#include "QDecContext.hh"
|
||||
extern "C" {
|
||||
#include "decDouble.h"
|
||||
}
|
||||
|
||||
// FORWARDS
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextStream;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecDouble
|
||||
QDecDouble encapsulates decDouble and provides decNumber library
|
||||
functions that operates upon decSingle as member functions with the same name.
|
||||
decimal64 is a 64-bit decimal floating-point representation which
|
||||
provides 16 decimal digits of precision in a compressed format.
|
||||
decDouble module provides the functions for the decimal64 format;
|
||||
this format is an IEEE 754 basic format and so a full set of arithmetic
|
||||
and other functions is included.
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecDouble
|
||||
{
|
||||
// MEMBERS
|
||||
//! Embedded decDouble structure
|
||||
decDouble m_data;
|
||||
|
||||
public:
|
||||
// TYPES
|
||||
typedef decDouble* decDoublePtr_t;
|
||||
enum {
|
||||
MaxStrSize = QDECMAXSTRSIZE
|
||||
};
|
||||
|
||||
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecDouble() { decDoubleZero(&m_data); }
|
||||
|
||||
// Default Dtor and Copy Ctor are ok
|
||||
|
||||
// Constructors using decDouble structure
|
||||
QDecDouble(decDouble d) : m_data(d) {}
|
||||
QDecDouble(const decDouble* p) : m_data(*p) {}
|
||||
|
||||
// Conversion constructors using simple types
|
||||
QDecDouble(const char* str) { fromString(str); }
|
||||
QDecDouble(int32_t i) { fromInt32(i); }
|
||||
QDecDouble(uint32_t i) { fromUInt32(i); }
|
||||
QDecDouble(double d) { fromDouble(d); }
|
||||
|
||||
|
||||
// Conversion constructors using composite types
|
||||
QDecDouble(const QDecQuad& q) { fromQDecQuad(q); }
|
||||
QDecDouble(const QDecSingle& s) { fromQDecSingle(s); }
|
||||
QDecDouble(const QDecPacked& p) { fromQDecPacked(p); }
|
||||
QDecDouble(const QDecNumber& n) { fromQDecNumber(n); }
|
||||
|
||||
|
||||
//! Copy assignment
|
||||
QDecDouble& operator=(const QDecDouble& o)
|
||||
{ return (this != &o ? copy(o) : *this); }
|
||||
|
||||
//! Conversion operator to decDouble*
|
||||
operator decDoublePtr_t() { return &m_data; }
|
||||
|
||||
|
||||
// ACCESSORS
|
||||
const decDouble* data() const
|
||||
{ return &m_data; }
|
||||
|
||||
// MODIFIERS
|
||||
decDouble* data()
|
||||
{ return &m_data; }
|
||||
|
||||
// UTILITIES & CONVERSIONS
|
||||
QDecDouble& fromBCD(int32_t exp, const QByteArray& bcd, int32_t sign) {
|
||||
decDoubleFromBCD(&m_data, exp, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& fromDouble(double d);
|
||||
|
||||
QDecDouble& fromInt32(int32_t i)
|
||||
{ decDoubleFromInt32(&m_data, i); return *this; }
|
||||
|
||||
QDecDouble& fromPacked(int32_t exp, const QByteArray& pack) {
|
||||
decDoubleFromPacked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& fromPackedChecked(int32_t exp, const QByteArray& pack) {
|
||||
decDoubleFromPackedChecked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& fromString(const char* str, QDecContext* c = 0)
|
||||
{ decDoubleFromString(&m_data, str, CXT(c)); return *this; }
|
||||
|
||||
//! Hexadecimal string in network byte order
|
||||
QDecDouble& fromHexString(const char* str);
|
||||
|
||||
QDecDouble& fromQDecSingle(const QDecSingle& s);
|
||||
|
||||
QDecDouble& fromQDecQuad(const QDecQuad& q, QDecContext* c = 0)
|
||||
{ return fromWider(q, c); }
|
||||
|
||||
QDecDouble& fromQDecNumber(const QDecNumber& n, QDecContext* c = 0);
|
||||
|
||||
QDecDouble& fromQDecPacked(const QDecPacked& p);
|
||||
|
||||
QDecDouble& fromUInt32(uint32_t i)
|
||||
{ decDoubleFromUInt32(&m_data, i); return *this; }
|
||||
|
||||
QDecDouble& fromWider(const QDecQuad& q, QDecContext* c = 0);
|
||||
|
||||
int32_t getCoefficient(QByteArray& bcd) const {
|
||||
bcd.resize(DECDOUBLE_Pmax);
|
||||
return decDoubleGetCoefficient(&m_data, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
QDecDouble& setCoefficient(const QByteArray& bcd, int32_t sign) {
|
||||
decDoubleSetCoefficient(&m_data, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecDouble& setExponent(int32_t exp, QDecContext* c = 0 ) {
|
||||
decDoubleSetExponent(&m_data, CXT(c), exp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int32_t toBCD(int32_t& exp, QByteArray& bcd) {
|
||||
bcd.resize(DECDOUBLE_Pmax);
|
||||
return decDoubleToBCD(&m_data, &exp, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
double toDouble() const;
|
||||
|
||||
QByteArray toEngString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decDoubleToEngString(&m_data, str);
|
||||
}
|
||||
|
||||
int32_t toPacked(int32_t& exp, QByteArray& pack) {
|
||||
pack.resize(DECDOUBLE_Pmax);
|
||||
return decDoubleToPacked(&m_data, &exp, (uint8_t*)pack.data());
|
||||
}
|
||||
|
||||
QByteArray toString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decDoubleToString(&m_data, str);
|
||||
}
|
||||
|
||||
QDecSingle toQDecSingle(QDecContext* c = 0) const;
|
||||
|
||||
QDecQuad toQDecQuad() const;
|
||||
|
||||
QDecPacked toQDecPacked() const;
|
||||
|
||||
QDecNumber toQDecNumber() const;
|
||||
|
||||
QDecQuad toWider() const;
|
||||
|
||||
QDecDouble& zero()
|
||||
{ decDoubleZero(&m_data); return *this; }
|
||||
|
||||
|
||||
// COMPUTATIONAL
|
||||
//! Returns the absolute value
|
||||
QDecDouble abs(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleAbs(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble add(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleAdd(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble digitAnd(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleAnd(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble divide(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleDivide(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble divideInteger(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleDivideInteger(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble fma(const QDecDouble& o, const QDecDouble& o2,
|
||||
QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleFMA(&d, &m_data, &o.m_data, &o2.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble invert(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleInvert(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble logB(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleLogB(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble max(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleMax(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble maxMag(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleMaxMag(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble minus(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleMinus(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble multiply(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleMultiply(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble nextMinus(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleNextMinus(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble nextPlus(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleNextPlus(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble nextToward(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleNextToward(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble digitOr(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleOr(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble plus(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoublePlus(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble quantize(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleQuantize(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble reduce(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleReduce(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble remainder(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleRemainder(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble remainderNear(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleRemainderNear(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble rotate(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleRotate(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble scaleB(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleScaleB(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble shift(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleShift(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble subtract(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleSubtract(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble toIntegralValue(enum rounding r, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleToIntegralValue(&d, &m_data, CXT(c), r); }
|
||||
|
||||
QDecDouble toIntegralExact(QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleToIntegralExact(&d, &m_data, CXT(c)); }
|
||||
|
||||
QDecDouble digitXor(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleXor(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
|
||||
// COMPARISONS
|
||||
QDecDouble compare(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleCompare(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble compareSignal(const QDecDouble& o, QDecContext* c = 0) const
|
||||
{ decDouble d; return decDoubleCompareSignal(&d, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecDouble compareTotal(const QDecDouble& o) const
|
||||
{ decDouble d; return decDoubleCompareTotal(&d, &m_data, &o.m_data); }
|
||||
|
||||
QDecDouble compareTotalMag(const QDecDouble& o) const
|
||||
{ decDouble d; return decDoubleCompareTotalMag(&d, &m_data, &o.m_data); }
|
||||
|
||||
|
||||
// COPIES
|
||||
QDecDouble& canonical(const QDecDouble& d)
|
||||
{ decDoubleCanonical(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecDouble& copy(const QDecDouble& d)
|
||||
{ decDoubleCopy(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecDouble& copyAbs(const QDecDouble& d)
|
||||
{ decDoubleCopyAbs(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecDouble& copyNegate(const QDecDouble& d)
|
||||
{ decDoubleCopyNegate(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecDouble& copySign(const QDecDouble& d, const QDecDouble& sd)
|
||||
{ decDoubleCopySign(&m_data, &d.m_data, &sd.m_data); return *this; }
|
||||
|
||||
|
||||
// NON-COMPUTATIONAL
|
||||
// "class" is a reserved word in C++
|
||||
enum decClass classification() const
|
||||
{ return decDoubleClass(&m_data); }
|
||||
|
||||
const char* classString() const
|
||||
{ return decDoubleClassString(&m_data); }
|
||||
|
||||
uint32_t digits() const
|
||||
{ return decDoubleDigits(&m_data); }
|
||||
|
||||
bool isCanonical() const
|
||||
{ return decDoubleIsCanonical(&m_data); }
|
||||
|
||||
bool isFinite() const
|
||||
{ return decDoubleIsFinite(&m_data); }
|
||||
|
||||
bool isInteger() const
|
||||
{ return decDoubleIsInteger(&m_data); }
|
||||
|
||||
bool isLogical() const
|
||||
{ return decDoubleIsLogical(&m_data); }
|
||||
|
||||
bool isInfinite() const
|
||||
{ return decDoubleIsInfinite(&m_data); }
|
||||
|
||||
bool isNaN() const
|
||||
{ return decDoubleIsNaN(&m_data); }
|
||||
|
||||
bool isNegative() const
|
||||
{ return decDoubleIsNegative(&m_data); }
|
||||
|
||||
bool isNormal() const
|
||||
{ return decDoubleIsNormal(&m_data); }
|
||||
|
||||
bool isPositive() const
|
||||
{ return decDoubleIsPositive(&m_data); }
|
||||
|
||||
bool isSignaling() const
|
||||
{ return decDoubleIsSignaling(&m_data); }
|
||||
|
||||
bool isSignalling() const
|
||||
{ return decDoubleIsSignalling(&m_data); }
|
||||
|
||||
bool isSigned() const
|
||||
{ return decDoubleIsSigned(&m_data); }
|
||||
|
||||
bool isSubnormal() const
|
||||
{ return decDoubleIsSubnormal(&m_data); }
|
||||
|
||||
bool isZero() const
|
||||
{ return decDoubleIsZero(&m_data); }
|
||||
|
||||
uint32_t radix() const
|
||||
{ return decDoubleRadix(&m_data); }
|
||||
|
||||
const char* version() const
|
||||
{ return decDoubleVersion(); }
|
||||
|
||||
|
||||
// RELATIONAL AND LOGICAL OPERATORS
|
||||
bool operator==(const QDecDouble& o) const
|
||||
{ return compare(o).isZero(); }
|
||||
|
||||
bool operator!=(const QDecDouble& o) const
|
||||
{ return !(this->operator==(o)); }
|
||||
|
||||
bool operator<(const QDecDouble& o) const
|
||||
{ return compare(o).isNegative(); }
|
||||
|
||||
bool operator<=(const QDecDouble& o) const
|
||||
{
|
||||
const QDecDouble& r = compare(o);
|
||||
return r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
bool operator>(const QDecDouble& o) const
|
||||
{ return !(this->operator<=(o)); }
|
||||
|
||||
bool operator>=(const QDecDouble& o) const
|
||||
{
|
||||
const QDecDouble& r = compare(o);
|
||||
return !r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
// BITWISE OPERATORS
|
||||
QDecDouble operator&(const QDecDouble& o) const
|
||||
{ return digitAnd(o); }
|
||||
|
||||
QDecDouble operator|(const QDecDouble& o) const
|
||||
{ return digitOr(o); }
|
||||
|
||||
QDecDouble operator^(const QDecDouble& o) const
|
||||
{ return digitXor(o); }
|
||||
|
||||
|
||||
// ARITHMETIC OPERATORS
|
||||
QDecDouble operator+(const QDecDouble& o) const
|
||||
{ return add(o); }
|
||||
|
||||
QDecDouble operator-(const QDecDouble& o) const
|
||||
{ return subtract(o); }
|
||||
|
||||
QDecDouble operator*(const QDecDouble& o) const
|
||||
{ return multiply(o); }
|
||||
|
||||
QDecDouble operator/(const QDecDouble& o) const
|
||||
{ return divide(o); }
|
||||
|
||||
QDecDouble operator%(const QDecDouble& o) const
|
||||
{ return remainder(o); }
|
||||
|
||||
|
||||
// COMPOUND ASSIGNMENT OPERATORS
|
||||
QDecDouble& operator+=(const QDecDouble& o)
|
||||
{ return copy(add(o)); }
|
||||
|
||||
QDecDouble& operator-=(const QDecDouble& o)
|
||||
{ return copy(subtract(o)); }
|
||||
|
||||
QDecDouble& operator*=(const QDecDouble& o)
|
||||
{ return copy(multiply(o)); }
|
||||
|
||||
QDecDouble& operator/=(const QDecDouble& o)
|
||||
{ return copy(divide(o)); }
|
||||
|
||||
QDecDouble& operator%=(const QDecDouble& o)
|
||||
{ return copy(remainder(o)); }
|
||||
|
||||
QDecDouble& operator&=(const QDecDouble& o)
|
||||
{ return copy(digitAnd(o)); }
|
||||
|
||||
QDecDouble& operator|=(const QDecDouble& o)
|
||||
{ return copy(digitOr(o)); }
|
||||
|
||||
QDecDouble& operator^=(const QDecDouble& o)
|
||||
{ return copy(digitXor(o)); }
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QDecDouble);
|
||||
|
||||
|
||||
QDECIMAL_EXPORT
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecDouble& d);
|
||||
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,79 @@
|
||||
#ifndef QDECFWD_HH
|
||||
#define QDECFWD_HH
|
||||
|
||||
/** \file QDecFwd.hh
|
||||
* Forward declarations for QDecimal types
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#ifndef DECNUMDIGITS
|
||||
//! Work with up to 80 digits as default, resulting in 64 bytes
|
||||
//! decNumber structure.
|
||||
# define DECNUMDIGITS 80
|
||||
#endif
|
||||
|
||||
//! Digits of decimal precision for QDecNumber, decNumber.
|
||||
//! This is set at compile time via DECNUMDIGITS macro.
|
||||
const int QDecNumDigits = DECNUMDIGITS;
|
||||
|
||||
//! Digits of decimal precision for QDecSingle, decSingle, decimal32
|
||||
const int QDecSingleDigits = 7;
|
||||
|
||||
//! Digits of decimal precision for QDecDouble, decDouble, decimal64
|
||||
const int QDecDoubleDigits = 16;
|
||||
|
||||
//! Digits of decimal precision for QDecQuad, decQuad, decimal128
|
||||
const int QDecQuadDigits = 34;
|
||||
|
||||
#ifndef QDECMAXSTRSIZE
|
||||
//! Maximum length of a conversion string
|
||||
# define QDECMAXSTRSIZE 512
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" {
|
||||
#if !defined(int32_t)
|
||||
#if defined(_MSC_VER)
|
||||
/* MS Visual C */
|
||||
#include <VCpp_stdint.h>
|
||||
#else
|
||||
/* C99 standard integers */
|
||||
#include <stdint.h>
|
||||
/* For unknown compilers, you can use portable stdint.h */
|
||||
//include <Port_stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "decContext.h"
|
||||
#include "decNumber.h"
|
||||
}
|
||||
|
||||
// Prepare for shared library usage.
|
||||
// See Q_DEC_EXPORT from Qt documentation for details.
|
||||
|
||||
#ifdef QDECIMAL_SHARED
|
||||
# if(QDECIMAL_SHARED > 1)
|
||||
# define QDECIMAL_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define QDECIMAL_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define QDECIMAL_EXPORT /* no-op */
|
||||
#endif
|
||||
|
||||
class QDECIMAL_EXPORT QDecContext;
|
||||
class QDECIMAL_EXPORT QDecNumber;
|
||||
class QDECIMAL_EXPORT QDecPacked;
|
||||
class QDECIMAL_EXPORT QDecSingle;
|
||||
class QDECIMAL_EXPORT QDecDouble;
|
||||
class QDECIMAL_EXPORT QDecQuad;
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,67 @@
|
||||
/** \file QDecNumber.cc
|
||||
* Definitions for the class QDecNumber.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecNumber.hh"
|
||||
#include <stdlib.h>
|
||||
#include <QTextStream>
|
||||
#include "QDecSingle.hh"
|
||||
#include "QDecDouble.hh"
|
||||
#include "QDecQuad.hh"
|
||||
#include "QDecPacked.hh"
|
||||
extern "C" {
|
||||
#include "decimal32.h"
|
||||
#include "decimal64.h"
|
||||
#include "decimal128.h"
|
||||
}
|
||||
|
||||
|
||||
|
||||
QDecNumber::QDecNumber(const QDecSingle& s)
|
||||
{ decSingleToNumber(s.data(), &m_data); }
|
||||
|
||||
QDecNumber::QDecNumber(const QDecDouble& d)
|
||||
{ decDoubleToNumber(d.data(), &m_data); }
|
||||
|
||||
QDecNumber::QDecNumber(const QDecQuad& q)
|
||||
{ decQuadToNumber(q.data(), &m_data); }
|
||||
|
||||
QDecNumber::QDecNumber(const QDecPacked& p)
|
||||
{ *this = p.toQDecNumber(); }
|
||||
|
||||
|
||||
QDecNumber& QDecNumber::fromDouble(double d)
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
_snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#else
|
||||
snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#endif
|
||||
return fromString(str);
|
||||
}
|
||||
|
||||
|
||||
double QDecNumber::toDouble() const
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
|
||||
decNumberToString(&m_data, str);
|
||||
return strtod(str, 0);
|
||||
}
|
||||
|
||||
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecNumber& n)
|
||||
{
|
||||
ts << n.toString();
|
||||
return ts;
|
||||
}
|
||||
|
@ -0,0 +1,433 @@
|
||||
#ifndef QDECNUMBER_HH
|
||||
#define QDECNUMBER_HH
|
||||
|
||||
/** \file QDecNumber.hh
|
||||
* Declarations for the class QDecNumber.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "QDecFwd.hh"
|
||||
#include "QDecContext.hh"
|
||||
|
||||
// FORWARDS
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextStream;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecNumber
|
||||
QDecNumber encapsulates decNumber and reimplements global functions
|
||||
that operates upon decNumber as member functions with the same name.
|
||||
decNumber module uses an arbitrary-precision decimal number representation
|
||||
designed for efficient computation in software and implements the
|
||||
arithmetic and logical operations, together with a number of conversions
|
||||
and utilities. Once a number is held as a decNumber, no further conversions
|
||||
are necessary to carry out arithmetic.
|
||||
The decNumber representation is variable-length and machine-dependent
|
||||
(for example, it contains integers which may be big-endian or little-endian).
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecNumber
|
||||
{
|
||||
// MEMBERS
|
||||
//! Embedded decNumber structure
|
||||
decNumber m_data;
|
||||
|
||||
public:
|
||||
// TYPES
|
||||
typedef decNumber* decNumberPtr_t;
|
||||
enum {
|
||||
MaxStrSize = QDECMAXSTRSIZE
|
||||
};
|
||||
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecNumber() { decNumberZero(&m_data); }
|
||||
|
||||
// Constructors using decNumber structure
|
||||
QDecNumber(const decNumber& d) : m_data(d) {}
|
||||
QDecNumber(const decNumber* p) : m_data(*p) {}
|
||||
|
||||
// Conversion constructors using simple types
|
||||
QDecNumber(const char* str) { fromString(str); }
|
||||
// m_data must have space for the digits needed to represent
|
||||
// the value of val, which may need up to ten digits.
|
||||
QDecNumber(uint32_t val) { fromUInt32(val); }
|
||||
QDecNumber(int32_t val) { fromInt32(val); }
|
||||
QDecNumber(double d) { fromDouble(d); }
|
||||
|
||||
// Conversion constructors using composite types
|
||||
QDecNumber(const QDecSingle& s);
|
||||
QDecNumber(const QDecDouble& d);
|
||||
QDecNumber(const QDecQuad& q);
|
||||
QDecNumber(const QDecPacked& p);
|
||||
|
||||
//! Copy constructor
|
||||
QDecNumber(const QDecNumber& o)
|
||||
{ decNumberCopy(&m_data, &o.m_data); }
|
||||
|
||||
//! Copy assignment
|
||||
QDecNumber& operator=(const QDecNumber& o)
|
||||
{ if(this != &o) decNumberCopy(&m_data, &o.m_data); return *this; }
|
||||
|
||||
//! Type conversion operator to decNumber*
|
||||
operator decNumberPtr_t() { return &m_data; }
|
||||
|
||||
|
||||
// ACCESSORS
|
||||
const decNumber* data() const
|
||||
{ return &m_data; }
|
||||
|
||||
// MODIFIERS
|
||||
decNumber* data()
|
||||
{ return &m_data; }
|
||||
|
||||
|
||||
// CONVERSIONS
|
||||
QDecNumber& fromBCD(QByteArray& bcd) {
|
||||
decNumberSetBCD(&m_data, (const uint8_t*)bcd.data(), bcd.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecNumber& fromDouble(double d);
|
||||
|
||||
QDecNumber& fromInt32(int32_t val)
|
||||
{ decNumberFromInt32(&m_data, val); return *this; }
|
||||
|
||||
QDecNumber& fromUInt32(uint32_t val)
|
||||
{ decNumberFromUInt32(&m_data, val); return *this; }
|
||||
|
||||
QDecNumber& fromString(const char* str, QDecContext* c = 0)
|
||||
{ decNumberFromString(&m_data, str, CXT(c)); return *this; }
|
||||
|
||||
QByteArray toBCD() const {
|
||||
QByteArray bcd(m_data.digits+1, '\0');
|
||||
decNumberGetBCD(&m_data, (uint8_t*)bcd.data());
|
||||
return bcd;
|
||||
}
|
||||
|
||||
double toDouble() const;
|
||||
|
||||
QByteArray toEngString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decNumberToEngString(&m_data, str);
|
||||
}
|
||||
|
||||
QByteArray toString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decNumberToString(&m_data, str);
|
||||
}
|
||||
|
||||
int32_t toInt32(QDecContext* c = 0) const
|
||||
{ return decNumberToInt32(&m_data, CXT(c)); }
|
||||
|
||||
uint32_t toUInt32(QDecContext* c = 0) const
|
||||
{ return decNumberToUInt32(&m_data, CXT(c)); }
|
||||
|
||||
|
||||
// COMPUTATIONAL FUNCTIONS
|
||||
QDecNumber abs(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberAbs(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber add(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberAdd(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber digitAnd(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberAnd(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber compare(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberCompare(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber compareSignal(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberCompareSignal(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber compareTotal(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberCompareTotal(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber compareTotalMag(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberCompareTotalMag(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber divide(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberDivide(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber divideInteger(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberDivideInteger(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber exp(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberExp(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber fma(const QDecNumber& mo, const QDecNumber& ao,
|
||||
QDecContext* c = 0) const {
|
||||
decNumber n;
|
||||
return decNumberFMA(&n, &m_data, &mo.m_data, &ao.m_data, CXT(c));
|
||||
}
|
||||
|
||||
QDecNumber invert(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberInvert(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber ln(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberLn(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber logB(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberLogB(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber log10(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberLog10(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber max(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMax(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber maxMag(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMaxMag(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber min(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMin(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber minMag(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMinMag(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber minus(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMinus(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber multiply(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberMultiply(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber nextMinus(QDecContext* c = 0)
|
||||
{ decNumber n; return decNumberNextMinus(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber nextPlus(QDecContext* c = 0)
|
||||
{ decNumber n; return decNumberNextPlus(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber nextToward(const QDecNumber& o, QDecContext* c = 0)
|
||||
{ decNumber n; return decNumberNextToward(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber normalize(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberNormalize(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber digitOr(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberOr(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber plus(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberPlus(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber power(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberPower(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber quantize(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberQuantize(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber reduce(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberReduce(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber remainder(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberRemainder(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber remainderNear(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberRemainderNear(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber rescale(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberRescale(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber rotate(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberRotate(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
bool sameQuantum(const QDecNumber& o) const {
|
||||
decNumber n;
|
||||
QDecNumber r = decNumberSameQuantum(&n, data(), o.data());
|
||||
return !r.isZero();
|
||||
}
|
||||
|
||||
QDecNumber scaleB(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberScaleB(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber shift(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberShift(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber squareRoot(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberSquareRoot(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber subtract(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberSubtract(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecNumber toIntegralExact(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberToIntegralExact(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber toIntegralValue(QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberToIntegralValue(&n, &m_data, CXT(c)); }
|
||||
|
||||
QDecNumber digitXor(const QDecNumber& o, QDecContext* c = 0) const
|
||||
{ decNumber n; return decNumberXor(&n, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
|
||||
// TESTING FUNCTIONS
|
||||
bool isCanonical() const
|
||||
{ return decNumberIsCanonical(&m_data); }
|
||||
|
||||
bool isFinite() const
|
||||
{ return decNumberIsFinite(&m_data); }
|
||||
|
||||
bool isInfinite() const
|
||||
{ return decNumberIsInfinite(&m_data); }
|
||||
|
||||
bool isNaN() const
|
||||
{ return decNumberIsNaN(&m_data); }
|
||||
|
||||
bool isNegative() const
|
||||
{ return decNumberIsNegative(&m_data); }
|
||||
|
||||
bool isQNaN() const
|
||||
{ return decNumberIsQNaN(&m_data); }
|
||||
|
||||
bool isSNaN() const
|
||||
{ return decNumberIsSNaN(&m_data); }
|
||||
|
||||
bool isSpecial() const
|
||||
{ return decNumberIsSpecial(&m_data); }
|
||||
|
||||
bool isZero() const
|
||||
{ return decNumberIsZero(&m_data); }
|
||||
|
||||
|
||||
// TEST FUNCTIONS (CONTEXT DEPENDENT)
|
||||
bool isNormal(QDecContext* c = 0) const
|
||||
{ return decNumberIsNormal(&m_data, CXT(c)); }
|
||||
|
||||
bool isSubnormal(QDecContext* c = 0) const
|
||||
{ return decNumberIsSubnormal(&m_data, CXT(c)); }
|
||||
|
||||
|
||||
|
||||
// UTILITIES
|
||||
enum decClass toClass(QDecContext* c = 0) const
|
||||
{ return decNumberClass(&m_data, CXT(c)); }
|
||||
|
||||
QDecNumber& copy(const QDecNumber& o)
|
||||
{ decNumberCopy(&m_data, &o.m_data); return *this; }
|
||||
|
||||
QDecNumber& copyAbs(const QDecNumber& o)
|
||||
{ decNumberCopyAbs(&m_data, &o.m_data); return *this; }
|
||||
|
||||
QDecNumber& copyNegate(const QDecNumber& o)
|
||||
{ decNumberCopyNegate(&m_data, &o.m_data); return *this; }
|
||||
|
||||
QDecNumber& copySign(const QDecNumber& o, const QDecNumber& so)
|
||||
{ decNumberCopySign(&m_data, &o.m_data, &so.m_data); return *this; }
|
||||
|
||||
uint32_t radix() const
|
||||
{ return decNumberRadix(&m_data); }
|
||||
|
||||
QDecNumber& trim()
|
||||
{ decNumberTrim(&m_data); return *this; }
|
||||
|
||||
const char* version() const
|
||||
{ return decNumberVersion(); }
|
||||
|
||||
QDecNumber& zero()
|
||||
{ decNumberZero(&m_data); return *this; }
|
||||
|
||||
|
||||
// STATIC FUNCTIONS (UTILITIES)
|
||||
static const char* ClassToString(enum decClass dc)
|
||||
{ return decNumberClassToString(dc); }
|
||||
|
||||
static const char* Version()
|
||||
{ return decNumberVersion(); }
|
||||
|
||||
|
||||
// RELATIONAL AND LOGICAL OPERATORS
|
||||
bool operator==(const QDecNumber& o) const
|
||||
{ return compare(o).isZero(); }
|
||||
|
||||
bool operator!=(const QDecNumber& o) const
|
||||
{ return !(this->operator==(o)); }
|
||||
|
||||
bool operator<(const QDecNumber& o) const
|
||||
{ return compare(o).isNegative(); }
|
||||
|
||||
bool operator<=(const QDecNumber& o) const
|
||||
{
|
||||
const QDecNumber& r = compare(o);
|
||||
return r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
bool operator>(const QDecNumber& o) const
|
||||
{ return !(this->operator<=(o)); }
|
||||
|
||||
bool operator>=(const QDecNumber& o) const
|
||||
{
|
||||
const QDecNumber& r = compare(o);
|
||||
return !r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
// BITWISE OPERATORS
|
||||
QDecNumber operator&(const QDecNumber& o) const
|
||||
{ return digitAnd(o); }
|
||||
|
||||
QDecNumber operator|(const QDecNumber& o) const
|
||||
{ return digitOr(o); }
|
||||
|
||||
QDecNumber operator^(const QDecNumber& o) const
|
||||
{ return digitXor(o); }
|
||||
|
||||
|
||||
// ARITHMETIC OPERATORS
|
||||
QDecNumber operator+(const QDecNumber& o) const
|
||||
{ return add(o); }
|
||||
|
||||
QDecNumber operator-(const QDecNumber& o) const
|
||||
{ return subtract(o); }
|
||||
|
||||
QDecNumber operator*(const QDecNumber& o) const
|
||||
{ return multiply(o); }
|
||||
|
||||
QDecNumber operator/(const QDecNumber& o) const
|
||||
{ return divide(o); }
|
||||
|
||||
QDecNumber operator%(const QDecNumber& o) const
|
||||
{ return remainder(o); }
|
||||
|
||||
|
||||
// COMPOUND ASSIGNMENT OPERATORS
|
||||
QDecNumber& operator+=(const QDecNumber& o)
|
||||
{ return copy(add(o)); }
|
||||
|
||||
QDecNumber& operator-=(const QDecNumber& o)
|
||||
{ return copy(subtract(o)); }
|
||||
|
||||
QDecNumber& operator*=(const QDecNumber& o)
|
||||
{ return copy(multiply(o)); }
|
||||
|
||||
QDecNumber& operator/=(const QDecNumber& o)
|
||||
{ return copy(divide(o)); }
|
||||
|
||||
QDecNumber& operator%=(const QDecNumber& o)
|
||||
{ return copy(remainder(o)); }
|
||||
|
||||
QDecNumber& operator&=(const QDecNumber& o)
|
||||
{ return copy(digitAnd(o)); }
|
||||
|
||||
QDecNumber& operator|=(const QDecNumber& o)
|
||||
{ return copy(digitOr(o)); }
|
||||
|
||||
QDecNumber& operator^=(const QDecNumber& o)
|
||||
{ return copy(digitXor(o)); }
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QDecNumber);
|
||||
|
||||
QDECIMAL_EXPORT
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecNumber& n);
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,83 @@
|
||||
/** \file QDecPacked.cc
|
||||
* Definitions for the class QDecPacked.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecPacked.hh"
|
||||
#include "QDecNumber.hh"
|
||||
#include "QDecSingle.hh"
|
||||
#include "QDecDouble.hh"
|
||||
#include "QDecQuad.hh"
|
||||
|
||||
QDecPacked::QDecPacked(const char* str)
|
||||
{ *this = fromQDecNumber(QDecNumber(str)); }
|
||||
|
||||
QDecPacked::QDecPacked(double d)
|
||||
{ *this = fromQDecNumber(QDecNumber(d)); }
|
||||
|
||||
QDecPacked::QDecPacked(const QDecSingle& s)
|
||||
{ *this = s.toQDecPacked(); }
|
||||
|
||||
QDecPacked::QDecPacked(const QDecDouble& d)
|
||||
{ *this = d.toQDecPacked(); }
|
||||
|
||||
QDecPacked::QDecPacked(const QDecQuad& q)
|
||||
{ *this = q.toQDecPacked(); }
|
||||
|
||||
|
||||
QDecPacked& QDecPacked::fromQDecNumber(const QDecNumber& d)
|
||||
{
|
||||
uint8_t bfr[QDecNumDigits] = { 0 };
|
||||
int32_t scale = 0;
|
||||
|
||||
uint8_t* rv = decPackedFromNumber(bfr, QDecNumDigits, &scale, d.data());
|
||||
|
||||
if(rv) {
|
||||
m_scale = scale;
|
||||
|
||||
char* p = (char*)bfr;
|
||||
int i = 0;
|
||||
// Skip null bytes at the left
|
||||
for(; p[i] == '\0' || i==QDecNumDigits; ++i);
|
||||
|
||||
// Construct byte array from the beginning of BCD bytes
|
||||
m_bytes = QByteArray(&p[i], QDecNumDigits-i);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecNumber QDecPacked::toQDecNumber() const
|
||||
{
|
||||
if(length() > 0) {
|
||||
decNumber n;
|
||||
return decPackedToNumber(bytesRaw(), length(), &m_scale, &n);
|
||||
}
|
||||
else
|
||||
// Not initialized, return default QDecNumber value
|
||||
return QDecNumber();
|
||||
}
|
||||
|
||||
QDecPacked& QDecPacked::fromDouble(double d)
|
||||
{
|
||||
*this = fromQDecNumber(QDecNumber(d));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecPacked& QDecPacked::fromString(const char* str)
|
||||
{
|
||||
*this = fromQDecNumber(QDecNumber(str));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QByteArray QDecPacked::toString() const
|
||||
{
|
||||
return toQDecNumber().toString();
|
||||
}
|
||||
|
@ -0,0 +1,108 @@
|
||||
#ifndef QDECPACKED_HH
|
||||
#define QDECPACKED_HH
|
||||
|
||||
/** \file QDecPacked.hh
|
||||
* Declarations for the class QDecPacked.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
#include "QDecFwd.hh"
|
||||
extern "C" {
|
||||
#include "decPacked.h"
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecPacked
|
||||
QDecPacked augments decPacked by encapsulating reference counted byte
|
||||
array and scale of the decimal point as members variables, thus, freeing up
|
||||
user of this class from memory management and keeping track of scale value.
|
||||
The decPacked format is the classic packed decimal format implemented
|
||||
by IBM S/360 and later machines, where each digit is encoded as
|
||||
a 4-bit binary sequence (BCD) and a number is ended by a 4-bit
|
||||
sign indicator. The decPacked module accepts variable lengths,
|
||||
allowing for very large numbers (up to a billion digits), and also
|
||||
allows the specification of a scale.
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecPacked
|
||||
{
|
||||
// MEMBERS
|
||||
//! Byte array containing BCD sequence
|
||||
QByteArray m_bytes;
|
||||
//! Scale of the decimal number (point)
|
||||
int32_t m_scale;
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecPacked() : m_scale(0) {}
|
||||
QDecPacked(int32_t length, int32_t scale = 0)
|
||||
: m_bytes(length,'\0'), m_scale(scale) {}
|
||||
QDecPacked(const QByteArray& bytes, int32_t scale = 0)
|
||||
: m_bytes(bytes), m_scale(scale) {}
|
||||
|
||||
// Default copy constructor and destructor are ok to use
|
||||
|
||||
// Conversion constructors using simple types
|
||||
QDecPacked(const char* str);
|
||||
QDecPacked(double d);
|
||||
|
||||
// Conversion constructors using composite types
|
||||
QDecPacked(const QDecNumber& d) { fromQDecNumber(d); }
|
||||
QDecPacked(const QDecSingle& s);
|
||||
QDecPacked(const QDecDouble& d);
|
||||
QDecPacked(const QDecQuad& d);
|
||||
|
||||
// ACCESSORS
|
||||
const char* data() const
|
||||
{ return m_bytes.data(); }
|
||||
|
||||
QByteArray bytes() const
|
||||
{ return m_bytes; }
|
||||
|
||||
const uint8_t* bytesRaw() const
|
||||
{ return reinterpret_cast<const uint8_t*>(m_bytes.data()); }
|
||||
|
||||
int32_t length() const
|
||||
{ return m_bytes.size(); }
|
||||
|
||||
int32_t scale() const
|
||||
{ return m_scale; }
|
||||
|
||||
QByteArray toString() const;
|
||||
|
||||
|
||||
// MODIFIERS
|
||||
uint8_t* bytesRaw()
|
||||
{ return reinterpret_cast<uint8_t*>(m_bytes.data()); }
|
||||
|
||||
QDecPacked& fromDouble(double d);
|
||||
|
||||
QDecPacked& fromString(const char* str);
|
||||
|
||||
void setLength(int32_t length)
|
||||
{ m_bytes.resize(length); }
|
||||
|
||||
void setScale(int32_t scale)
|
||||
{ m_scale = scale; }
|
||||
|
||||
// CONVERSIONS
|
||||
QDecNumber toQDecNumber() const;
|
||||
QDecPacked& fromQDecNumber(const QDecNumber& d);
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,100 @@
|
||||
/** \file QDecQuad.cc
|
||||
* Definitions for the class QDecQuad.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id: QDecQuad.cc 111 2006-06-19 03:45:40Z semihc $
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecQuad.hh"
|
||||
extern "C" {
|
||||
#include "decimal128.h"
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include <QTextStream>
|
||||
#include "QDecNumber.hh"
|
||||
#include "QDecPacked.hh"
|
||||
#include "QDecDouble.hh"
|
||||
|
||||
|
||||
QDecQuad& QDecQuad::fromDouble(double d)
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
_snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#else
|
||||
snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#endif
|
||||
|
||||
return fromString(str);
|
||||
}
|
||||
|
||||
|
||||
QDecQuad& QDecQuad::fromHexString(const char* str)
|
||||
{
|
||||
QByteArray ba = QByteArray::fromHex(str);
|
||||
int size = sizeof(m_data);
|
||||
char* p = (char*)&m_data;
|
||||
int i = 0;
|
||||
int j = size-1;
|
||||
for(; i<size; i++,j--)
|
||||
p[j] = ba.at(i);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
QDecQuad& QDecQuad::fromQDecDouble(const QDecDouble& d)
|
||||
{
|
||||
decDoubleToWider(d.data(), &m_data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& QDecQuad::fromQDecNumber(const QDecNumber& n, QDecContext* c)
|
||||
{
|
||||
decQuadFromNumber(&m_data, n.data(), CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& QDecQuad::fromQDecPacked(const QDecPacked& p)
|
||||
{
|
||||
fromQDecNumber(p.toQDecNumber());
|
||||
return *this;
|
||||
}
|
||||
|
||||
double QDecQuad::toDouble() const
|
||||
{
|
||||
char str[MaxStrSize] = { 0 };
|
||||
decQuadToString(&m_data, str);
|
||||
return strtod(str, 0);
|
||||
}
|
||||
|
||||
QDecDouble QDecQuad::toQDecDouble(QDecContext* c) const
|
||||
{
|
||||
decDouble d;
|
||||
return decDoubleFromWider(&d, &m_data, CXT(c));
|
||||
}
|
||||
|
||||
QDecPacked QDecQuad::toQDecPacked() const
|
||||
{
|
||||
return QDecPacked(toQDecNumber());
|
||||
}
|
||||
|
||||
QDecNumber QDecQuad::toQDecNumber() const
|
||||
{
|
||||
decNumber n;
|
||||
return decQuadToNumber(&m_data, &n);
|
||||
}
|
||||
|
||||
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecQuad& d)
|
||||
{
|
||||
ts << d.toString();
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,442 @@
|
||||
#ifndef QDECQUAD_HH
|
||||
#define QDECQUAD_HH
|
||||
|
||||
/** \file QDecQuad.hh
|
||||
* Declarations for the class QDecQuad.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "QDecFwd.hh"
|
||||
#include "QDecContext.hh"
|
||||
extern "C" {
|
||||
#include "decQuad.h"
|
||||
}
|
||||
|
||||
// FORWARDS
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextStream;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecQuad
|
||||
QDecQuad encapsulates decQuad and provides decNumber library functions
|
||||
that operates upon decSingle as member functions with the same name.
|
||||
decimal128 is a 128-bit decimal floating-point representation which
|
||||
provides 34 decimal digits of precision in a compressed format.
|
||||
decQuad module provides the functions for the decimal128 format;
|
||||
this format is an IEEE 754 basic format; it contains the same set of
|
||||
functions as decDouble.
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecQuad
|
||||
{
|
||||
// MEMBERS
|
||||
//! Embedded decQuad structure
|
||||
decQuad m_data;
|
||||
|
||||
public:
|
||||
// TYPES
|
||||
typedef decQuad* decQuadPtr_t;
|
||||
enum {
|
||||
MaxStrSize = QDECMAXSTRSIZE
|
||||
};
|
||||
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecQuad() { decQuadZero(&m_data); }
|
||||
|
||||
// Default Dtor and Copy Ctor are ok
|
||||
|
||||
// Constructors using decQuad structure
|
||||
QDecQuad(decQuad d) : m_data(d) {}
|
||||
QDecQuad(const decQuad* p) : m_data(*p) {}
|
||||
|
||||
// Conversion constructors using simple types
|
||||
QDecQuad(const char* str) { fromString(str); }
|
||||
QDecQuad(int32_t i) { fromInt32(i); }
|
||||
QDecQuad(uint32_t i) { fromUInt32(i); }
|
||||
QDecQuad(double d) { fromDouble(d); }
|
||||
|
||||
|
||||
// Conversion constructors using composite types
|
||||
QDecQuad(const QDecDouble& d) { fromQDecDouble(d); }
|
||||
QDecQuad(const QDecPacked& p) { fromQDecPacked(p); }
|
||||
QDecQuad(const QDecNumber& n) { fromQDecNumber(n); }
|
||||
|
||||
|
||||
//! Copy assignment
|
||||
QDecQuad& operator=(const QDecQuad& o)
|
||||
{ return (this != &o ? copy(o) : *this); }
|
||||
|
||||
//! Conversion operator to decQuad*
|
||||
operator decQuadPtr_t() { return &m_data; }
|
||||
|
||||
|
||||
// ACCESSORS
|
||||
const decQuad* data() const
|
||||
{ return &m_data; }
|
||||
|
||||
// MODIFIERS
|
||||
decQuad* data()
|
||||
{ return &m_data; }
|
||||
|
||||
// UTILITIES & CONVERSIONS
|
||||
QDecQuad& fromBCD(int32_t exp, const QByteArray& bcd, int32_t sign) {
|
||||
decQuadFromBCD(&m_data, exp, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& fromDouble(double d);
|
||||
|
||||
QDecQuad& fromInt32(int32_t i)
|
||||
{ decQuadFromInt32(&m_data, i); return *this; }
|
||||
|
||||
QDecQuad& fromPacked(int32_t exp, const QByteArray& pack) {
|
||||
decQuadFromPacked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& fromPackedChecked(int32_t exp, const QByteArray& pack) {
|
||||
decQuadFromPackedChecked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& fromString(const char* str, QDecContext* c = 0)
|
||||
{ decQuadFromString(&m_data, str, CXT(c)); return *this; }
|
||||
|
||||
//! Hexadecimal string in network byte order
|
||||
QDecQuad& fromHexString(const char* str);
|
||||
|
||||
QDecQuad& fromQDecDouble(const QDecDouble& d);
|
||||
|
||||
QDecQuad& fromQDecNumber(const QDecNumber& n, QDecContext* c = 0);
|
||||
|
||||
QDecQuad& fromQDecPacked(const QDecPacked& p);
|
||||
|
||||
QDecQuad& fromUInt32(uint32_t i)
|
||||
{ decQuadFromUInt32(&m_data, i); return *this; }
|
||||
|
||||
int32_t getCoefficient(QByteArray& bcd) const {
|
||||
bcd.resize(DECQUAD_Pmax);
|
||||
return decQuadGetCoefficient(&m_data, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
QDecQuad& setCoefficient(const QByteArray& bcd, int32_t sign) {
|
||||
decQuadSetCoefficient(&m_data, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecQuad& setExponent(int32_t exp, QDecContext* c = 0) {
|
||||
decQuadSetExponent(&m_data, CXT(c), exp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int32_t toBCD(int32_t& exp, QByteArray& bcd) {
|
||||
bcd.resize(DECQUAD_Pmax);
|
||||
return decQuadToBCD(&m_data, &exp, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
double toDouble() const;
|
||||
|
||||
QByteArray toEngString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decQuadToEngString(&m_data, str);
|
||||
}
|
||||
|
||||
int32_t toPacked(int32_t& exp, QByteArray& pack) {
|
||||
pack.resize(DECQUAD_Pmax);
|
||||
return decQuadToPacked(&m_data, &exp, (uint8_t*)pack.data());
|
||||
}
|
||||
|
||||
QByteArray toString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decQuadToString(&m_data, str);
|
||||
}
|
||||
|
||||
QDecDouble toQDecDouble(QDecContext* c = 0) const;
|
||||
|
||||
QDecPacked toQDecPacked() const;
|
||||
|
||||
QDecNumber toQDecNumber() const;
|
||||
|
||||
QDecQuad& zero()
|
||||
{ decQuadZero(&m_data); return *this; }
|
||||
|
||||
|
||||
// COMPUTATIONAL
|
||||
QDecQuad abs(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadAbs(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad add(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadAdd(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad digitAnd(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadAnd(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad divide(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadDivide(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad divideInteger(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadDivideInteger(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad fma(const QDecQuad& o, const QDecQuad& o2,
|
||||
QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadFMA(&q, &m_data, &o.m_data, &o2.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad invert(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadInvert(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad logB(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadLogB(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad max(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadMax(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad maxMag(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadMaxMag(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad minus(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadMinus(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad multiply(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadMultiply(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad nextMinus(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadNextMinus(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad nextPlus(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadNextPlus(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad nextToward(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadNextToward(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad digitOr(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadOr(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad plus(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadPlus(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad quantize(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadQuantize(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad reduce(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadReduce(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad remainder(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadRemainder(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad remainderNear(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadRemainderNear(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad rotate(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadRotate(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad scaleB(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadScaleB(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad shift(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadShift(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad subtract(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadSubtract(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad toIntegralValue(enum rounding r, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadToIntegralValue(&q, &m_data, CXT(c), r); }
|
||||
|
||||
QDecQuad toIntegralExact(QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadToIntegralExact(&q, &m_data, CXT(c)); }
|
||||
|
||||
QDecQuad digitXor(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadXor(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
|
||||
// COMPARISONS
|
||||
QDecQuad compare(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadCompare(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad compareSignal(const QDecQuad& o, QDecContext* c = 0) const
|
||||
{ decQuad q; return decQuadCompareSignal(&q, &m_data, &o.m_data, CXT(c)); }
|
||||
|
||||
QDecQuad compareTotal(const QDecQuad& o) const
|
||||
{ decQuad q; return decQuadCompareTotal(&q, &m_data, &o.m_data); }
|
||||
|
||||
QDecQuad compareTotalMag(const QDecQuad& o) const
|
||||
{ decQuad q; return decQuadCompareTotalMag(&q, &m_data, &o.m_data); }
|
||||
|
||||
|
||||
// COPIES
|
||||
QDecQuad& canonical(const QDecQuad& d)
|
||||
{ decQuadCanonical(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecQuad& copy(const QDecQuad& d)
|
||||
{ decQuadCopy(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecQuad& copyAbs(const QDecQuad& d)
|
||||
{ decQuadCopyAbs(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecQuad& copyNegate(const QDecQuad& d)
|
||||
{ decQuadCopyNegate(&m_data, &d.m_data); return *this; }
|
||||
|
||||
QDecQuad& copySign(const QDecQuad& d, const QDecQuad& sd)
|
||||
{ decQuadCopySign(&m_data, &d.m_data, &sd.m_data); return *this; }
|
||||
|
||||
|
||||
// NON-COMPUTATIONAL
|
||||
// "class" is a reserved word in C++
|
||||
enum decClass classification() const
|
||||
{ return decQuadClass(&m_data); }
|
||||
|
||||
const char* classString() const
|
||||
{ return decQuadClassString(&m_data); }
|
||||
|
||||
uint32_t digits() const
|
||||
{ return decQuadDigits(&m_data); }
|
||||
|
||||
bool isCanonical() const
|
||||
{ return decQuadIsCanonical(&m_data); }
|
||||
|
||||
bool isFinite() const
|
||||
{ return decQuadIsFinite(&m_data); }
|
||||
|
||||
bool isInteger() const
|
||||
{ return decQuadIsInteger(&m_data); }
|
||||
|
||||
bool isLogical() const
|
||||
{ return decQuadIsLogical(&m_data); }
|
||||
|
||||
bool isInfinite() const
|
||||
{ return decQuadIsInfinite(&m_data); }
|
||||
|
||||
bool isNaN() const
|
||||
{ return decQuadIsNaN(&m_data); }
|
||||
|
||||
bool isNegative() const
|
||||
{ return decQuadIsNegative(&m_data); }
|
||||
|
||||
bool isNormal() const
|
||||
{ return decQuadIsNormal(&m_data); }
|
||||
|
||||
bool isPositive() const
|
||||
{ return decQuadIsPositive(&m_data); }
|
||||
|
||||
bool isSignaling() const
|
||||
{ return decQuadIsSignaling(&m_data); }
|
||||
|
||||
bool isSignalling() const
|
||||
{ return decQuadIsSignalling(&m_data); }
|
||||
|
||||
bool isSigned() const
|
||||
{ return decQuadIsSigned(&m_data); }
|
||||
|
||||
bool isSubnormal() const
|
||||
{ return decQuadIsSubnormal(&m_data); }
|
||||
|
||||
bool isZero() const
|
||||
{ return decQuadIsZero(&m_data); }
|
||||
|
||||
uint32_t radix() const
|
||||
{ return decQuadRadix(&m_data); }
|
||||
|
||||
const char* version() const
|
||||
{ return decQuadVersion(); }
|
||||
|
||||
|
||||
// RELATIONAL AND LOGICAL OPERATORS
|
||||
bool operator==(const QDecQuad& o) const
|
||||
{ return compare(o).isZero(); }
|
||||
|
||||
bool operator!=(const QDecQuad& o) const
|
||||
{ return !(this->operator==(o)); }
|
||||
|
||||
bool operator<(const QDecQuad& o) const
|
||||
{ return compare(o).isNegative(); }
|
||||
|
||||
bool operator<=(const QDecQuad& o) const
|
||||
{
|
||||
const QDecQuad& r = compare(o);
|
||||
return r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
bool operator>(const QDecQuad& o) const
|
||||
{ return !(this->operator<=(o)); }
|
||||
|
||||
bool operator>=(const QDecQuad& o) const
|
||||
{
|
||||
const QDecQuad& r = compare(o);
|
||||
return !r.isNegative() || r.isZero();
|
||||
}
|
||||
|
||||
// BITWISE OPERATORS
|
||||
QDecQuad operator&(const QDecQuad& o) const
|
||||
{ return digitAnd(o); }
|
||||
|
||||
QDecQuad operator|(const QDecQuad& o) const
|
||||
{ return digitOr(o); }
|
||||
|
||||
QDecQuad operator^(const QDecQuad& o) const
|
||||
{ return digitXor(o); }
|
||||
|
||||
|
||||
// ARITHMETIC OPERATORS
|
||||
QDecQuad operator+(const QDecQuad& o) const
|
||||
{ return add(o); }
|
||||
|
||||
QDecQuad operator-(const QDecQuad& o) const
|
||||
{ return subtract(o); }
|
||||
|
||||
QDecQuad operator*(const QDecQuad& o) const
|
||||
{ return multiply(o); }
|
||||
|
||||
QDecQuad operator/(const QDecQuad& o) const
|
||||
{ return divide(o); }
|
||||
|
||||
QDecQuad operator%(const QDecQuad& o) const
|
||||
{ return remainder(o); }
|
||||
|
||||
|
||||
// COMPOUND ASSIGNMENT OPERATORS
|
||||
QDecQuad& operator+=(const QDecQuad& o)
|
||||
{ return copy(add(o)); }
|
||||
|
||||
QDecQuad& operator-=(const QDecQuad& o)
|
||||
{ return copy(subtract(o)); }
|
||||
|
||||
QDecQuad& operator*=(const QDecQuad& o)
|
||||
{ return copy(multiply(o)); }
|
||||
|
||||
QDecQuad& operator/=(const QDecQuad& o)
|
||||
{ return copy(divide(o)); }
|
||||
|
||||
QDecQuad& operator%=(const QDecQuad& o)
|
||||
{ return copy(remainder(o)); }
|
||||
|
||||
QDecQuad& operator&=(const QDecQuad& o)
|
||||
{ return copy(digitAnd(o)); }
|
||||
|
||||
QDecQuad& operator|=(const QDecQuad& o)
|
||||
{ return copy(digitOr(o)); }
|
||||
|
||||
QDecQuad& operator^=(const QDecQuad& o)
|
||||
{ return copy(digitXor(o)); }
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QDecQuad);
|
||||
|
||||
|
||||
QDECIMAL_EXPORT
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecQuad& d);
|
||||
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,102 @@
|
||||
/** \file QDecSingle.cc
|
||||
* Definitions for the class QDecSingle.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "QDecSingle.hh"
|
||||
extern "C" {
|
||||
#include "decimal32.h"
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include <QTextStream>
|
||||
#include "QDecNumber.hh"
|
||||
#include "QDecPacked.hh"
|
||||
#include "QDecDouble.hh"
|
||||
|
||||
|
||||
QDecSingle& QDecSingle::fromDouble(double d)
|
||||
{
|
||||
char str[MaxStrSize] = {0};
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
_snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#else
|
||||
snprintf(str, MaxStrSize, "%.*g", QDecNumDigits, d);
|
||||
#endif
|
||||
|
||||
return fromString(str);
|
||||
}
|
||||
|
||||
QDecSingle& QDecSingle::fromHexString(const char* str)
|
||||
{
|
||||
QByteArray ba = QByteArray::fromHex(str);
|
||||
int size = sizeof(m_data);
|
||||
char* p = (char*)&m_data;
|
||||
int i = 0;
|
||||
int j = size-1;
|
||||
for(; i<size; i++,j--)
|
||||
p[j] = ba.at(i);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
QDecSingle& QDecSingle::fromQDecNumber(const QDecNumber& n, QDecContext* c)
|
||||
{
|
||||
decSingleFromNumber(&m_data, n.data(), CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& QDecSingle::fromQDecPacked(const QDecPacked& p)
|
||||
{
|
||||
fromQDecNumber(p.toQDecNumber());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& QDecSingle::fromWider(const QDecDouble& d, QDecContext* c)
|
||||
{
|
||||
decSingleFromWider(&m_data, d.data(), CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
double QDecSingle::toDouble() const
|
||||
{
|
||||
char str[MaxStrSize] = {0};
|
||||
decSingleToString(&m_data, str);
|
||||
return strtod(str, 0);
|
||||
}
|
||||
|
||||
QDecDouble QDecSingle::toQDecDouble() const
|
||||
{
|
||||
return toWider();
|
||||
}
|
||||
|
||||
QDecPacked QDecSingle::toQDecPacked() const
|
||||
{
|
||||
return QDecPacked(toQDecNumber());
|
||||
}
|
||||
|
||||
QDecNumber QDecSingle::toQDecNumber() const
|
||||
{
|
||||
decNumber n;
|
||||
return decSingleToNumber(&m_data, &n);
|
||||
}
|
||||
|
||||
QDecDouble QDecSingle::toWider() const
|
||||
{
|
||||
decDouble d;
|
||||
return decSingleToWider(&m_data, &d);
|
||||
}
|
||||
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecSingle& d)
|
||||
{
|
||||
ts << d.toString();
|
||||
return ts;
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
#ifndef QDECSINGLE_HH
|
||||
#define QDECSINGLE_HH
|
||||
|
||||
/** \file QDecSingle.hh
|
||||
* Declarations for the class QDecSingle.
|
||||
*
|
||||
* (C) Copyright by Semih Cemiloglu
|
||||
* All rights reserved, see COPYRIGHT file for details.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "QDecFwd.hh"
|
||||
#include "QDecContext.hh"
|
||||
extern "C" {
|
||||
#include "decSingle.h"
|
||||
}
|
||||
|
||||
// FORWARDS
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextStream;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecSingle
|
||||
QDecSingle encapsulates decSingle and provides decNumber
|
||||
library functions that operates upon decSingle as member functions
|
||||
with the same name.
|
||||
decimal32 is a 32-bit decimal floating-point representation which
|
||||
provides 7 decimal digits of precision in a compressed format.
|
||||
decSingle module provides the functions for the decimal32 format;
|
||||
this format is intended for storage and interchange only and so
|
||||
the module provides utilities and conversions but no arithmetic functions.
|
||||
*/
|
||||
class QDECIMAL_EXPORT QDecSingle
|
||||
{
|
||||
// MEMBERS
|
||||
//! Embedded decSingle structure
|
||||
decSingle m_data;
|
||||
|
||||
public:
|
||||
// TYPES
|
||||
typedef decSingle* decSinglePtr_t;
|
||||
enum {
|
||||
MaxStrSize = QDECMAXSTRSIZE
|
||||
};
|
||||
|
||||
|
||||
// CREATORS
|
||||
//! Default constructor
|
||||
QDecSingle() { decSingleZero(&m_data); }
|
||||
|
||||
// Default Dtor and Copy Ctor are ok
|
||||
|
||||
// Constructors using decSingle structure
|
||||
QDecSingle(decSingle d) : m_data(d) {}
|
||||
QDecSingle(const decSingle* p) : m_data(*p) {}
|
||||
|
||||
// Conversion constructors using simple types
|
||||
QDecSingle(const char* str) { fromString(str); }
|
||||
QDecSingle(double d) { fromDouble(d); }
|
||||
|
||||
// Conversion constructors using composite types
|
||||
QDecSingle(const QDecDouble& d) { fromQDecDouble(d); }
|
||||
QDecSingle(const QDecPacked& p) { fromQDecPacked(p); }
|
||||
QDecSingle(const QDecNumber& n) { fromQDecNumber(n); }
|
||||
|
||||
//! Copy assignment
|
||||
QDecSingle& operator=(const QDecSingle& o)
|
||||
{ if(this != &o) m_data = o.m_data; return *this; }
|
||||
|
||||
//! Conversion operator to decSingle*
|
||||
operator decSinglePtr_t() { return &m_data; }
|
||||
|
||||
|
||||
// ACCESSORS
|
||||
const decSingle* data() const
|
||||
{ return &m_data; }
|
||||
|
||||
// MODIFIERS
|
||||
decSingle* data()
|
||||
{ return &m_data; }
|
||||
|
||||
|
||||
// UTILITIES & CONVERSIONS
|
||||
QDecSingle& fromBCD(int32_t exp, const QByteArray& bcd, int32_t sign) {
|
||||
decSingleFromBCD(&m_data, exp, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& fromDouble(double d);
|
||||
|
||||
QDecSingle& fromPacked(int32_t exp, const QByteArray& pack) {
|
||||
decSingleFromPacked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& fromPackedChecked(int32_t exp, const QByteArray& pack) {
|
||||
decSingleFromPackedChecked(&m_data, exp, (const uint8_t*)pack.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& fromString(const char* str, QDecContext* c = 0) {
|
||||
decSingleFromString(&m_data, str, CXT(c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Hexadecimal string in network byte order
|
||||
QDecSingle& fromHexString(const char* str);
|
||||
|
||||
QDecSingle& fromQDecDouble(const QDecDouble& d, QDecContext* c = 0)
|
||||
{ return fromWider(d,c); }
|
||||
|
||||
QDecSingle& fromQDecNumber(const QDecNumber& n, QDecContext* c = 0);
|
||||
|
||||
QDecSingle& fromQDecPacked(const QDecPacked& p);
|
||||
|
||||
QDecSingle& fromWider(const QDecDouble& d, QDecContext* c = 0);
|
||||
|
||||
int32_t getCoefficient(QByteArray& bcd) const {
|
||||
bcd.resize(DECSINGLE_Pmax);
|
||||
return decSingleGetCoefficient(&m_data, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
int32_t getExponent() const
|
||||
{ return decSingleGetExponent(&m_data); }
|
||||
|
||||
QDecSingle& setCoefficient(const QByteArray& bcd, int32_t sign) {
|
||||
decSingleSetCoefficient(&m_data, (const uint8_t*)bcd.data(), sign);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDecSingle& setExponent(int32_t exp, QDecContext* c = 0 ) {
|
||||
decSingleSetExponent(&m_data, CXT(c), exp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int32_t toBCD(int32_t& exp, QByteArray& bcd) {
|
||||
bcd.resize(DECSINGLE_Pmax);
|
||||
return decSingleToBCD(&m_data, &exp, (uint8_t*)bcd.data());
|
||||
}
|
||||
|
||||
double toDouble() const;
|
||||
|
||||
QByteArray toEngString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decSingleToEngString(&m_data, str);
|
||||
}
|
||||
|
||||
QByteArray toString() const {
|
||||
char str[MaxStrSize] = { 0 };
|
||||
return decSingleToString(&m_data, str);
|
||||
}
|
||||
|
||||
int32_t toPacked(int32_t& exp, QByteArray& pack) {
|
||||
pack.resize(DECSINGLE_Pmax);
|
||||
return decSingleToPacked(&m_data, &exp, (uint8_t*)pack.data());
|
||||
}
|
||||
|
||||
QDecDouble toQDecDouble() const;
|
||||
|
||||
QDecPacked toQDecPacked() const;
|
||||
|
||||
QDecNumber toQDecNumber() const;
|
||||
|
||||
QDecDouble toWider() const;
|
||||
|
||||
QDecSingle& zero()
|
||||
{ decSingleZero(&m_data); return *this; }
|
||||
|
||||
|
||||
// ARITHMETIC
|
||||
// No arithmetic routines defines for QDecSingle
|
||||
|
||||
// NON-COMPUTATIONAL
|
||||
|
||||
uint32_t radix() const
|
||||
{ return decSingleRadix(&m_data); }
|
||||
|
||||
const char* version() const
|
||||
{ return decSingleVersion(); }
|
||||
|
||||
|
||||
}; // end class
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QDecSingle);
|
||||
|
||||
|
||||
QDECIMAL_EXPORT
|
||||
QTextStream& operator<<(QTextStream& ts, const QDecSingle& d);
|
||||
|
||||
|
||||
#endif /* Include guard */
|
@ -0,0 +1,7 @@
|
||||
Import('*')
|
||||
|
||||
env.AppendUnique(CPPPATH = ['#/decnumber'])
|
||||
|
||||
lib = env.Library('qdecimal', Glob('*.cc'))
|
||||
|
||||
env['PRJ_LIBS']['qdecimal'] = lib
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
include(../common.pri)
|
||||
|
||||
QT -= gui
|
||||
TEMPLATE = lib
|
||||
|
||||
# Pick if the library will be static or dynamic:
|
||||
CONFIG += static
|
||||
# or dynamic (don't forget to define QDECIMAL_SHARED
|
||||
#CONFIG += shared
|
||||
#DEFINES += QDECIMAL_SHARED=2
|
||||
# 1=import, client app, 2=export, source shared library (here)
|
||||
|
||||
|
||||
TARGET = qdecimal
|
||||
DEPENDPATH += .
|
||||
# To include decnumber headers
|
||||
INCLUDEPATH += ../decnumber
|
||||
DESTDIR = ../lib
|
||||
LIBS += -L../lib -ldecnumber
|
||||
|
||||
# Input
|
||||
HEADERS += QDecContext.hh \
|
||||
QDecDouble.hh \
|
||||
QDecPacked.hh \
|
||||
QDecNumber.hh \
|
||||
QDecSingle.hh \
|
||||
QDecQuad.hh
|
||||
|
||||
SOURCES += QDecContext.cc \
|
||||
QDecDouble.cc \
|
||||
QDecPacked.cc \
|
||||
QDecNumber.cc \
|
||||
QDecSingle.cc \
|
||||
QDecQuad.cc
|
@ -0,0 +1,70 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "QDecNumberTests.hh"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# ident "$Id$"
|
||||
#elif defined(__sun)
|
||||
# pragma ident "$Id$"
|
||||
#elif defined(_WIN32)
|
||||
# pragma comment( user, __FILE__ " " __DATE__ " " __TIME__ "$Id$" )
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void MessageOutput(QtMsgType type, const QMessageLogContext &context,
|
||||
const QString &msg)
|
||||
{
|
||||
QByteArray lmsg = msg.toLocal8Bit();
|
||||
const char* cmsg = lmsg.constData();
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
fprintf(stderr, "%s\n", cmsg);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
fprintf(stderr, "Warn: %s\n", cmsg);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
fprintf(stderr, "Critical: %s\n", cmsg);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
fprintf(stderr, "Fatal: %s\n", cmsg);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//QTEST_MAIN(QDecNumberTests)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
qInstallMessageHandler(MessageOutput);
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
|
||||
QRegExp flagre("--(\\w+)=.*");
|
||||
QStringList tc_args;
|
||||
QStringList qt_args;
|
||||
|
||||
// Separate QTest arguments out of test class arguments
|
||||
QStringListIterator ai(args);
|
||||
while(ai.hasNext()) {
|
||||
QString item = ai.next();
|
||||
if(flagre.exactMatch(item))
|
||||
tc_args << item;
|
||||
else
|
||||
qt_args << item;
|
||||
}
|
||||
|
||||
QDecNumberTests tc(tc_args);
|
||||
int rv;
|
||||
|
||||
// Increase limit for warnings count
|
||||
qt_args << "-maxwarnings" << "9999999";
|
||||
rv = QTest::qExec(&tc, qt_args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//include "moc_QDecNumberTests.cpp"
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,82 @@
|
||||
#ifndef QDECNUMBERTESTS_HH
|
||||
#define QDECNUMBERTESTS_HH
|
||||
|
||||
#if defined(_MSC_VER) || defined(__GNUC__)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
|
||||
// FORWARDS
|
||||
class QDecContext;
|
||||
class QDecNumber;
|
||||
|
||||
class QDecNumberTests: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(TestCodes_e)
|
||||
|
||||
public:
|
||||
|
||||
// CREATORS
|
||||
QDecNumberTests(const QStringList& arguments);
|
||||
|
||||
enum TestCodes_e {
|
||||
TC_ignore = 0,
|
||||
TC_comment,
|
||||
TC_directive ,
|
||||
TC_test,
|
||||
TC_unknown
|
||||
};
|
||||
|
||||
private slots:
|
||||
void compound_interest();
|
||||
void compressed_formats();
|
||||
void packed_decimals();
|
||||
void quad_tests();
|
||||
void quad_with_number();
|
||||
void QDecContext_tests();
|
||||
void QDecNumber_abs();
|
||||
void QDecNumber_add();
|
||||
void QDecimal_size();
|
||||
void conversion();
|
||||
void regression();
|
||||
void test_cases();
|
||||
|
||||
private:
|
||||
void procTestFile(const QString& filename);
|
||||
int procTestLine(const QString& line, QStringList& tokens);
|
||||
int applyTestDirective(const QStringList& tokens, QDecContext& ctx);
|
||||
int getDirectivesContext(QDecContext& ctx, bool precision=true);
|
||||
void displayDirectivesContext();
|
||||
void clearDirectivesContext();
|
||||
int opTest(const QStringList& tokens);
|
||||
int runTestCase(const QStringList& tokens, const QDecContext& ctx);
|
||||
|
||||
|
||||
bool token2QDecNumber(const QString& token, const QDecContext& ctx, QDecNumber& num);
|
||||
bool QDecNumber2token(QString& token, const QDecNumber& num);
|
||||
|
||||
|
||||
// MEMBERS
|
||||
// Current test file
|
||||
QString m_testFile;
|
||||
// Test lines (cases + directives)
|
||||
QStringList m_testLines;
|
||||
// Currently in force directives
|
||||
QMap<QString, QString> m_curDirectives;
|
||||
|
||||
// Map of arguments
|
||||
QMap<QString, QString> m_argsMap;
|
||||
|
||||
// Set of test cases to be skipped
|
||||
QSet<QString> m_skipSet;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
Import('*')
|
||||
|
||||
env.AppendUnique(CPPPATH = ['#/test', '#/src'])
|
||||
|
||||
qd_libs = [
|
||||
env['PRJ_LIBS']['qdecimal'],
|
||||
env['PRJ_LIBS']['decnumber']
|
||||
]
|
||||
env.AppendUnique(LIBS = qd_libs)
|
||||
|
||||
|
||||
exe = env.Program('qdecimal_test', Glob('*.cc'))
|
||||
|
||||
env['PRJ_TSTS']['qdecimal_test'] = exe
|
@ -0,0 +1,161 @@
|
||||
------------------------------------------------------------------------
|
||||
-- abs.decTest -- decimal absolute value --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- This set of tests primarily tests the existence of the operator.
|
||||
-- Additon, subtraction, rounding, and more overflows are tested
|
||||
-- elsewhere.
|
||||
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 384
|
||||
minexponent: -383
|
||||
extended: 1
|
||||
|
||||
absx001 abs '1' -> '1'
|
||||
absx002 abs '-1' -> '1'
|
||||
absx003 abs '1.00' -> '1.00'
|
||||
absx004 abs '-1.00' -> '1.00'
|
||||
absx005 abs '0' -> '0'
|
||||
absx006 abs '0.00' -> '0.00'
|
||||
absx007 abs '00.0' -> '0.0'
|
||||
absx008 abs '00.00' -> '0.00'
|
||||
absx009 abs '00' -> '0'
|
||||
|
||||
absx010 abs '-2' -> '2'
|
||||
absx011 abs '2' -> '2'
|
||||
absx012 abs '-2.00' -> '2.00'
|
||||
absx013 abs '2.00' -> '2.00'
|
||||
absx014 abs '-0' -> '0'
|
||||
absx015 abs '-0.00' -> '0.00'
|
||||
absx016 abs '-00.0' -> '0.0'
|
||||
absx017 abs '-00.00' -> '0.00'
|
||||
absx018 abs '-00' -> '0'
|
||||
|
||||
absx020 abs '-2000000' -> '2000000'
|
||||
absx021 abs '2000000' -> '2000000'
|
||||
precision: 7
|
||||
absx022 abs '-2000000' -> '2000000'
|
||||
absx023 abs '2000000' -> '2000000'
|
||||
precision: 6
|
||||
absx024 abs '-2000000' -> '2.00000E+6' Rounded
|
||||
absx025 abs '2000000' -> '2.00000E+6' Rounded
|
||||
precision: 3
|
||||
absx026 abs '-2000000' -> '2.00E+6' Rounded
|
||||
absx027 abs '2000000' -> '2.00E+6' Rounded
|
||||
|
||||
absx030 abs '+0.1' -> '0.1'
|
||||
absx031 abs '-0.1' -> '0.1'
|
||||
absx032 abs '+0.01' -> '0.01'
|
||||
absx033 abs '-0.01' -> '0.01'
|
||||
absx034 abs '+0.001' -> '0.001'
|
||||
absx035 abs '-0.001' -> '0.001'
|
||||
absx036 abs '+0.000001' -> '0.000001'
|
||||
absx037 abs '-0.000001' -> '0.000001'
|
||||
absx038 abs '+0.000000000001' -> '1E-12'
|
||||
absx039 abs '-0.000000000001' -> '1E-12'
|
||||
|
||||
-- examples from decArith
|
||||
precision: 9
|
||||
absx040 abs '2.1' -> '2.1'
|
||||
absx041 abs '-100' -> '100'
|
||||
absx042 abs '101.5' -> '101.5'
|
||||
absx043 abs '-101.5' -> '101.5'
|
||||
|
||||
-- more fixed, potential LHS swaps/overlays if done by subtract 0
|
||||
precision: 9
|
||||
absx060 abs '-56267E-10' -> '0.0000056267'
|
||||
absx061 abs '-56267E-5' -> '0.56267'
|
||||
absx062 abs '-56267E-2' -> '562.67'
|
||||
absx063 abs '-56267E-1' -> '5626.7'
|
||||
absx065 abs '-56267E-0' -> '56267'
|
||||
|
||||
-- overflow tests
|
||||
maxexponent: 999999999
|
||||
minexponent: -999999999
|
||||
precision: 3
|
||||
absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded
|
||||
|
||||
-- subnormals and underflow
|
||||
precision: 3
|
||||
maxexponent: 999
|
||||
minexponent: -999
|
||||
absx210 abs 1.00E-999 -> 1.00E-999
|
||||
absx211 abs 0.1E-999 -> 1E-1000 Subnormal
|
||||
absx212 abs 0.10E-999 -> 1.0E-1000 Subnormal
|
||||
absx213 abs 0.100E-999 -> 1.0E-1000 Subnormal Rounded
|
||||
absx214 abs 0.01E-999 -> 1E-1001 Subnormal
|
||||
-- next is rounded to Emin
|
||||
absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
|
||||
absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
|
||||
absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
|
||||
absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
|
||||
absx230 abs -1.00E-999 -> 1.00E-999
|
||||
absx231 abs -0.1E-999 -> 1E-1000 Subnormal
|
||||
absx232 abs -0.10E-999 -> 1.0E-1000 Subnormal
|
||||
absx233 abs -0.100E-999 -> 1.0E-1000 Subnormal Rounded
|
||||
absx234 abs -0.01E-999 -> 1E-1001 Subnormal
|
||||
-- next is rounded to Emin
|
||||
absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
|
||||
absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
|
||||
absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
|
||||
absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
|
||||
|
||||
-- long operand tests
|
||||
maxexponent: 999
|
||||
minexponent: -999
|
||||
precision: 9
|
||||
absx301 abs 12345678000 -> 1.23456780E+10 Rounded
|
||||
absx302 abs 1234567800 -> 1.23456780E+9 Rounded
|
||||
absx303 abs 1234567890 -> 1.23456789E+9 Rounded
|
||||
absx304 abs 1234567891 -> 1.23456789E+9 Inexact Rounded
|
||||
absx305 abs 12345678901 -> 1.23456789E+10 Inexact Rounded
|
||||
absx306 abs 1234567896 -> 1.23456790E+9 Inexact Rounded
|
||||
|
||||
precision: 15
|
||||
absx321 abs 12345678000 -> 12345678000
|
||||
absx322 abs 1234567800 -> 1234567800
|
||||
absx323 abs 1234567890 -> 1234567890
|
||||
absx324 abs 1234567891 -> 1234567891
|
||||
absx325 abs 12345678901 -> 12345678901
|
||||
absx326 abs 1234567896 -> 1234567896
|
||||
|
||||
|
||||
-- Specials
|
||||
precision: 9
|
||||
|
||||
-- specials
|
||||
absx520 abs 'Inf' -> 'Infinity'
|
||||
absx521 abs '-Inf' -> 'Infinity'
|
||||
absx522 abs NaN -> NaN
|
||||
absx523 abs sNaN -> NaN Invalid_operation
|
||||
absx524 abs NaN22 -> NaN22
|
||||
absx525 abs sNaN33 -> NaN33 Invalid_operation
|
||||
absx526 abs -NaN22 -> -NaN22
|
||||
absx527 abs -sNaN33 -> -NaN33 Invalid_operation
|
||||
|
||||
-- Null tests
|
||||
absx900 abs # -> NaN Invalid_operation
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,338 @@
|
||||
------------------------------------------------------------------------
|
||||
-- and.decTest -- digitwise logical AND --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
extended: 1
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
|
||||
-- Sanity check (truth table)
|
||||
andx001 and 0 0 -> 0
|
||||
andx002 and 0 1 -> 0
|
||||
andx003 and 1 0 -> 0
|
||||
andx004 and 1 1 -> 1
|
||||
andx005 and 1100 1010 -> 1000
|
||||
andx006 and 1111 10 -> 10
|
||||
andx007 and 1111 1010 -> 1010
|
||||
|
||||
-- and at msd and msd-1
|
||||
andx010 and 000000000 000000000 -> 0
|
||||
andx011 and 000000000 100000000 -> 0
|
||||
andx012 and 100000000 000000000 -> 0
|
||||
andx013 and 100000000 100000000 -> 100000000
|
||||
andx014 and 000000000 000000000 -> 0
|
||||
andx015 and 000000000 010000000 -> 0
|
||||
andx016 and 010000000 000000000 -> 0
|
||||
andx017 and 010000000 010000000 -> 10000000
|
||||
|
||||
-- Various lengths
|
||||
-- 123456789 123456789 123456789
|
||||
andx021 and 111111111 111111111 -> 111111111
|
||||
andx022 and 111111111111 111111111 -> 111111111
|
||||
andx023 and 111111111111 11111111 -> 11111111
|
||||
andx024 and 111111111 11111111 -> 11111111
|
||||
andx025 and 111111111 1111111 -> 1111111
|
||||
andx026 and 111111111111 111111 -> 111111
|
||||
andx027 and 111111111111 11111 -> 11111
|
||||
andx028 and 111111111111 1111 -> 1111
|
||||
andx029 and 111111111111 111 -> 111
|
||||
andx031 and 111111111111 11 -> 11
|
||||
andx032 and 111111111111 1 -> 1
|
||||
andx033 and 111111111111 1111111111 -> 111111111
|
||||
andx034 and 11111111111 11111111111 -> 111111111
|
||||
andx035 and 1111111111 111111111111 -> 111111111
|
||||
andx036 and 111111111 1111111111111 -> 111111111
|
||||
|
||||
andx040 and 111111111 111111111111 -> 111111111
|
||||
andx041 and 11111111 111111111111 -> 11111111
|
||||
andx042 and 11111111 111111111 -> 11111111
|
||||
andx043 and 1111111 111111111 -> 1111111
|
||||
andx044 and 111111 111111111 -> 111111
|
||||
andx045 and 11111 111111111 -> 11111
|
||||
andx046 and 1111 111111111 -> 1111
|
||||
andx047 and 111 111111111 -> 111
|
||||
andx048 and 11 111111111 -> 11
|
||||
andx049 and 1 111111111 -> 1
|
||||
|
||||
andx050 and 1111111111 1 -> 1
|
||||
andx051 and 111111111 1 -> 1
|
||||
andx052 and 11111111 1 -> 1
|
||||
andx053 and 1111111 1 -> 1
|
||||
andx054 and 111111 1 -> 1
|
||||
andx055 and 11111 1 -> 1
|
||||
andx056 and 1111 1 -> 1
|
||||
andx057 and 111 1 -> 1
|
||||
andx058 and 11 1 -> 1
|
||||
andx059 and 1 1 -> 1
|
||||
|
||||
andx060 and 1111111111 0 -> 0
|
||||
andx061 and 111111111 0 -> 0
|
||||
andx062 and 11111111 0 -> 0
|
||||
andx063 and 1111111 0 -> 0
|
||||
andx064 and 111111 0 -> 0
|
||||
andx065 and 11111 0 -> 0
|
||||
andx066 and 1111 0 -> 0
|
||||
andx067 and 111 0 -> 0
|
||||
andx068 and 11 0 -> 0
|
||||
andx069 and 1 0 -> 0
|
||||
|
||||
andx070 and 1 1111111111 -> 1
|
||||
andx071 and 1 111111111 -> 1
|
||||
andx072 and 1 11111111 -> 1
|
||||
andx073 and 1 1111111 -> 1
|
||||
andx074 and 1 111111 -> 1
|
||||
andx075 and 1 11111 -> 1
|
||||
andx076 and 1 1111 -> 1
|
||||
andx077 and 1 111 -> 1
|
||||
andx078 and 1 11 -> 1
|
||||
andx079 and 1 1 -> 1
|
||||
|
||||
andx080 and 0 1111111111 -> 0
|
||||
andx081 and 0 111111111 -> 0
|
||||
andx082 and 0 11111111 -> 0
|
||||
andx083 and 0 1111111 -> 0
|
||||
andx084 and 0 111111 -> 0
|
||||
andx085 and 0 11111 -> 0
|
||||
andx086 and 0 1111 -> 0
|
||||
andx087 and 0 111 -> 0
|
||||
andx088 and 0 11 -> 0
|
||||
andx089 and 0 1 -> 0
|
||||
|
||||
andx090 and 011111111 111111111 -> 11111111
|
||||
andx091 and 101111111 111111111 -> 101111111
|
||||
andx092 and 110111111 111111111 -> 110111111
|
||||
andx093 and 111011111 111111111 -> 111011111
|
||||
andx094 and 111101111 111111111 -> 111101111
|
||||
andx095 and 111110111 111111111 -> 111110111
|
||||
andx096 and 111111011 111111111 -> 111111011
|
||||
andx097 and 111111101 111111111 -> 111111101
|
||||
andx098 and 111111110 111111111 -> 111111110
|
||||
|
||||
andx100 and 111111111 011111111 -> 11111111
|
||||
andx101 and 111111111 101111111 -> 101111111
|
||||
andx102 and 111111111 110111111 -> 110111111
|
||||
andx103 and 111111111 111011111 -> 111011111
|
||||
andx104 and 111111111 111101111 -> 111101111
|
||||
andx105 and 111111111 111110111 -> 111110111
|
||||
andx106 and 111111111 111111011 -> 111111011
|
||||
andx107 and 111111111 111111101 -> 111111101
|
||||
andx108 and 111111111 111111110 -> 111111110
|
||||
|
||||
-- non-0/1 should not be accepted, nor should signs
|
||||
andx220 and 111111112 111111111 -> NaN Invalid_operation
|
||||
andx221 and 333333333 333333333 -> NaN Invalid_operation
|
||||
andx222 and 555555555 555555555 -> NaN Invalid_operation
|
||||
andx223 and 777777777 777777777 -> NaN Invalid_operation
|
||||
andx224 and 999999999 999999999 -> NaN Invalid_operation
|
||||
andx225 and 222222222 999999999 -> NaN Invalid_operation
|
||||
andx226 and 444444444 999999999 -> NaN Invalid_operation
|
||||
andx227 and 666666666 999999999 -> NaN Invalid_operation
|
||||
andx228 and 888888888 999999999 -> NaN Invalid_operation
|
||||
andx229 and 999999999 222222222 -> NaN Invalid_operation
|
||||
andx230 and 999999999 444444444 -> NaN Invalid_operation
|
||||
andx231 and 999999999 666666666 -> NaN Invalid_operation
|
||||
andx232 and 999999999 888888888 -> NaN Invalid_operation
|
||||
-- a few randoms
|
||||
andx240 and 567468689 -934981942 -> NaN Invalid_operation
|
||||
andx241 and 567367689 934981942 -> NaN Invalid_operation
|
||||
andx242 and -631917772 -706014634 -> NaN Invalid_operation
|
||||
andx243 and -756253257 138579234 -> NaN Invalid_operation
|
||||
andx244 and 835590149 567435400 -> NaN Invalid_operation
|
||||
-- test MSD
|
||||
andx250 and 200000000 100000000 -> NaN Invalid_operation
|
||||
andx251 and 700000000 100000000 -> NaN Invalid_operation
|
||||
andx252 and 800000000 100000000 -> NaN Invalid_operation
|
||||
andx253 and 900000000 100000000 -> NaN Invalid_operation
|
||||
andx254 and 200000000 000000000 -> NaN Invalid_operation
|
||||
andx255 and 700000000 000000000 -> NaN Invalid_operation
|
||||
andx256 and 800000000 000000000 -> NaN Invalid_operation
|
||||
andx257 and 900000000 000000000 -> NaN Invalid_operation
|
||||
andx258 and 100000000 200000000 -> NaN Invalid_operation
|
||||
andx259 and 100000000 700000000 -> NaN Invalid_operation
|
||||
andx260 and 100000000 800000000 -> NaN Invalid_operation
|
||||
andx261 and 100000000 900000000 -> NaN Invalid_operation
|
||||
andx262 and 000000000 200000000 -> NaN Invalid_operation
|
||||
andx263 and 000000000 700000000 -> NaN Invalid_operation
|
||||
andx264 and 000000000 800000000 -> NaN Invalid_operation
|
||||
andx265 and 000000000 900000000 -> NaN Invalid_operation
|
||||
-- test MSD-1
|
||||
andx270 and 020000000 100000000 -> NaN Invalid_operation
|
||||
andx271 and 070100000 100000000 -> NaN Invalid_operation
|
||||
andx272 and 080010000 100000001 -> NaN Invalid_operation
|
||||
andx273 and 090001000 100000010 -> NaN Invalid_operation
|
||||
andx274 and 100000100 020010100 -> NaN Invalid_operation
|
||||
andx275 and 100000000 070001000 -> NaN Invalid_operation
|
||||
andx276 and 100000010 080010100 -> NaN Invalid_operation
|
||||
andx277 and 100000000 090000010 -> NaN Invalid_operation
|
||||
-- test LSD
|
||||
andx280 and 001000002 100000000 -> NaN Invalid_operation
|
||||
andx281 and 000000007 100000000 -> NaN Invalid_operation
|
||||
andx282 and 000000008 100000000 -> NaN Invalid_operation
|
||||
andx283 and 000000009 100000000 -> NaN Invalid_operation
|
||||
andx284 and 100000000 000100002 -> NaN Invalid_operation
|
||||
andx285 and 100100000 001000007 -> NaN Invalid_operation
|
||||
andx286 and 100010000 010000008 -> NaN Invalid_operation
|
||||
andx287 and 100001000 100000009 -> NaN Invalid_operation
|
||||
-- test Middie
|
||||
andx288 and 001020000 100000000 -> NaN Invalid_operation
|
||||
andx289 and 000070001 100000000 -> NaN Invalid_operation
|
||||
andx290 and 000080000 100010000 -> NaN Invalid_operation
|
||||
andx291 and 000090000 100001000 -> NaN Invalid_operation
|
||||
andx292 and 100000010 000020100 -> NaN Invalid_operation
|
||||
andx293 and 100100000 000070010 -> NaN Invalid_operation
|
||||
andx294 and 100010100 000080001 -> NaN Invalid_operation
|
||||
andx295 and 100001000 000090000 -> NaN Invalid_operation
|
||||
-- signs
|
||||
andx296 and -100001000 -000000000 -> NaN Invalid_operation
|
||||
andx297 and -100001000 000010000 -> NaN Invalid_operation
|
||||
andx298 and 100001000 -000000000 -> NaN Invalid_operation
|
||||
andx299 and 100001000 000011000 -> 1000
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
andx331 and 2 9.99999999E+999 -> NaN Invalid_operation
|
||||
andx332 and 3 1E-999 -> NaN Invalid_operation
|
||||
andx333 and 4 1.00000000E-999 -> NaN Invalid_operation
|
||||
andx334 and 5 1E-1007 -> NaN Invalid_operation
|
||||
andx335 and 6 -1E-1007 -> NaN Invalid_operation
|
||||
andx336 and 7 -1.00000000E-999 -> NaN Invalid_operation
|
||||
andx337 and 8 -1E-999 -> NaN Invalid_operation
|
||||
andx338 and 9 -9.99999999E+999 -> NaN Invalid_operation
|
||||
andx341 and 9.99999999E+999 -18 -> NaN Invalid_operation
|
||||
andx342 and 1E-999 01 -> NaN Invalid_operation
|
||||
andx343 and 1.00000000E-999 -18 -> NaN Invalid_operation
|
||||
andx344 and 1E-1007 18 -> NaN Invalid_operation
|
||||
andx345 and -1E-1007 -10 -> NaN Invalid_operation
|
||||
andx346 and -1.00000000E-999 18 -> NaN Invalid_operation
|
||||
andx347 and -1E-999 10 -> NaN Invalid_operation
|
||||
andx348 and -9.99999999E+999 -18 -> NaN Invalid_operation
|
||||
|
||||
-- A few other non-integers
|
||||
andx361 and 1.0 1 -> NaN Invalid_operation
|
||||
andx362 and 1E+1 1 -> NaN Invalid_operation
|
||||
andx363 and 0.0 1 -> NaN Invalid_operation
|
||||
andx364 and 0E+1 1 -> NaN Invalid_operation
|
||||
andx365 and 9.9 1 -> NaN Invalid_operation
|
||||
andx366 and 9E+1 1 -> NaN Invalid_operation
|
||||
andx371 and 0 1.0 -> NaN Invalid_operation
|
||||
andx372 and 0 1E+1 -> NaN Invalid_operation
|
||||
andx373 and 0 0.0 -> NaN Invalid_operation
|
||||
andx374 and 0 0E+1 -> NaN Invalid_operation
|
||||
andx375 and 0 9.9 -> NaN Invalid_operation
|
||||
andx376 and 0 9E+1 -> NaN Invalid_operation
|
||||
|
||||
-- All Specials are in error
|
||||
andx780 and -Inf -Inf -> NaN Invalid_operation
|
||||
andx781 and -Inf -1000 -> NaN Invalid_operation
|
||||
andx782 and -Inf -1 -> NaN Invalid_operation
|
||||
andx783 and -Inf -0 -> NaN Invalid_operation
|
||||
andx784 and -Inf 0 -> NaN Invalid_operation
|
||||
andx785 and -Inf 1 -> NaN Invalid_operation
|
||||
andx786 and -Inf 1000 -> NaN Invalid_operation
|
||||
andx787 and -1000 -Inf -> NaN Invalid_operation
|
||||
andx788 and -Inf -Inf -> NaN Invalid_operation
|
||||
andx789 and -1 -Inf -> NaN Invalid_operation
|
||||
andx790 and -0 -Inf -> NaN Invalid_operation
|
||||
andx791 and 0 -Inf -> NaN Invalid_operation
|
||||
andx792 and 1 -Inf -> NaN Invalid_operation
|
||||
andx793 and 1000 -Inf -> NaN Invalid_operation
|
||||
andx794 and Inf -Inf -> NaN Invalid_operation
|
||||
|
||||
andx800 and Inf -Inf -> NaN Invalid_operation
|
||||
andx801 and Inf -1000 -> NaN Invalid_operation
|
||||
andx802 and Inf -1 -> NaN Invalid_operation
|
||||
andx803 and Inf -0 -> NaN Invalid_operation
|
||||
andx804 and Inf 0 -> NaN Invalid_operation
|
||||
andx805 and Inf 1 -> NaN Invalid_operation
|
||||
andx806 and Inf 1000 -> NaN Invalid_operation
|
||||
andx807 and Inf Inf -> NaN Invalid_operation
|
||||
andx808 and -1000 Inf -> NaN Invalid_operation
|
||||
andx809 and -Inf Inf -> NaN Invalid_operation
|
||||
andx810 and -1 Inf -> NaN Invalid_operation
|
||||
andx811 and -0 Inf -> NaN Invalid_operation
|
||||
andx812 and 0 Inf -> NaN Invalid_operation
|
||||
andx813 and 1 Inf -> NaN Invalid_operation
|
||||
andx814 and 1000 Inf -> NaN Invalid_operation
|
||||
andx815 and Inf Inf -> NaN Invalid_operation
|
||||
|
||||
andx821 and NaN -Inf -> NaN Invalid_operation
|
||||
andx822 and NaN -1000 -> NaN Invalid_operation
|
||||
andx823 and NaN -1 -> NaN Invalid_operation
|
||||
andx824 and NaN -0 -> NaN Invalid_operation
|
||||
andx825 and NaN 0 -> NaN Invalid_operation
|
||||
andx826 and NaN 1 -> NaN Invalid_operation
|
||||
andx827 and NaN 1000 -> NaN Invalid_operation
|
||||
andx828 and NaN Inf -> NaN Invalid_operation
|
||||
andx829 and NaN NaN -> NaN Invalid_operation
|
||||
andx830 and -Inf NaN -> NaN Invalid_operation
|
||||
andx831 and -1000 NaN -> NaN Invalid_operation
|
||||
andx832 and -1 NaN -> NaN Invalid_operation
|
||||
andx833 and -0 NaN -> NaN Invalid_operation
|
||||
andx834 and 0 NaN -> NaN Invalid_operation
|
||||
andx835 and 1 NaN -> NaN Invalid_operation
|
||||
andx836 and 1000 NaN -> NaN Invalid_operation
|
||||
andx837 and Inf NaN -> NaN Invalid_operation
|
||||
|
||||
andx841 and sNaN -Inf -> NaN Invalid_operation
|
||||
andx842 and sNaN -1000 -> NaN Invalid_operation
|
||||
andx843 and sNaN -1 -> NaN Invalid_operation
|
||||
andx844 and sNaN -0 -> NaN Invalid_operation
|
||||
andx845 and sNaN 0 -> NaN Invalid_operation
|
||||
andx846 and sNaN 1 -> NaN Invalid_operation
|
||||
andx847 and sNaN 1000 -> NaN Invalid_operation
|
||||
andx848 and sNaN NaN -> NaN Invalid_operation
|
||||
andx849 and sNaN sNaN -> NaN Invalid_operation
|
||||
andx850 and NaN sNaN -> NaN Invalid_operation
|
||||
andx851 and -Inf sNaN -> NaN Invalid_operation
|
||||
andx852 and -1000 sNaN -> NaN Invalid_operation
|
||||
andx853 and -1 sNaN -> NaN Invalid_operation
|
||||
andx854 and -0 sNaN -> NaN Invalid_operation
|
||||
andx855 and 0 sNaN -> NaN Invalid_operation
|
||||
andx856 and 1 sNaN -> NaN Invalid_operation
|
||||
andx857 and 1000 sNaN -> NaN Invalid_operation
|
||||
andx858 and Inf sNaN -> NaN Invalid_operation
|
||||
andx859 and NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
andx861 and NaN1 -Inf -> NaN Invalid_operation
|
||||
andx862 and +NaN2 -1000 -> NaN Invalid_operation
|
||||
andx863 and NaN3 1000 -> NaN Invalid_operation
|
||||
andx864 and NaN4 Inf -> NaN Invalid_operation
|
||||
andx865 and NaN5 +NaN6 -> NaN Invalid_operation
|
||||
andx866 and -Inf NaN7 -> NaN Invalid_operation
|
||||
andx867 and -1000 NaN8 -> NaN Invalid_operation
|
||||
andx868 and 1000 NaN9 -> NaN Invalid_operation
|
||||
andx869 and Inf +NaN10 -> NaN Invalid_operation
|
||||
andx871 and sNaN11 -Inf -> NaN Invalid_operation
|
||||
andx872 and sNaN12 -1000 -> NaN Invalid_operation
|
||||
andx873 and sNaN13 1000 -> NaN Invalid_operation
|
||||
andx874 and sNaN14 NaN17 -> NaN Invalid_operation
|
||||
andx875 and sNaN15 sNaN18 -> NaN Invalid_operation
|
||||
andx876 and NaN16 sNaN19 -> NaN Invalid_operation
|
||||
andx877 and -Inf +sNaN20 -> NaN Invalid_operation
|
||||
andx878 and -1000 sNaN21 -> NaN Invalid_operation
|
||||
andx879 and 1000 sNaN22 -> NaN Invalid_operation
|
||||
andx880 and Inf sNaN23 -> NaN Invalid_operation
|
||||
andx881 and +NaN25 +sNaN24 -> NaN Invalid_operation
|
||||
andx882 and -NaN26 NaN28 -> NaN Invalid_operation
|
||||
andx883 and -sNaN27 sNaN29 -> NaN Invalid_operation
|
||||
andx884 and 1000 -NaN30 -> NaN Invalid_operation
|
||||
andx885 and 1000 -sNaN31 -> NaN Invalid_operation
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,211 @@
|
||||
------------------------------------------------------------------------
|
||||
-- clamp.decTest -- clamped exponent tests (format-independent) --
|
||||
-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- This set of tests uses the same limits as the 8-byte concrete
|
||||
-- representation, but applies clamping without using format-specific
|
||||
-- conversions.
|
||||
|
||||
extended: 1
|
||||
precision: 16
|
||||
rounding: half_even
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
clamp: 1
|
||||
|
||||
-- General testcases
|
||||
|
||||
-- Normality
|
||||
clam010 apply 1234567890123456 -> 1234567890123456
|
||||
clam011 apply 1234567890123456.0 -> 1234567890123456 Rounded
|
||||
clam012 apply 1234567890123456.1 -> 1234567890123456 Rounded Inexact
|
||||
clam013 apply -1234567890123456 -> -1234567890123456
|
||||
clam014 apply -1234567890123456.0 -> -1234567890123456 Rounded
|
||||
clam015 apply -1234567890123456.1 -> -1234567890123456 Rounded Inexact
|
||||
|
||||
|
||||
-- Nmax and similar
|
||||
clam022 apply 9.999999999999999E+384 -> 9.999999999999999E+384
|
||||
clam024 apply 1.234567890123456E+384 -> 1.234567890123456E+384
|
||||
-- fold-downs (more below)
|
||||
clam030 apply 1.23E+384 -> 1.230000000000000E+384 Clamped
|
||||
clam032 apply 1E+384 -> 1.000000000000000E+384 Clamped
|
||||
|
||||
clam051 apply 12345 -> 12345
|
||||
clam053 apply 1234 -> 1234
|
||||
clam055 apply 123 -> 123
|
||||
clam057 apply 12 -> 12
|
||||
clam059 apply 1 -> 1
|
||||
clam061 apply 1.23 -> 1.23
|
||||
clam063 apply 123.45 -> 123.45
|
||||
|
||||
-- Nmin and below
|
||||
clam071 apply 1E-383 -> 1E-383
|
||||
clam073 apply 1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
clam075 apply 1.000000000000001E-383 -> 1.000000000000001E-383
|
||||
|
||||
clam077 apply 0.100000000000000E-383 -> 1.00000000000000E-384 Subnormal
|
||||
clam079 apply 0.000000000000010E-383 -> 1.0E-397 Subnormal
|
||||
clam081 apply 0.00000000000001E-383 -> 1E-397 Subnormal
|
||||
clam083 apply 0.000000000000001E-383 -> 1E-398 Subnormal
|
||||
|
||||
-- underflows
|
||||
clam090 apply 1e-398 -> #0000000000000001 Subnormal
|
||||
clam091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded
|
||||
clam092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
|
||||
-- Same again, negatives
|
||||
-- Nmax and similar
|
||||
clam122 apply -9.999999999999999E+384 -> -9.999999999999999E+384
|
||||
clam124 apply -1.234567890123456E+384 -> -1.234567890123456E+384
|
||||
-- fold-downs (more below)
|
||||
clam130 apply -1.23E+384 -> -1.230000000000000E+384 Clamped
|
||||
clam132 apply -1E+384 -> -1.000000000000000E+384 Clamped
|
||||
|
||||
clam151 apply -12345 -> -12345
|
||||
clam153 apply -1234 -> -1234
|
||||
clam155 apply -123 -> -123
|
||||
clam157 apply -12 -> -12
|
||||
clam159 apply -1 -> -1
|
||||
clam161 apply -1.23 -> -1.23
|
||||
clam163 apply -123.45 -> -123.45
|
||||
|
||||
-- Nmin and below
|
||||
clam171 apply -1E-383 -> -1E-383
|
||||
clam173 apply -1.000000000000000E-383 -> -1.000000000000000E-383
|
||||
clam175 apply -1.000000000000001E-383 -> -1.000000000000001E-383
|
||||
|
||||
clam177 apply -0.100000000000000E-383 -> -1.00000000000000E-384 Subnormal
|
||||
clam179 apply -0.000000000000010E-383 -> -1.0E-397 Subnormal
|
||||
clam181 apply -0.00000000000001E-383 -> -1E-397 Subnormal
|
||||
clam183 apply -0.000000000000001E-383 -> -1E-398 Subnormal
|
||||
|
||||
-- underflows
|
||||
clam189 apply -1e-398 -> #8000000000000001 Subnormal
|
||||
clam190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
|
||||
clam191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded
|
||||
clam192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
|
||||
clam196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
clam199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
|
||||
|
||||
-- zeros
|
||||
clam401 apply 0E-500 -> 0E-398 Clamped
|
||||
clam402 apply 0E-400 -> 0E-398 Clamped
|
||||
clam403 apply 0E-398 -> 0E-398
|
||||
clam404 apply 0.000000000000000E-383 -> 0E-398
|
||||
clam405 apply 0E-2 -> 0.00
|
||||
clam406 apply 0 -> 0
|
||||
clam407 apply 0E+3 -> 0E+3
|
||||
clam408 apply 0E+369 -> 0E+369
|
||||
-- clamped zeros...
|
||||
clam410 apply 0E+370 -> 0E+369 Clamped
|
||||
clam411 apply 0E+384 -> 0E+369 Clamped
|
||||
clam412 apply 0E+400 -> 0E+369 Clamped
|
||||
clam413 apply 0E+500 -> 0E+369 Clamped
|
||||
|
||||
-- negative zeros
|
||||
clam420 apply -0E-500 -> -0E-398 Clamped
|
||||
clam421 apply -0E-400 -> -0E-398 Clamped
|
||||
clam422 apply -0E-398 -> -0E-398
|
||||
clam423 apply -0.000000000000000E-383 -> -0E-398
|
||||
clam424 apply -0E-2 -> -0.00
|
||||
clam425 apply -0 -> -0
|
||||
clam426 apply -0E+3 -> -0E+3
|
||||
clam427 apply -0E+369 -> -0E+369
|
||||
-- clamped zeros...
|
||||
clam431 apply -0E+370 -> -0E+369 Clamped
|
||||
clam432 apply -0E+384 -> -0E+369 Clamped
|
||||
clam433 apply -0E+400 -> -0E+369 Clamped
|
||||
clam434 apply -0E+500 -> -0E+369 Clamped
|
||||
|
||||
-- fold-down full sequence
|
||||
clam601 apply 1E+384 -> 1.000000000000000E+384 Clamped
|
||||
clam603 apply 1E+383 -> 1.00000000000000E+383 Clamped
|
||||
clam605 apply 1E+382 -> 1.0000000000000E+382 Clamped
|
||||
clam607 apply 1E+381 -> 1.000000000000E+381 Clamped
|
||||
clam609 apply 1E+380 -> 1.00000000000E+380 Clamped
|
||||
clam611 apply 1E+379 -> 1.0000000000E+379 Clamped
|
||||
clam613 apply 1E+378 -> 1.000000000E+378 Clamped
|
||||
clam615 apply 1E+377 -> 1.00000000E+377 Clamped
|
||||
clam617 apply 1E+376 -> 1.0000000E+376 Clamped
|
||||
clam619 apply 1E+375 -> 1.000000E+375 Clamped
|
||||
clam621 apply 1E+374 -> 1.00000E+374 Clamped
|
||||
clam623 apply 1E+373 -> 1.0000E+373 Clamped
|
||||
clam625 apply 1E+372 -> 1.000E+372 Clamped
|
||||
clam627 apply 1E+371 -> 1.00E+371 Clamped
|
||||
clam629 apply 1E+370 -> 1.0E+370 Clamped
|
||||
clam631 apply 1E+369 -> 1E+369
|
||||
clam633 apply 1E+368 -> 1E+368
|
||||
-- same with 9s
|
||||
clam641 apply 9E+384 -> 9.000000000000000E+384 Clamped
|
||||
clam643 apply 9E+383 -> 9.00000000000000E+383 Clamped
|
||||
clam645 apply 9E+382 -> 9.0000000000000E+382 Clamped
|
||||
clam647 apply 9E+381 -> 9.000000000000E+381 Clamped
|
||||
clam649 apply 9E+380 -> 9.00000000000E+380 Clamped
|
||||
clam651 apply 9E+379 -> 9.0000000000E+379 Clamped
|
||||
clam653 apply 9E+378 -> 9.000000000E+378 Clamped
|
||||
clam655 apply 9E+377 -> 9.00000000E+377 Clamped
|
||||
clam657 apply 9E+376 -> 9.0000000E+376 Clamped
|
||||
clam659 apply 9E+375 -> 9.000000E+375 Clamped
|
||||
clam661 apply 9E+374 -> 9.00000E+374 Clamped
|
||||
clam663 apply 9E+373 -> 9.0000E+373 Clamped
|
||||
clam665 apply 9E+372 -> 9.000E+372 Clamped
|
||||
clam667 apply 9E+371 -> 9.00E+371 Clamped
|
||||
clam669 apply 9E+370 -> 9.0E+370 Clamped
|
||||
clam671 apply 9E+369 -> 9E+369
|
||||
clam673 apply 9E+368 -> 9E+368
|
||||
|
||||
-- subnormals clamped to 0-Etiny
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
clam681 apply 7E-398 -> 7E-398 Subnormal
|
||||
clam682 apply 0E-398 -> 0E-398
|
||||
clam683 apply 7E-399 -> 1E-398 Subnormal Underflow Inexact Rounded
|
||||
clam684 apply 4E-399 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
|
||||
clam685 apply 7E-400 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
|
||||
clam686 apply 7E-401 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
|
||||
clam687 apply 0E-399 -> 0E-398 Clamped
|
||||
clam688 apply 0E-400 -> 0E-398 Clamped
|
||||
clam689 apply 0E-401 -> 0E-398 Clamped
|
||||
|
||||
-- example from documentation
|
||||
precision: 7
|
||||
rounding: half_even
|
||||
maxExponent: +96
|
||||
minExponent: -95
|
||||
|
||||
clamp: 0
|
||||
clam700 apply 1.23E+96 -> 1.23E+96
|
||||
|
||||
clamp: 1
|
||||
clam701 apply 1.23E+96 -> 1.230000E+96 Clamped
|
@ -0,0 +1,131 @@
|
||||
------------------------------------------------------------------------
|
||||
-- class.decTest -- Class operations --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- [New 2006.11.27]
|
||||
|
||||
precision: 9
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
clasx001 class 0 -> +Zero
|
||||
clasx002 class 0.00 -> +Zero
|
||||
clasx003 class 0E+5 -> +Zero
|
||||
clasx004 class 1E-1007 -> +Subnormal
|
||||
clasx005 class 0.1E-999 -> +Subnormal
|
||||
clasx006 class 0.99999999E-999 -> +Subnormal
|
||||
clasx007 class 1.00000000E-999 -> +Normal
|
||||
clasx008 class 1E-999 -> +Normal
|
||||
clasx009 class 1E-100 -> +Normal
|
||||
clasx010 class 1E-10 -> +Normal
|
||||
clasx012 class 1E-1 -> +Normal
|
||||
clasx013 class 1 -> +Normal
|
||||
clasx014 class 2.50 -> +Normal
|
||||
clasx015 class 100.100 -> +Normal
|
||||
clasx016 class 1E+30 -> +Normal
|
||||
clasx017 class 1E+999 -> +Normal
|
||||
clasx018 class 9.99999999E+999 -> +Normal
|
||||
clasx019 class Inf -> +Infinity
|
||||
|
||||
clasx021 class -0 -> -Zero
|
||||
clasx022 class -0.00 -> -Zero
|
||||
clasx023 class -0E+5 -> -Zero
|
||||
clasx024 class -1E-1007 -> -Subnormal
|
||||
clasx025 class -0.1E-999 -> -Subnormal
|
||||
clasx026 class -0.99999999E-999 -> -Subnormal
|
||||
clasx027 class -1.00000000E-999 -> -Normal
|
||||
clasx028 class -1E-999 -> -Normal
|
||||
clasx029 class -1E-100 -> -Normal
|
||||
clasx030 class -1E-10 -> -Normal
|
||||
clasx032 class -1E-1 -> -Normal
|
||||
clasx033 class -1 -> -Normal
|
||||
clasx034 class -2.50 -> -Normal
|
||||
clasx035 class -100.100 -> -Normal
|
||||
clasx036 class -1E+30 -> -Normal
|
||||
clasx037 class -1E+999 -> -Normal
|
||||
clasx038 class -9.99999999E+999 -> -Normal
|
||||
clasx039 class -Inf -> -Infinity
|
||||
|
||||
clasx041 class NaN -> NaN
|
||||
clasx042 class -NaN -> NaN
|
||||
clasx043 class +NaN12345 -> NaN
|
||||
clasx044 class sNaN -> sNaN
|
||||
clasx045 class -sNaN -> sNaN
|
||||
clasx046 class +sNaN12345 -> sNaN
|
||||
|
||||
|
||||
-- decimal64 bounds
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
clasx201 class 0 -> +Zero
|
||||
clasx202 class 0.00 -> +Zero
|
||||
clasx203 class 0E+5 -> +Zero
|
||||
clasx204 class 1E-396 -> +Subnormal
|
||||
clasx205 class 0.1E-383 -> +Subnormal
|
||||
clasx206 class 0.999999999999999E-383 -> +Subnormal
|
||||
clasx207 class 1.000000000000000E-383 -> +Normal
|
||||
clasx208 class 1E-383 -> +Normal
|
||||
clasx209 class 1E-100 -> +Normal
|
||||
clasx210 class 1E-10 -> +Normal
|
||||
clasx212 class 1E-1 -> +Normal
|
||||
clasx213 class 1 -> +Normal
|
||||
clasx214 class 2.50 -> +Normal
|
||||
clasx215 class 100.100 -> +Normal
|
||||
clasx216 class 1E+30 -> +Normal
|
||||
clasx217 class 1E+384 -> +Normal
|
||||
clasx218 class 9.999999999999999E+384 -> +Normal
|
||||
clasx219 class Inf -> +Infinity
|
||||
|
||||
clasx221 class -0 -> -Zero
|
||||
clasx222 class -0.00 -> -Zero
|
||||
clasx223 class -0E+5 -> -Zero
|
||||
clasx224 class -1E-396 -> -Subnormal
|
||||
clasx225 class -0.1E-383 -> -Subnormal
|
||||
clasx226 class -0.999999999999999E-383 -> -Subnormal
|
||||
clasx227 class -1.000000000000000E-383 -> -Normal
|
||||
clasx228 class -1E-383 -> -Normal
|
||||
clasx229 class -1E-100 -> -Normal
|
||||
clasx230 class -1E-10 -> -Normal
|
||||
clasx232 class -1E-1 -> -Normal
|
||||
clasx233 class -1 -> -Normal
|
||||
clasx234 class -2.50 -> -Normal
|
||||
clasx235 class -100.100 -> -Normal
|
||||
clasx236 class -1E+30 -> -Normal
|
||||
clasx237 class -1E+384 -> -Normal
|
||||
clasx238 class -9.999999999999999E+384 -> -Normal
|
||||
clasx239 class -Inf -> -Infinity
|
||||
|
||||
clasx241 class NaN -> NaN
|
||||
clasx242 class -NaN -> NaN
|
||||
clasx243 class +NaN12345 -> NaN
|
||||
clasx244 class sNaN -> sNaN
|
||||
clasx245 class -sNaN -> sNaN
|
||||
clasx246 class +sNaN12345 -> sNaN
|
||||
|
||||
|
||||
|
@ -0,0 +1,758 @@
|
||||
------------------------------------------------------------------------
|
||||
-- compare.decTest -- decimal comparison that allows quiet NaNs --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
|
||||
extended: 1
|
||||
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minexponent: -999
|
||||
|
||||
-- sanity checks
|
||||
comx001 compare -2 -2 -> 0
|
||||
comx002 compare -2 -1 -> -1
|
||||
comx003 compare -2 0 -> -1
|
||||
comx004 compare -2 1 -> -1
|
||||
comx005 compare -2 2 -> -1
|
||||
comx006 compare -1 -2 -> 1
|
||||
comx007 compare -1 -1 -> 0
|
||||
comx008 compare -1 0 -> -1
|
||||
comx009 compare -1 1 -> -1
|
||||
comx010 compare -1 2 -> -1
|
||||
comx011 compare 0 -2 -> 1
|
||||
comx012 compare 0 -1 -> 1
|
||||
comx013 compare 0 0 -> 0
|
||||
comx014 compare 0 1 -> -1
|
||||
comx015 compare 0 2 -> -1
|
||||
comx016 compare 1 -2 -> 1
|
||||
comx017 compare 1 -1 -> 1
|
||||
comx018 compare 1 0 -> 1
|
||||
comx019 compare 1 1 -> 0
|
||||
comx020 compare 1 2 -> -1
|
||||
comx021 compare 2 -2 -> 1
|
||||
comx022 compare 2 -1 -> 1
|
||||
comx023 compare 2 0 -> 1
|
||||
comx025 compare 2 1 -> 1
|
||||
comx026 compare 2 2 -> 0
|
||||
|
||||
comx031 compare -20 -20 -> 0
|
||||
comx032 compare -20 -10 -> -1
|
||||
comx033 compare -20 00 -> -1
|
||||
comx034 compare -20 10 -> -1
|
||||
comx035 compare -20 20 -> -1
|
||||
comx036 compare -10 -20 -> 1
|
||||
comx037 compare -10 -10 -> 0
|
||||
comx038 compare -10 00 -> -1
|
||||
comx039 compare -10 10 -> -1
|
||||
comx040 compare -10 20 -> -1
|
||||
comx041 compare 00 -20 -> 1
|
||||
comx042 compare 00 -10 -> 1
|
||||
comx043 compare 00 00 -> 0
|
||||
comx044 compare 00 10 -> -1
|
||||
comx045 compare 00 20 -> -1
|
||||
comx046 compare 10 -20 -> 1
|
||||
comx047 compare 10 -10 -> 1
|
||||
comx048 compare 10 00 -> 1
|
||||
comx049 compare 10 10 -> 0
|
||||
comx050 compare 10 20 -> -1
|
||||
comx051 compare 20 -20 -> 1
|
||||
comx052 compare 20 -10 -> 1
|
||||
comx053 compare 20 00 -> 1
|
||||
comx055 compare 20 10 -> 1
|
||||
comx056 compare 20 20 -> 0
|
||||
|
||||
comx061 compare -2.0 -2.0 -> 0
|
||||
comx062 compare -2.0 -1.0 -> -1
|
||||
comx063 compare -2.0 0.0 -> -1
|
||||
comx064 compare -2.0 1.0 -> -1
|
||||
comx065 compare -2.0 2.0 -> -1
|
||||
comx066 compare -1.0 -2.0 -> 1
|
||||
comx067 compare -1.0 -1.0 -> 0
|
||||
comx068 compare -1.0 0.0 -> -1
|
||||
comx069 compare -1.0 1.0 -> -1
|
||||
comx070 compare -1.0 2.0 -> -1
|
||||
comx071 compare 0.0 -2.0 -> 1
|
||||
comx072 compare 0.0 -1.0 -> 1
|
||||
comx073 compare 0.0 0.0 -> 0
|
||||
comx074 compare 0.0 1.0 -> -1
|
||||
comx075 compare 0.0 2.0 -> -1
|
||||
comx076 compare 1.0 -2.0 -> 1
|
||||
comx077 compare 1.0 -1.0 -> 1
|
||||
comx078 compare 1.0 0.0 -> 1
|
||||
comx079 compare 1.0 1.0 -> 0
|
||||
comx080 compare 1.0 2.0 -> -1
|
||||
comx081 compare 2.0 -2.0 -> 1
|
||||
comx082 compare 2.0 -1.0 -> 1
|
||||
comx083 compare 2.0 0.0 -> 1
|
||||
comx085 compare 2.0 1.0 -> 1
|
||||
comx086 compare 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
maxexponent: 999999999
|
||||
minexponent: -999999999
|
||||
comx095 compare 9.99999999E+999999999 9.99999999E+999999999 -> 0
|
||||
comx096 compare -9.99999999E+999999999 9.99999999E+999999999 -> -1
|
||||
comx097 compare 9.99999999E+999999999 -9.99999999E+999999999 -> 1
|
||||
comx098 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
comx100 compare 7.0 7.0 -> 0
|
||||
comx101 compare 7.0 7 -> 0
|
||||
comx102 compare 7 7.0 -> 0
|
||||
comx103 compare 7E+0 7.0 -> 0
|
||||
comx104 compare 70E-1 7.0 -> 0
|
||||
comx105 compare 0.7E+1 7 -> 0
|
||||
comx106 compare 70E-1 7 -> 0
|
||||
comx107 compare 7.0 7E+0 -> 0
|
||||
comx108 compare 7.0 70E-1 -> 0
|
||||
comx109 compare 7 0.7E+1 -> 0
|
||||
comx110 compare 7 70E-1 -> 0
|
||||
|
||||
comx120 compare 8.0 7.0 -> 1
|
||||
comx121 compare 8.0 7 -> 1
|
||||
comx122 compare 8 7.0 -> 1
|
||||
comx123 compare 8E+0 7.0 -> 1
|
||||
comx124 compare 80E-1 7.0 -> 1
|
||||
comx125 compare 0.8E+1 7 -> 1
|
||||
comx126 compare 80E-1 7 -> 1
|
||||
comx127 compare 8.0 7E+0 -> 1
|
||||
comx128 compare 8.0 70E-1 -> 1
|
||||
comx129 compare 8 0.7E+1 -> 1
|
||||
comx130 compare 8 70E-1 -> 1
|
||||
|
||||
comx140 compare 8.0 9.0 -> -1
|
||||
comx141 compare 8.0 9 -> -1
|
||||
comx142 compare 8 9.0 -> -1
|
||||
comx143 compare 8E+0 9.0 -> -1
|
||||
comx144 compare 80E-1 9.0 -> -1
|
||||
comx145 compare 0.8E+1 9 -> -1
|
||||
comx146 compare 80E-1 9 -> -1
|
||||
comx147 compare 8.0 9E+0 -> -1
|
||||
comx148 compare 8.0 90E-1 -> -1
|
||||
comx149 compare 8 0.9E+1 -> -1
|
||||
comx150 compare 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
comx200 compare -7.0 7.0 -> -1
|
||||
comx201 compare -7.0 7 -> -1
|
||||
comx202 compare -7 7.0 -> -1
|
||||
comx203 compare -7E+0 7.0 -> -1
|
||||
comx204 compare -70E-1 7.0 -> -1
|
||||
comx205 compare -0.7E+1 7 -> -1
|
||||
comx206 compare -70E-1 7 -> -1
|
||||
comx207 compare -7.0 7E+0 -> -1
|
||||
comx208 compare -7.0 70E-1 -> -1
|
||||
comx209 compare -7 0.7E+1 -> -1
|
||||
comx210 compare -7 70E-1 -> -1
|
||||
|
||||
comx220 compare -8.0 7.0 -> -1
|
||||
comx221 compare -8.0 7 -> -1
|
||||
comx222 compare -8 7.0 -> -1
|
||||
comx223 compare -8E+0 7.0 -> -1
|
||||
comx224 compare -80E-1 7.0 -> -1
|
||||
comx225 compare -0.8E+1 7 -> -1
|
||||
comx226 compare -80E-1 7 -> -1
|
||||
comx227 compare -8.0 7E+0 -> -1
|
||||
comx228 compare -8.0 70E-1 -> -1
|
||||
comx229 compare -8 0.7E+1 -> -1
|
||||
comx230 compare -8 70E-1 -> -1
|
||||
|
||||
comx240 compare -8.0 9.0 -> -1
|
||||
comx241 compare -8.0 9 -> -1
|
||||
comx242 compare -8 9.0 -> -1
|
||||
comx243 compare -8E+0 9.0 -> -1
|
||||
comx244 compare -80E-1 9.0 -> -1
|
||||
comx245 compare -0.8E+1 9 -> -1
|
||||
comx246 compare -80E-1 9 -> -1
|
||||
comx247 compare -8.0 9E+0 -> -1
|
||||
comx248 compare -8.0 90E-1 -> -1
|
||||
comx249 compare -8 0.9E+1 -> -1
|
||||
comx250 compare -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
comx300 compare 7.0 -7.0 -> 1
|
||||
comx301 compare 7.0 -7 -> 1
|
||||
comx302 compare 7 -7.0 -> 1
|
||||
comx303 compare 7E+0 -7.0 -> 1
|
||||
comx304 compare 70E-1 -7.0 -> 1
|
||||
comx305 compare .7E+1 -7 -> 1
|
||||
comx306 compare 70E-1 -7 -> 1
|
||||
comx307 compare 7.0 -7E+0 -> 1
|
||||
comx308 compare 7.0 -70E-1 -> 1
|
||||
comx309 compare 7 -.7E+1 -> 1
|
||||
comx310 compare 7 -70E-1 -> 1
|
||||
|
||||
comx320 compare 8.0 -7.0 -> 1
|
||||
comx321 compare 8.0 -7 -> 1
|
||||
comx322 compare 8 -7.0 -> 1
|
||||
comx323 compare 8E+0 -7.0 -> 1
|
||||
comx324 compare 80E-1 -7.0 -> 1
|
||||
comx325 compare .8E+1 -7 -> 1
|
||||
comx326 compare 80E-1 -7 -> 1
|
||||
comx327 compare 8.0 -7E+0 -> 1
|
||||
comx328 compare 8.0 -70E-1 -> 1
|
||||
comx329 compare 8 -.7E+1 -> 1
|
||||
comx330 compare 8 -70E-1 -> 1
|
||||
|
||||
comx340 compare 8.0 -9.0 -> 1
|
||||
comx341 compare 8.0 -9 -> 1
|
||||
comx342 compare 8 -9.0 -> 1
|
||||
comx343 compare 8E+0 -9.0 -> 1
|
||||
comx344 compare 80E-1 -9.0 -> 1
|
||||
comx345 compare .8E+1 -9 -> 1
|
||||
comx346 compare 80E-1 -9 -> 1
|
||||
comx347 compare 8.0 -9E+0 -> 1
|
||||
comx348 compare 8.0 -90E-1 -> 1
|
||||
comx349 compare 8 -.9E+1 -> 1
|
||||
comx350 compare 8 -90E-1 -> 1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
comx400 compare -7.0 -7.0 -> 0
|
||||
comx401 compare -7.0 -7 -> 0
|
||||
comx402 compare -7 -7.0 -> 0
|
||||
comx403 compare -7E+0 -7.0 -> 0
|
||||
comx404 compare -70E-1 -7.0 -> 0
|
||||
comx405 compare -.7E+1 -7 -> 0
|
||||
comx406 compare -70E-1 -7 -> 0
|
||||
comx407 compare -7.0 -7E+0 -> 0
|
||||
comx408 compare -7.0 -70E-1 -> 0
|
||||
comx409 compare -7 -.7E+1 -> 0
|
||||
comx410 compare -7 -70E-1 -> 0
|
||||
|
||||
comx420 compare -8.0 -7.0 -> -1
|
||||
comx421 compare -8.0 -7 -> -1
|
||||
comx422 compare -8 -7.0 -> -1
|
||||
comx423 compare -8E+0 -7.0 -> -1
|
||||
comx424 compare -80E-1 -7.0 -> -1
|
||||
comx425 compare -.8E+1 -7 -> -1
|
||||
comx426 compare -80E-1 -7 -> -1
|
||||
comx427 compare -8.0 -7E+0 -> -1
|
||||
comx428 compare -8.0 -70E-1 -> -1
|
||||
comx429 compare -8 -.7E+1 -> -1
|
||||
comx430 compare -8 -70E-1 -> -1
|
||||
|
||||
comx440 compare -8.0 -9.0 -> 1
|
||||
comx441 compare -8.0 -9 -> 1
|
||||
comx442 compare -8 -9.0 -> 1
|
||||
comx443 compare -8E+0 -9.0 -> 1
|
||||
comx444 compare -80E-1 -9.0 -> 1
|
||||
comx445 compare -.8E+1 -9 -> 1
|
||||
comx446 compare -80E-1 -9 -> 1
|
||||
comx447 compare -8.0 -9E+0 -> 1
|
||||
comx448 compare -8.0 -90E-1 -> 1
|
||||
comx449 compare -8 -.9E+1 -> 1
|
||||
comx450 compare -8 -90E-1 -> 1
|
||||
|
||||
-- misalignment traps for little-endian
|
||||
comx451 compare 1.0 0.1 -> 1
|
||||
comx452 compare 0.1 1.0 -> -1
|
||||
comx453 compare 10.0 0.1 -> 1
|
||||
comx454 compare 0.1 10.0 -> -1
|
||||
comx455 compare 100 1.0 -> 1
|
||||
comx456 compare 1.0 100 -> -1
|
||||
comx457 compare 1000 10.0 -> 1
|
||||
comx458 compare 10.0 1000 -> -1
|
||||
comx459 compare 10000 100.0 -> 1
|
||||
comx460 compare 100.0 10000 -> -1
|
||||
comx461 compare 100000 1000.0 -> 1
|
||||
comx462 compare 1000.0 100000 -> -1
|
||||
comx463 compare 1000000 10000.0 -> 1
|
||||
comx464 compare 10000.0 1000000 -> -1
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
precision: 40
|
||||
comx470 compare 123.4560000000000000E789 123.456E789 -> 0
|
||||
comx471 compare 123.456000000000000E-89 123.456E-89 -> 0
|
||||
comx472 compare 123.45600000000000E789 123.456E789 -> 0
|
||||
comx473 compare 123.4560000000000E-89 123.456E-89 -> 0
|
||||
comx474 compare 123.456000000000E789 123.456E789 -> 0
|
||||
comx475 compare 123.45600000000E-89 123.456E-89 -> 0
|
||||
comx476 compare 123.4560000000E789 123.456E789 -> 0
|
||||
comx477 compare 123.456000000E-89 123.456E-89 -> 0
|
||||
comx478 compare 123.45600000E789 123.456E789 -> 0
|
||||
comx479 compare 123.4560000E-89 123.456E-89 -> 0
|
||||
comx480 compare 123.456000E789 123.456E789 -> 0
|
||||
comx481 compare 123.45600E-89 123.456E-89 -> 0
|
||||
comx482 compare 123.4560E789 123.456E789 -> 0
|
||||
comx483 compare 123.456E-89 123.456E-89 -> 0
|
||||
comx484 compare 123.456E-89 123.4560000000000000E-89 -> 0
|
||||
comx485 compare 123.456E789 123.456000000000000E789 -> 0
|
||||
comx486 compare 123.456E-89 123.45600000000000E-89 -> 0
|
||||
comx487 compare 123.456E789 123.4560000000000E789 -> 0
|
||||
comx488 compare 123.456E-89 123.456000000000E-89 -> 0
|
||||
comx489 compare 123.456E789 123.45600000000E789 -> 0
|
||||
comx490 compare 123.456E-89 123.4560000000E-89 -> 0
|
||||
comx491 compare 123.456E789 123.456000000E789 -> 0
|
||||
comx492 compare 123.456E-89 123.45600000E-89 -> 0
|
||||
comx493 compare 123.456E789 123.4560000E789 -> 0
|
||||
comx494 compare 123.456E-89 123.456000E-89 -> 0
|
||||
comx495 compare 123.456E789 123.45600E789 -> 0
|
||||
comx496 compare 123.456E-89 123.4560E-89 -> 0
|
||||
comx497 compare 123.456E789 123.456E789 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
precision: 9
|
||||
comx500 compare 1 1E-15 -> 1
|
||||
comx501 compare 1 1E-14 -> 1
|
||||
comx502 compare 1 1E-13 -> 1
|
||||
comx503 compare 1 1E-12 -> 1
|
||||
comx504 compare 1 1E-11 -> 1
|
||||
comx505 compare 1 1E-10 -> 1
|
||||
comx506 compare 1 1E-9 -> 1
|
||||
comx507 compare 1 1E-8 -> 1
|
||||
comx508 compare 1 1E-7 -> 1
|
||||
comx509 compare 1 1E-6 -> 1
|
||||
comx510 compare 1 1E-5 -> 1
|
||||
comx511 compare 1 1E-4 -> 1
|
||||
comx512 compare 1 1E-3 -> 1
|
||||
comx513 compare 1 1E-2 -> 1
|
||||
comx514 compare 1 1E-1 -> 1
|
||||
comx515 compare 1 1E-0 -> 0
|
||||
comx516 compare 1 1E+1 -> -1
|
||||
comx517 compare 1 1E+2 -> -1
|
||||
comx518 compare 1 1E+3 -> -1
|
||||
comx519 compare 1 1E+4 -> -1
|
||||
comx521 compare 1 1E+5 -> -1
|
||||
comx522 compare 1 1E+6 -> -1
|
||||
comx523 compare 1 1E+7 -> -1
|
||||
comx524 compare 1 1E+8 -> -1
|
||||
comx525 compare 1 1E+9 -> -1
|
||||
comx526 compare 1 1E+10 -> -1
|
||||
comx527 compare 1 1E+11 -> -1
|
||||
comx528 compare 1 1E+12 -> -1
|
||||
comx529 compare 1 1E+13 -> -1
|
||||
comx530 compare 1 1E+14 -> -1
|
||||
comx531 compare 1 1E+15 -> -1
|
||||
-- LR swap
|
||||
comx540 compare 1E-15 1 -> -1
|
||||
comx541 compare 1E-14 1 -> -1
|
||||
comx542 compare 1E-13 1 -> -1
|
||||
comx543 compare 1E-12 1 -> -1
|
||||
comx544 compare 1E-11 1 -> -1
|
||||
comx545 compare 1E-10 1 -> -1
|
||||
comx546 compare 1E-9 1 -> -1
|
||||
comx547 compare 1E-8 1 -> -1
|
||||
comx548 compare 1E-7 1 -> -1
|
||||
comx549 compare 1E-6 1 -> -1
|
||||
comx550 compare 1E-5 1 -> -1
|
||||
comx551 compare 1E-4 1 -> -1
|
||||
comx552 compare 1E-3 1 -> -1
|
||||
comx553 compare 1E-2 1 -> -1
|
||||
comx554 compare 1E-1 1 -> -1
|
||||
comx555 compare 1E-0 1 -> 0
|
||||
comx556 compare 1E+1 1 -> 1
|
||||
comx557 compare 1E+2 1 -> 1
|
||||
comx558 compare 1E+3 1 -> 1
|
||||
comx559 compare 1E+4 1 -> 1
|
||||
comx561 compare 1E+5 1 -> 1
|
||||
comx562 compare 1E+6 1 -> 1
|
||||
comx563 compare 1E+7 1 -> 1
|
||||
comx564 compare 1E+8 1 -> 1
|
||||
comx565 compare 1E+9 1 -> 1
|
||||
comx566 compare 1E+10 1 -> 1
|
||||
comx567 compare 1E+11 1 -> 1
|
||||
comx568 compare 1E+12 1 -> 1
|
||||
comx569 compare 1E+13 1 -> 1
|
||||
comx570 compare 1E+14 1 -> 1
|
||||
comx571 compare 1E+15 1 -> 1
|
||||
-- similar with a useful coefficient, one side only
|
||||
comx580 compare 0.000000987654321 1E-15 -> 1
|
||||
comx581 compare 0.000000987654321 1E-14 -> 1
|
||||
comx582 compare 0.000000987654321 1E-13 -> 1
|
||||
comx583 compare 0.000000987654321 1E-12 -> 1
|
||||
comx584 compare 0.000000987654321 1E-11 -> 1
|
||||
comx585 compare 0.000000987654321 1E-10 -> 1
|
||||
comx586 compare 0.000000987654321 1E-9 -> 1
|
||||
comx587 compare 0.000000987654321 1E-8 -> 1
|
||||
comx588 compare 0.000000987654321 1E-7 -> 1
|
||||
comx589 compare 0.000000987654321 1E-6 -> -1
|
||||
comx590 compare 0.000000987654321 1E-5 -> -1
|
||||
comx591 compare 0.000000987654321 1E-4 -> -1
|
||||
comx592 compare 0.000000987654321 1E-3 -> -1
|
||||
comx593 compare 0.000000987654321 1E-2 -> -1
|
||||
comx594 compare 0.000000987654321 1E-1 -> -1
|
||||
comx595 compare 0.000000987654321 1E-0 -> -1
|
||||
comx596 compare 0.000000987654321 1E+1 -> -1
|
||||
comx597 compare 0.000000987654321 1E+2 -> -1
|
||||
comx598 compare 0.000000987654321 1E+3 -> -1
|
||||
comx599 compare 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
precision: 20
|
||||
comx600 compare 12 12.2345 -> -1
|
||||
comx601 compare 12.0 12.2345 -> -1
|
||||
comx602 compare 12.00 12.2345 -> -1
|
||||
comx603 compare 12.000 12.2345 -> -1
|
||||
comx604 compare 12.0000 12.2345 -> -1
|
||||
comx605 compare 12.00000 12.2345 -> -1
|
||||
comx606 compare 12.000000 12.2345 -> -1
|
||||
comx607 compare 12.0000000 12.2345 -> -1
|
||||
comx608 compare 12.00000000 12.2345 -> -1
|
||||
comx609 compare 12.000000000 12.2345 -> -1
|
||||
comx610 compare 12.1234 12 -> 1
|
||||
comx611 compare 12.1234 12.0 -> 1
|
||||
comx612 compare 12.1234 12.00 -> 1
|
||||
comx613 compare 12.1234 12.000 -> 1
|
||||
comx614 compare 12.1234 12.0000 -> 1
|
||||
comx615 compare 12.1234 12.00000 -> 1
|
||||
comx616 compare 12.1234 12.000000 -> 1
|
||||
comx617 compare 12.1234 12.0000000 -> 1
|
||||
comx618 compare 12.1234 12.00000000 -> 1
|
||||
comx619 compare 12.1234 12.000000000 -> 1
|
||||
comx620 compare -12 -12.2345 -> 1
|
||||
comx621 compare -12.0 -12.2345 -> 1
|
||||
comx622 compare -12.00 -12.2345 -> 1
|
||||
comx623 compare -12.000 -12.2345 -> 1
|
||||
comx624 compare -12.0000 -12.2345 -> 1
|
||||
comx625 compare -12.00000 -12.2345 -> 1
|
||||
comx626 compare -12.000000 -12.2345 -> 1
|
||||
comx627 compare -12.0000000 -12.2345 -> 1
|
||||
comx628 compare -12.00000000 -12.2345 -> 1
|
||||
comx629 compare -12.000000000 -12.2345 -> 1
|
||||
comx630 compare -12.1234 -12 -> -1
|
||||
comx631 compare -12.1234 -12.0 -> -1
|
||||
comx632 compare -12.1234 -12.00 -> -1
|
||||
comx633 compare -12.1234 -12.000 -> -1
|
||||
comx634 compare -12.1234 -12.0000 -> -1
|
||||
comx635 compare -12.1234 -12.00000 -> -1
|
||||
comx636 compare -12.1234 -12.000000 -> -1
|
||||
comx637 compare -12.1234 -12.0000000 -> -1
|
||||
comx638 compare -12.1234 -12.00000000 -> -1
|
||||
comx639 compare -12.1234 -12.000000000 -> -1
|
||||
precision: 9
|
||||
|
||||
-- extended zeros
|
||||
comx640 compare 0 0 -> 0
|
||||
comx641 compare 0 -0 -> 0
|
||||
comx642 compare 0 -0.0 -> 0
|
||||
comx643 compare 0 0.0 -> 0
|
||||
comx644 compare -0 0 -> 0
|
||||
comx645 compare -0 -0 -> 0
|
||||
comx646 compare -0 -0.0 -> 0
|
||||
comx647 compare -0 0.0 -> 0
|
||||
comx648 compare 0.0 0 -> 0
|
||||
comx649 compare 0.0 -0 -> 0
|
||||
comx650 compare 0.0 -0.0 -> 0
|
||||
comx651 compare 0.0 0.0 -> 0
|
||||
comx652 compare -0.0 0 -> 0
|
||||
comx653 compare -0.0 -0 -> 0
|
||||
comx654 compare -0.0 -0.0 -> 0
|
||||
comx655 compare -0.0 0.0 -> 0
|
||||
|
||||
comx656 compare -0E1 0.0 -> 0
|
||||
comx657 compare -0E2 0.0 -> 0
|
||||
comx658 compare 0E1 0.0 -> 0
|
||||
comx659 compare 0E2 0.0 -> 0
|
||||
comx660 compare -0E1 0 -> 0
|
||||
comx661 compare -0E2 0 -> 0
|
||||
comx662 compare 0E1 0 -> 0
|
||||
comx663 compare 0E2 0 -> 0
|
||||
comx664 compare -0E1 -0E1 -> 0
|
||||
comx665 compare -0E2 -0E1 -> 0
|
||||
comx666 compare 0E1 -0E1 -> 0
|
||||
comx667 compare 0E2 -0E1 -> 0
|
||||
comx668 compare -0E1 -0E2 -> 0
|
||||
comx669 compare -0E2 -0E2 -> 0
|
||||
comx670 compare 0E1 -0E2 -> 0
|
||||
comx671 compare 0E2 -0E2 -> 0
|
||||
comx672 compare -0E1 0E1 -> 0
|
||||
comx673 compare -0E2 0E1 -> 0
|
||||
comx674 compare 0E1 0E1 -> 0
|
||||
comx675 compare 0E2 0E1 -> 0
|
||||
comx676 compare -0E1 0E2 -> 0
|
||||
comx677 compare -0E2 0E2 -> 0
|
||||
comx678 compare 0E1 0E2 -> 0
|
||||
comx679 compare 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
precision: 20
|
||||
comx680 compare 12 12 -> 0
|
||||
comx681 compare 12 12.0 -> 0
|
||||
comx682 compare 12 12.00 -> 0
|
||||
comx683 compare 12 12.000 -> 0
|
||||
comx684 compare 12 12.0000 -> 0
|
||||
comx685 compare 12 12.00000 -> 0
|
||||
comx686 compare 12 12.000000 -> 0
|
||||
comx687 compare 12 12.0000000 -> 0
|
||||
comx688 compare 12 12.00000000 -> 0
|
||||
comx689 compare 12 12.000000000 -> 0
|
||||
comx690 compare 12 12 -> 0
|
||||
comx691 compare 12.0 12 -> 0
|
||||
comx692 compare 12.00 12 -> 0
|
||||
comx693 compare 12.000 12 -> 0
|
||||
comx694 compare 12.0000 12 -> 0
|
||||
comx695 compare 12.00000 12 -> 0
|
||||
comx696 compare 12.000000 12 -> 0
|
||||
comx697 compare 12.0000000 12 -> 0
|
||||
comx698 compare 12.00000000 12 -> 0
|
||||
comx699 compare 12.000000000 12 -> 0
|
||||
|
||||
-- long operand checks
|
||||
maxexponent: 999
|
||||
minexponent: -999
|
||||
precision: 9
|
||||
comx701 compare 12345678000 1 -> 1
|
||||
comx702 compare 1 12345678000 -> -1
|
||||
comx703 compare 1234567800 1 -> 1
|
||||
comx704 compare 1 1234567800 -> -1
|
||||
comx705 compare 1234567890 1 -> 1
|
||||
comx706 compare 1 1234567890 -> -1
|
||||
comx707 compare 1234567891 1 -> 1
|
||||
comx708 compare 1 1234567891 -> -1
|
||||
comx709 compare 12345678901 1 -> 1
|
||||
comx710 compare 1 12345678901 -> -1
|
||||
comx711 compare 1234567896 1 -> 1
|
||||
comx712 compare 1 1234567896 -> -1
|
||||
comx713 compare -1234567891 1 -> -1
|
||||
comx714 compare 1 -1234567891 -> 1
|
||||
comx715 compare -12345678901 1 -> -1
|
||||
comx716 compare 1 -12345678901 -> 1
|
||||
comx717 compare -1234567896 1 -> -1
|
||||
comx718 compare 1 -1234567896 -> 1
|
||||
|
||||
precision: 15
|
||||
-- same with plenty of precision
|
||||
comx721 compare 12345678000 1 -> 1
|
||||
comx722 compare 1 12345678000 -> -1
|
||||
comx723 compare 1234567800 1 -> 1
|
||||
comx724 compare 1 1234567800 -> -1
|
||||
comx725 compare 1234567890 1 -> 1
|
||||
comx726 compare 1 1234567890 -> -1
|
||||
comx727 compare 1234567891 1 -> 1
|
||||
comx728 compare 1 1234567891 -> -1
|
||||
comx729 compare 12345678901 1 -> 1
|
||||
comx730 compare 1 12345678901 -> -1
|
||||
comx731 compare 1234567896 1 -> 1
|
||||
comx732 compare 1 1234567896 -> -1
|
||||
|
||||
-- residue cases
|
||||
precision: 5
|
||||
comx740 compare 1 0.9999999 -> 1
|
||||
comx741 compare 1 0.999999 -> 1
|
||||
comx742 compare 1 0.99999 -> 1
|
||||
comx743 compare 1 1.0000 -> 0
|
||||
comx744 compare 1 1.00001 -> -1
|
||||
comx745 compare 1 1.000001 -> -1
|
||||
comx746 compare 1 1.0000001 -> -1
|
||||
comx750 compare 0.9999999 1 -> -1
|
||||
comx751 compare 0.999999 1 -> -1
|
||||
comx752 compare 0.99999 1 -> -1
|
||||
comx753 compare 1.0000 1 -> 0
|
||||
comx754 compare 1.00001 1 -> 1
|
||||
comx755 compare 1.000001 1 -> 1
|
||||
comx756 compare 1.0000001 1 -> 1
|
||||
|
||||
-- a selection of longies
|
||||
comx760 compare -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
|
||||
comx761 compare -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
|
||||
comx762 compare -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
|
||||
comx763 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
-- precisions above or below the difference should have no effect
|
||||
precision: 11
|
||||
comx764 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 10
|
||||
comx765 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 9
|
||||
comx766 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 8
|
||||
comx767 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 7
|
||||
comx768 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 6
|
||||
comx769 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 5
|
||||
comx770 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 4
|
||||
comx771 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 3
|
||||
comx772 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 2
|
||||
comx773 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 1
|
||||
comx774 compare -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
|
||||
-- Specials
|
||||
precision: 9
|
||||
comx780 compare Inf -Inf -> 1
|
||||
comx781 compare Inf -1000 -> 1
|
||||
comx782 compare Inf -1 -> 1
|
||||
comx783 compare Inf -0 -> 1
|
||||
comx784 compare Inf 0 -> 1
|
||||
comx785 compare Inf 1 -> 1
|
||||
comx786 compare Inf 1000 -> 1
|
||||
comx787 compare Inf Inf -> 0
|
||||
comx788 compare -1000 Inf -> -1
|
||||
comx789 compare -Inf Inf -> -1
|
||||
comx790 compare -1 Inf -> -1
|
||||
comx791 compare -0 Inf -> -1
|
||||
comx792 compare 0 Inf -> -1
|
||||
comx793 compare 1 Inf -> -1
|
||||
comx794 compare 1000 Inf -> -1
|
||||
comx795 compare Inf Inf -> 0
|
||||
|
||||
comx800 compare -Inf -Inf -> 0
|
||||
comx801 compare -Inf -1000 -> -1
|
||||
comx802 compare -Inf -1 -> -1
|
||||
comx803 compare -Inf -0 -> -1
|
||||
comx804 compare -Inf 0 -> -1
|
||||
comx805 compare -Inf 1 -> -1
|
||||
comx806 compare -Inf 1000 -> -1
|
||||
comx807 compare -Inf Inf -> -1
|
||||
comx808 compare -Inf -Inf -> 0
|
||||
comx809 compare -1000 -Inf -> 1
|
||||
comx810 compare -1 -Inf -> 1
|
||||
comx811 compare -0 -Inf -> 1
|
||||
comx812 compare 0 -Inf -> 1
|
||||
comx813 compare 1 -Inf -> 1
|
||||
comx814 compare 1000 -Inf -> 1
|
||||
comx815 compare Inf -Inf -> 1
|
||||
|
||||
comx821 compare NaN -Inf -> NaN
|
||||
comx822 compare NaN -1000 -> NaN
|
||||
comx823 compare NaN -1 -> NaN
|
||||
comx824 compare NaN -0 -> NaN
|
||||
comx825 compare NaN 0 -> NaN
|
||||
comx826 compare NaN 1 -> NaN
|
||||
comx827 compare NaN 1000 -> NaN
|
||||
comx828 compare NaN Inf -> NaN
|
||||
comx829 compare NaN NaN -> NaN
|
||||
comx830 compare -Inf NaN -> NaN
|
||||
comx831 compare -1000 NaN -> NaN
|
||||
comx832 compare -1 NaN -> NaN
|
||||
comx833 compare -0 NaN -> NaN
|
||||
comx834 compare 0 NaN -> NaN
|
||||
comx835 compare 1 NaN -> NaN
|
||||
comx836 compare 1000 NaN -> NaN
|
||||
comx837 compare Inf NaN -> NaN
|
||||
comx838 compare -NaN -NaN -> -NaN
|
||||
comx839 compare +NaN -NaN -> NaN
|
||||
comx840 compare -NaN +NaN -> -NaN
|
||||
|
||||
comx841 compare sNaN -Inf -> NaN Invalid_operation
|
||||
comx842 compare sNaN -1000 -> NaN Invalid_operation
|
||||
comx843 compare sNaN -1 -> NaN Invalid_operation
|
||||
comx844 compare sNaN -0 -> NaN Invalid_operation
|
||||
comx845 compare sNaN 0 -> NaN Invalid_operation
|
||||
comx846 compare sNaN 1 -> NaN Invalid_operation
|
||||
comx847 compare sNaN 1000 -> NaN Invalid_operation
|
||||
comx848 compare sNaN NaN -> NaN Invalid_operation
|
||||
comx849 compare sNaN sNaN -> NaN Invalid_operation
|
||||
comx850 compare NaN sNaN -> NaN Invalid_operation
|
||||
comx851 compare -Inf sNaN -> NaN Invalid_operation
|
||||
comx852 compare -1000 sNaN -> NaN Invalid_operation
|
||||
comx853 compare -1 sNaN -> NaN Invalid_operation
|
||||
comx854 compare -0 sNaN -> NaN Invalid_operation
|
||||
comx855 compare 0 sNaN -> NaN Invalid_operation
|
||||
comx856 compare 1 sNaN -> NaN Invalid_operation
|
||||
comx857 compare 1000 sNaN -> NaN Invalid_operation
|
||||
comx858 compare Inf sNaN -> NaN Invalid_operation
|
||||
comx859 compare NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
comx860 compare NaN9 -Inf -> NaN9
|
||||
comx861 compare NaN8 999 -> NaN8
|
||||
comx862 compare NaN77 Inf -> NaN77
|
||||
comx863 compare -NaN67 NaN5 -> -NaN67
|
||||
comx864 compare -Inf -NaN4 -> -NaN4
|
||||
comx865 compare -999 -NaN33 -> -NaN33
|
||||
comx866 compare Inf NaN2 -> NaN2
|
||||
comx867 compare -NaN41 -NaN42 -> -NaN41
|
||||
comx868 compare +NaN41 -NaN42 -> NaN41
|
||||
comx869 compare -NaN41 +NaN42 -> -NaN41
|
||||
comx870 compare +NaN41 +NaN42 -> NaN41
|
||||
|
||||
comx871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
comx872 compare sNaN98 -11 -> NaN98 Invalid_operation
|
||||
comx873 compare sNaN97 NaN -> NaN97 Invalid_operation
|
||||
comx874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
|
||||
comx875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
|
||||
comx876 compare -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
comx877 compare 088 sNaN81 -> NaN81 Invalid_operation
|
||||
comx878 compare Inf sNaN90 -> NaN90 Invalid_operation
|
||||
comx879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
|
||||
|
||||
-- overflow and underflow tests .. subnormal results now allowed
|
||||
maxExponent: 999999999
|
||||
minexponent: -999999999
|
||||
comx880 compare +1.23456789012345E-0 9E+999999999 -> -1
|
||||
comx881 compare 9E+999999999 +1.23456789012345E-0 -> 1
|
||||
comx882 compare +0.100 9E-999999999 -> 1
|
||||
comx883 compare 9E-999999999 +0.100 -> -1
|
||||
comx885 compare -1.23456789012345E-0 9E+999999999 -> -1
|
||||
comx886 compare 9E+999999999 -1.23456789012345E-0 -> 1
|
||||
comx887 compare -0.100 9E-999999999 -> -1
|
||||
comx888 compare 9E-999999999 -0.100 -> 1
|
||||
|
||||
comx889 compare 1e-599999999 1e-400000001 -> -1
|
||||
comx890 compare 1e-599999999 1e-400000000 -> -1
|
||||
comx891 compare 1e-600000000 1e-400000000 -> -1
|
||||
comx892 compare 9e-999999998 0.01 -> -1
|
||||
comx893 compare 9e-999999998 0.1 -> -1
|
||||
comx894 compare 0.01 9e-999999998 -> 1
|
||||
comx895 compare 1e599999999 1e400000001 -> 1
|
||||
comx896 compare 1e599999999 1e400000000 -> 1
|
||||
comx897 compare 1e600000000 1e400000000 -> 1
|
||||
comx898 compare 9e999999998 100 -> 1
|
||||
comx899 compare 9e999999998 10 -> 1
|
||||
comx900 compare 100 9e999999998 -> -1
|
||||
-- signs
|
||||
comx901 compare 1e+777777777 1e+411111111 -> 1
|
||||
comx902 compare 1e+777777777 -1e+411111111 -> 1
|
||||
comx903 compare -1e+777777777 1e+411111111 -> -1
|
||||
comx904 compare -1e+777777777 -1e+411111111 -> -1
|
||||
comx905 compare 1e-777777777 1e-411111111 -> -1
|
||||
comx906 compare 1e-777777777 -1e-411111111 -> 1
|
||||
comx907 compare -1e-777777777 1e-411111111 -> -1
|
||||
comx908 compare -1e-777777777 -1e-411111111 -> 1
|
||||
|
||||
-- spread zeros
|
||||
comx910 compare 0E-383 0 -> 0
|
||||
comx911 compare 0E-383 -0 -> 0
|
||||
comx912 compare -0E-383 0 -> 0
|
||||
comx913 compare -0E-383 -0 -> 0
|
||||
comx914 compare 0E-383 0E+384 -> 0
|
||||
comx915 compare 0E-383 -0E+384 -> 0
|
||||
comx916 compare -0E-383 0E+384 -> 0
|
||||
comx917 compare -0E-383 -0E+384 -> 0
|
||||
comx918 compare 0 0E+384 -> 0
|
||||
comx919 compare 0 -0E+384 -> 0
|
||||
comx920 compare -0 0E+384 -> 0
|
||||
comx921 compare -0 -0E+384 -> 0
|
||||
comx930 compare 0E+384 0 -> 0
|
||||
comx931 compare 0E+384 -0 -> 0
|
||||
comx932 compare -0E+384 0 -> 0
|
||||
comx933 compare -0E+384 -0 -> 0
|
||||
comx934 compare 0E+384 0E-383 -> 0
|
||||
comx935 compare 0E+384 -0E-383 -> 0
|
||||
comx936 compare -0E+384 0E-383 -> 0
|
||||
comx937 compare -0E+384 -0E-383 -> 0
|
||||
comx938 compare 0 0E-383 -> 0
|
||||
comx939 compare 0 -0E-383 -> 0
|
||||
comx940 compare -0 0E-383 -> 0
|
||||
comx941 compare -0 -0E-383 -> 0
|
||||
|
||||
-- Null tests
|
||||
comx990 compare 10 # -> NaN Invalid_operation
|
||||
comx991 compare # 10 -> NaN Invalid_operation
|
@ -0,0 +1,798 @@
|
||||
------------------------------------------------------------------------
|
||||
-- comparetotal.decTest -- decimal comparison using total ordering --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
-- Similarly, comparetotal will have some radically different paths
|
||||
-- than compare.
|
||||
|
||||
extended: 1
|
||||
precision: 16
|
||||
rounding: half_up
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
|
||||
-- sanity checks
|
||||
cotx001 comparetotal -2 -2 -> 0
|
||||
cotx002 comparetotal -2 -1 -> -1
|
||||
cotx003 comparetotal -2 0 -> -1
|
||||
cotx004 comparetotal -2 1 -> -1
|
||||
cotx005 comparetotal -2 2 -> -1
|
||||
cotx006 comparetotal -1 -2 -> 1
|
||||
cotx007 comparetotal -1 -1 -> 0
|
||||
cotx008 comparetotal -1 0 -> -1
|
||||
cotx009 comparetotal -1 1 -> -1
|
||||
cotx010 comparetotal -1 2 -> -1
|
||||
cotx011 comparetotal 0 -2 -> 1
|
||||
cotx012 comparetotal 0 -1 -> 1
|
||||
cotx013 comparetotal 0 0 -> 0
|
||||
cotx014 comparetotal 0 1 -> -1
|
||||
cotx015 comparetotal 0 2 -> -1
|
||||
cotx016 comparetotal 1 -2 -> 1
|
||||
cotx017 comparetotal 1 -1 -> 1
|
||||
cotx018 comparetotal 1 0 -> 1
|
||||
cotx019 comparetotal 1 1 -> 0
|
||||
cotx020 comparetotal 1 2 -> -1
|
||||
cotx021 comparetotal 2 -2 -> 1
|
||||
cotx022 comparetotal 2 -1 -> 1
|
||||
cotx023 comparetotal 2 0 -> 1
|
||||
cotx025 comparetotal 2 1 -> 1
|
||||
cotx026 comparetotal 2 2 -> 0
|
||||
|
||||
cotx031 comparetotal -20 -20 -> 0
|
||||
cotx032 comparetotal -20 -10 -> -1
|
||||
cotx033 comparetotal -20 00 -> -1
|
||||
cotx034 comparetotal -20 10 -> -1
|
||||
cotx035 comparetotal -20 20 -> -1
|
||||
cotx036 comparetotal -10 -20 -> 1
|
||||
cotx037 comparetotal -10 -10 -> 0
|
||||
cotx038 comparetotal -10 00 -> -1
|
||||
cotx039 comparetotal -10 10 -> -1
|
||||
cotx040 comparetotal -10 20 -> -1
|
||||
cotx041 comparetotal 00 -20 -> 1
|
||||
cotx042 comparetotal 00 -10 -> 1
|
||||
cotx043 comparetotal 00 00 -> 0
|
||||
cotx044 comparetotal 00 10 -> -1
|
||||
cotx045 comparetotal 00 20 -> -1
|
||||
cotx046 comparetotal 10 -20 -> 1
|
||||
cotx047 comparetotal 10 -10 -> 1
|
||||
cotx048 comparetotal 10 00 -> 1
|
||||
cotx049 comparetotal 10 10 -> 0
|
||||
cotx050 comparetotal 10 20 -> -1
|
||||
cotx051 comparetotal 20 -20 -> 1
|
||||
cotx052 comparetotal 20 -10 -> 1
|
||||
cotx053 comparetotal 20 00 -> 1
|
||||
cotx055 comparetotal 20 10 -> 1
|
||||
cotx056 comparetotal 20 20 -> 0
|
||||
|
||||
cotx061 comparetotal -2.0 -2.0 -> 0
|
||||
cotx062 comparetotal -2.0 -1.0 -> -1
|
||||
cotx063 comparetotal -2.0 0.0 -> -1
|
||||
cotx064 comparetotal -2.0 1.0 -> -1
|
||||
cotx065 comparetotal -2.0 2.0 -> -1
|
||||
cotx066 comparetotal -1.0 -2.0 -> 1
|
||||
cotx067 comparetotal -1.0 -1.0 -> 0
|
||||
cotx068 comparetotal -1.0 0.0 -> -1
|
||||
cotx069 comparetotal -1.0 1.0 -> -1
|
||||
cotx070 comparetotal -1.0 2.0 -> -1
|
||||
cotx071 comparetotal 0.0 -2.0 -> 1
|
||||
cotx072 comparetotal 0.0 -1.0 -> 1
|
||||
cotx073 comparetotal 0.0 0.0 -> 0
|
||||
cotx074 comparetotal 0.0 1.0 -> -1
|
||||
cotx075 comparetotal 0.0 2.0 -> -1
|
||||
cotx076 comparetotal 1.0 -2.0 -> 1
|
||||
cotx077 comparetotal 1.0 -1.0 -> 1
|
||||
cotx078 comparetotal 1.0 0.0 -> 1
|
||||
cotx079 comparetotal 1.0 1.0 -> 0
|
||||
cotx080 comparetotal 1.0 2.0 -> -1
|
||||
cotx081 comparetotal 2.0 -2.0 -> 1
|
||||
cotx082 comparetotal 2.0 -1.0 -> 1
|
||||
cotx083 comparetotal 2.0 0.0 -> 1
|
||||
cotx085 comparetotal 2.0 1.0 -> 1
|
||||
cotx086 comparetotal 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
maxexponent: 999999999
|
||||
minexponent: -999999999
|
||||
cotx090 comparetotal 9.99999999E+999999999 9.99999999E+999999999 -> 0
|
||||
cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999 -> -1
|
||||
cotx092 comparetotal 9.99999999E+999999999 -9.99999999E+999999999 -> 1
|
||||
cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0
|
||||
|
||||
-- Examples
|
||||
cotx094 comparetotal 12.73 127.9 -> -1
|
||||
cotx095 comparetotal -127 12 -> -1
|
||||
cotx096 comparetotal 12.30 12.3 -> -1
|
||||
cotx097 comparetotal 12.30 12.30 -> 0
|
||||
cotx098 comparetotal 12.3 12.300 -> 1
|
||||
cotx099 comparetotal 12.3 NaN -> -1
|
||||
|
||||
-- some differing length/exponent cases
|
||||
-- in this first group, compare would compare all equal
|
||||
cotx100 comparetotal 7.0 7.0 -> 0
|
||||
cotx101 comparetotal 7.0 7 -> -1
|
||||
cotx102 comparetotal 7 7.0 -> 1
|
||||
cotx103 comparetotal 7E+0 7.0 -> 1
|
||||
cotx104 comparetotal 70E-1 7.0 -> 0
|
||||
cotx105 comparetotal 0.7E+1 7 -> 0
|
||||
cotx106 comparetotal 70E-1 7 -> -1
|
||||
cotx107 comparetotal 7.0 7E+0 -> -1
|
||||
cotx108 comparetotal 7.0 70E-1 -> 0
|
||||
cotx109 comparetotal 7 0.7E+1 -> 0
|
||||
cotx110 comparetotal 7 70E-1 -> 1
|
||||
|
||||
cotx120 comparetotal 8.0 7.0 -> 1
|
||||
cotx121 comparetotal 8.0 7 -> 1
|
||||
cotx122 comparetotal 8 7.0 -> 1
|
||||
cotx123 comparetotal 8E+0 7.0 -> 1
|
||||
cotx124 comparetotal 80E-1 7.0 -> 1
|
||||
cotx125 comparetotal 0.8E+1 7 -> 1
|
||||
cotx126 comparetotal 80E-1 7 -> 1
|
||||
cotx127 comparetotal 8.0 7E+0 -> 1
|
||||
cotx128 comparetotal 8.0 70E-1 -> 1
|
||||
cotx129 comparetotal 8 0.7E+1 -> 1
|
||||
cotx130 comparetotal 8 70E-1 -> 1
|
||||
|
||||
cotx140 comparetotal 8.0 9.0 -> -1
|
||||
cotx141 comparetotal 8.0 9 -> -1
|
||||
cotx142 comparetotal 8 9.0 -> -1
|
||||
cotx143 comparetotal 8E+0 9.0 -> -1
|
||||
cotx144 comparetotal 80E-1 9.0 -> -1
|
||||
cotx145 comparetotal 0.8E+1 9 -> -1
|
||||
cotx146 comparetotal 80E-1 9 -> -1
|
||||
cotx147 comparetotal 8.0 9E+0 -> -1
|
||||
cotx148 comparetotal 8.0 90E-1 -> -1
|
||||
cotx149 comparetotal 8 0.9E+1 -> -1
|
||||
cotx150 comparetotal 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
cotx200 comparetotal -7.0 7.0 -> -1
|
||||
cotx201 comparetotal -7.0 7 -> -1
|
||||
cotx202 comparetotal -7 7.0 -> -1
|
||||
cotx203 comparetotal -7E+0 7.0 -> -1
|
||||
cotx204 comparetotal -70E-1 7.0 -> -1
|
||||
cotx205 comparetotal -0.7E+1 7 -> -1
|
||||
cotx206 comparetotal -70E-1 7 -> -1
|
||||
cotx207 comparetotal -7.0 7E+0 -> -1
|
||||
cotx208 comparetotal -7.0 70E-1 -> -1
|
||||
cotx209 comparetotal -7 0.7E+1 -> -1
|
||||
cotx210 comparetotal -7 70E-1 -> -1
|
||||
|
||||
cotx220 comparetotal -8.0 7.0 -> -1
|
||||
cotx221 comparetotal -8.0 7 -> -1
|
||||
cotx222 comparetotal -8 7.0 -> -1
|
||||
cotx223 comparetotal -8E+0 7.0 -> -1
|
||||
cotx224 comparetotal -80E-1 7.0 -> -1
|
||||
cotx225 comparetotal -0.8E+1 7 -> -1
|
||||
cotx226 comparetotal -80E-1 7 -> -1
|
||||
cotx227 comparetotal -8.0 7E+0 -> -1
|
||||
cotx228 comparetotal -8.0 70E-1 -> -1
|
||||
cotx229 comparetotal -8 0.7E+1 -> -1
|
||||
cotx230 comparetotal -8 70E-1 -> -1
|
||||
|
||||
cotx240 comparetotal -8.0 9.0 -> -1
|
||||
cotx241 comparetotal -8.0 9 -> -1
|
||||
cotx242 comparetotal -8 9.0 -> -1
|
||||
cotx243 comparetotal -8E+0 9.0 -> -1
|
||||
cotx244 comparetotal -80E-1 9.0 -> -1
|
||||
cotx245 comparetotal -0.8E+1 9 -> -1
|
||||
cotx246 comparetotal -80E-1 9 -> -1
|
||||
cotx247 comparetotal -8.0 9E+0 -> -1
|
||||
cotx248 comparetotal -8.0 90E-1 -> -1
|
||||
cotx249 comparetotal -8 0.9E+1 -> -1
|
||||
cotx250 comparetotal -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
cotx300 comparetotal 7.0 -7.0 -> 1
|
||||
cotx301 comparetotal 7.0 -7 -> 1
|
||||
cotx302 comparetotal 7 -7.0 -> 1
|
||||
cotx303 comparetotal 7E+0 -7.0 -> 1
|
||||
cotx304 comparetotal 70E-1 -7.0 -> 1
|
||||
cotx305 comparetotal .7E+1 -7 -> 1
|
||||
cotx306 comparetotal 70E-1 -7 -> 1
|
||||
cotx307 comparetotal 7.0 -7E+0 -> 1
|
||||
cotx308 comparetotal 7.0 -70E-1 -> 1
|
||||
cotx309 comparetotal 7 -.7E+1 -> 1
|
||||
cotx310 comparetotal 7 -70E-1 -> 1
|
||||
|
||||
cotx320 comparetotal 8.0 -7.0 -> 1
|
||||
cotx321 comparetotal 8.0 -7 -> 1
|
||||
cotx322 comparetotal 8 -7.0 -> 1
|
||||
cotx323 comparetotal 8E+0 -7.0 -> 1
|
||||
cotx324 comparetotal 80E-1 -7.0 -> 1
|
||||
cotx325 comparetotal .8E+1 -7 -> 1
|
||||
cotx326 comparetotal 80E-1 -7 -> 1
|
||||
cotx327 comparetotal 8.0 -7E+0 -> 1
|
||||
cotx328 comparetotal 8.0 -70E-1 -> 1
|
||||
cotx329 comparetotal 8 -.7E+1 -> 1
|
||||
cotx330 comparetotal 8 -70E-1 -> 1
|
||||
|
||||
cotx340 comparetotal 8.0 -9.0 -> 1
|
||||
cotx341 comparetotal 8.0 -9 -> 1
|
||||
cotx342 comparetotal 8 -9.0 -> 1
|
||||
cotx343 comparetotal 8E+0 -9.0 -> 1
|
||||
cotx344 comparetotal 80E-1 -9.0 -> 1
|
||||
cotx345 comparetotal .8E+1 -9 -> 1
|
||||
cotx346 comparetotal 80E-1 -9 -> 1
|
||||
cotx347 comparetotal 8.0 -9E+0 -> 1
|
||||
cotx348 comparetotal 8.0 -90E-1 -> 1
|
||||
cotx349 comparetotal 8 -.9E+1 -> 1
|
||||
cotx350 comparetotal 8 -90E-1 -> 1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
cotx400 comparetotal -7.0 -7.0 -> 0
|
||||
cotx401 comparetotal -7.0 -7 -> 1
|
||||
cotx402 comparetotal -7 -7.0 -> -1
|
||||
cotx403 comparetotal -7E+0 -7.0 -> -1
|
||||
cotx404 comparetotal -70E-1 -7.0 -> 0
|
||||
cotx405 comparetotal -.7E+1 -7 -> 0
|
||||
cotx406 comparetotal -70E-1 -7 -> 1
|
||||
cotx407 comparetotal -7.0 -7E+0 -> 1
|
||||
cotx408 comparetotal -7.0 -70E-1 -> 0
|
||||
cotx409 comparetotal -7 -.7E+1 -> 0
|
||||
cotx410 comparetotal -7 -70E-1 -> -1
|
||||
|
||||
cotx420 comparetotal -8.0 -7.0 -> -1
|
||||
cotx421 comparetotal -8.0 -7 -> -1
|
||||
cotx422 comparetotal -8 -7.0 -> -1
|
||||
cotx423 comparetotal -8E+0 -7.0 -> -1
|
||||
cotx424 comparetotal -80E-1 -7.0 -> -1
|
||||
cotx425 comparetotal -.8E+1 -7 -> -1
|
||||
cotx426 comparetotal -80E-1 -7 -> -1
|
||||
cotx427 comparetotal -8.0 -7E+0 -> -1
|
||||
cotx428 comparetotal -8.0 -70E-1 -> -1
|
||||
cotx429 comparetotal -8 -.7E+1 -> -1
|
||||
cotx430 comparetotal -8 -70E-1 -> -1
|
||||
|
||||
cotx440 comparetotal -8.0 -9.0 -> 1
|
||||
cotx441 comparetotal -8.0 -9 -> 1
|
||||
cotx442 comparetotal -8 -9.0 -> 1
|
||||
cotx443 comparetotal -8E+0 -9.0 -> 1
|
||||
cotx444 comparetotal -80E-1 -9.0 -> 1
|
||||
cotx445 comparetotal -.8E+1 -9 -> 1
|
||||
cotx446 comparetotal -80E-1 -9 -> 1
|
||||
cotx447 comparetotal -8.0 -9E+0 -> 1
|
||||
cotx448 comparetotal -8.0 -90E-1 -> 1
|
||||
cotx449 comparetotal -8 -.9E+1 -> 1
|
||||
cotx450 comparetotal -8 -90E-1 -> 1
|
||||
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
precision: 40
|
||||
cotx470 comparetotal 123.4560000000000000E789 123.456E789 -> -1
|
||||
cotx471 comparetotal 123.456000000000000E-89 123.456E-89 -> -1
|
||||
cotx472 comparetotal 123.45600000000000E789 123.456E789 -> -1
|
||||
cotx473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
|
||||
cotx474 comparetotal 123.456000000000E789 123.456E789 -> -1
|
||||
cotx475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
|
||||
cotx476 comparetotal 123.4560000000E789 123.456E789 -> -1
|
||||
cotx477 comparetotal 123.456000000E-89 123.456E-89 -> -1
|
||||
cotx478 comparetotal 123.45600000E789 123.456E789 -> -1
|
||||
cotx479 comparetotal 123.4560000E-89 123.456E-89 -> -1
|
||||
cotx480 comparetotal 123.456000E789 123.456E789 -> -1
|
||||
cotx481 comparetotal 123.45600E-89 123.456E-89 -> -1
|
||||
cotx482 comparetotal 123.4560E789 123.456E789 -> -1
|
||||
cotx483 comparetotal 123.456E-89 123.456E-89 -> 0
|
||||
cotx484 comparetotal 123.456E-89 123.4560000000000000E-89 -> 1
|
||||
cotx485 comparetotal 123.456E789 123.456000000000000E789 -> 1
|
||||
cotx486 comparetotal 123.456E-89 123.45600000000000E-89 -> 1
|
||||
cotx487 comparetotal 123.456E789 123.4560000000000E789 -> 1
|
||||
cotx488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
|
||||
cotx489 comparetotal 123.456E789 123.45600000000E789 -> 1
|
||||
cotx490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
|
||||
cotx491 comparetotal 123.456E789 123.456000000E789 -> 1
|
||||
cotx492 comparetotal 123.456E-89 123.45600000E-89 -> 1
|
||||
cotx493 comparetotal 123.456E789 123.4560000E789 -> 1
|
||||
cotx494 comparetotal 123.456E-89 123.456000E-89 -> 1
|
||||
cotx495 comparetotal 123.456E789 123.45600E789 -> 1
|
||||
cotx496 comparetotal 123.456E-89 123.4560E-89 -> 1
|
||||
cotx497 comparetotal 123.456E789 123.456E789 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
precision: 9
|
||||
cotx500 comparetotal 1 1E-15 -> 1
|
||||
cotx501 comparetotal 1 1E-14 -> 1
|
||||
cotx502 comparetotal 1 1E-13 -> 1
|
||||
cotx503 comparetotal 1 1E-12 -> 1
|
||||
cotx504 comparetotal 1 1E-11 -> 1
|
||||
cotx505 comparetotal 1 1E-10 -> 1
|
||||
cotx506 comparetotal 1 1E-9 -> 1
|
||||
cotx507 comparetotal 1 1E-8 -> 1
|
||||
cotx508 comparetotal 1 1E-7 -> 1
|
||||
cotx509 comparetotal 1 1E-6 -> 1
|
||||
cotx510 comparetotal 1 1E-5 -> 1
|
||||
cotx511 comparetotal 1 1E-4 -> 1
|
||||
cotx512 comparetotal 1 1E-3 -> 1
|
||||
cotx513 comparetotal 1 1E-2 -> 1
|
||||
cotx514 comparetotal 1 1E-1 -> 1
|
||||
cotx515 comparetotal 1 1E-0 -> 0
|
||||
cotx516 comparetotal 1 1E+1 -> -1
|
||||
cotx517 comparetotal 1 1E+2 -> -1
|
||||
cotx518 comparetotal 1 1E+3 -> -1
|
||||
cotx519 comparetotal 1 1E+4 -> -1
|
||||
cotx521 comparetotal 1 1E+5 -> -1
|
||||
cotx522 comparetotal 1 1E+6 -> -1
|
||||
cotx523 comparetotal 1 1E+7 -> -1
|
||||
cotx524 comparetotal 1 1E+8 -> -1
|
||||
cotx525 comparetotal 1 1E+9 -> -1
|
||||
cotx526 comparetotal 1 1E+10 -> -1
|
||||
cotx527 comparetotal 1 1E+11 -> -1
|
||||
cotx528 comparetotal 1 1E+12 -> -1
|
||||
cotx529 comparetotal 1 1E+13 -> -1
|
||||
cotx530 comparetotal 1 1E+14 -> -1
|
||||
cotx531 comparetotal 1 1E+15 -> -1
|
||||
-- LR swap
|
||||
cotx540 comparetotal 1E-15 1 -> -1
|
||||
cotx541 comparetotal 1E-14 1 -> -1
|
||||
cotx542 comparetotal 1E-13 1 -> -1
|
||||
cotx543 comparetotal 1E-12 1 -> -1
|
||||
cotx544 comparetotal 1E-11 1 -> -1
|
||||
cotx545 comparetotal 1E-10 1 -> -1
|
||||
cotx546 comparetotal 1E-9 1 -> -1
|
||||
cotx547 comparetotal 1E-8 1 -> -1
|
||||
cotx548 comparetotal 1E-7 1 -> -1
|
||||
cotx549 comparetotal 1E-6 1 -> -1
|
||||
cotx550 comparetotal 1E-5 1 -> -1
|
||||
cotx551 comparetotal 1E-4 1 -> -1
|
||||
cotx552 comparetotal 1E-3 1 -> -1
|
||||
cotx553 comparetotal 1E-2 1 -> -1
|
||||
cotx554 comparetotal 1E-1 1 -> -1
|
||||
cotx555 comparetotal 1E-0 1 -> 0
|
||||
cotx556 comparetotal 1E+1 1 -> 1
|
||||
cotx557 comparetotal 1E+2 1 -> 1
|
||||
cotx558 comparetotal 1E+3 1 -> 1
|
||||
cotx559 comparetotal 1E+4 1 -> 1
|
||||
cotx561 comparetotal 1E+5 1 -> 1
|
||||
cotx562 comparetotal 1E+6 1 -> 1
|
||||
cotx563 comparetotal 1E+7 1 -> 1
|
||||
cotx564 comparetotal 1E+8 1 -> 1
|
||||
cotx565 comparetotal 1E+9 1 -> 1
|
||||
cotx566 comparetotal 1E+10 1 -> 1
|
||||
cotx567 comparetotal 1E+11 1 -> 1
|
||||
cotx568 comparetotal 1E+12 1 -> 1
|
||||
cotx569 comparetotal 1E+13 1 -> 1
|
||||
cotx570 comparetotal 1E+14 1 -> 1
|
||||
cotx571 comparetotal 1E+15 1 -> 1
|
||||
-- similar with an useful coefficient, one side only
|
||||
cotx580 comparetotal 0.000000987654321 1E-15 -> 1
|
||||
cotx581 comparetotal 0.000000987654321 1E-14 -> 1
|
||||
cotx582 comparetotal 0.000000987654321 1E-13 -> 1
|
||||
cotx583 comparetotal 0.000000987654321 1E-12 -> 1
|
||||
cotx584 comparetotal 0.000000987654321 1E-11 -> 1
|
||||
cotx585 comparetotal 0.000000987654321 1E-10 -> 1
|
||||
cotx586 comparetotal 0.000000987654321 1E-9 -> 1
|
||||
cotx587 comparetotal 0.000000987654321 1E-8 -> 1
|
||||
cotx588 comparetotal 0.000000987654321 1E-7 -> 1
|
||||
cotx589 comparetotal 0.000000987654321 1E-6 -> -1
|
||||
cotx590 comparetotal 0.000000987654321 1E-5 -> -1
|
||||
cotx591 comparetotal 0.000000987654321 1E-4 -> -1
|
||||
cotx592 comparetotal 0.000000987654321 1E-3 -> -1
|
||||
cotx593 comparetotal 0.000000987654321 1E-2 -> -1
|
||||
cotx594 comparetotal 0.000000987654321 1E-1 -> -1
|
||||
cotx595 comparetotal 0.000000987654321 1E-0 -> -1
|
||||
cotx596 comparetotal 0.000000987654321 1E+1 -> -1
|
||||
cotx597 comparetotal 0.000000987654321 1E+2 -> -1
|
||||
cotx598 comparetotal 0.000000987654321 1E+3 -> -1
|
||||
cotx599 comparetotal 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
precision: 20
|
||||
cotx600 comparetotal 12 12.2345 -> -1
|
||||
cotx601 comparetotal 12.0 12.2345 -> -1
|
||||
cotx602 comparetotal 12.00 12.2345 -> -1
|
||||
cotx603 comparetotal 12.000 12.2345 -> -1
|
||||
cotx604 comparetotal 12.0000 12.2345 -> -1
|
||||
cotx605 comparetotal 12.00000 12.2345 -> -1
|
||||
cotx606 comparetotal 12.000000 12.2345 -> -1
|
||||
cotx607 comparetotal 12.0000000 12.2345 -> -1
|
||||
cotx608 comparetotal 12.00000000 12.2345 -> -1
|
||||
cotx609 comparetotal 12.000000000 12.2345 -> -1
|
||||
cotx610 comparetotal 12.1234 12 -> 1
|
||||
cotx611 comparetotal 12.1234 12.0 -> 1
|
||||
cotx612 comparetotal 12.1234 12.00 -> 1
|
||||
cotx613 comparetotal 12.1234 12.000 -> 1
|
||||
cotx614 comparetotal 12.1234 12.0000 -> 1
|
||||
cotx615 comparetotal 12.1234 12.00000 -> 1
|
||||
cotx616 comparetotal 12.1234 12.000000 -> 1
|
||||
cotx617 comparetotal 12.1234 12.0000000 -> 1
|
||||
cotx618 comparetotal 12.1234 12.00000000 -> 1
|
||||
cotx619 comparetotal 12.1234 12.000000000 -> 1
|
||||
cotx620 comparetotal -12 -12.2345 -> 1
|
||||
cotx621 comparetotal -12.0 -12.2345 -> 1
|
||||
cotx622 comparetotal -12.00 -12.2345 -> 1
|
||||
cotx623 comparetotal -12.000 -12.2345 -> 1
|
||||
cotx624 comparetotal -12.0000 -12.2345 -> 1
|
||||
cotx625 comparetotal -12.00000 -12.2345 -> 1
|
||||
cotx626 comparetotal -12.000000 -12.2345 -> 1
|
||||
cotx627 comparetotal -12.0000000 -12.2345 -> 1
|
||||
cotx628 comparetotal -12.00000000 -12.2345 -> 1
|
||||
cotx629 comparetotal -12.000000000 -12.2345 -> 1
|
||||
cotx630 comparetotal -12.1234 -12 -> -1
|
||||
cotx631 comparetotal -12.1234 -12.0 -> -1
|
||||
cotx632 comparetotal -12.1234 -12.00 -> -1
|
||||
cotx633 comparetotal -12.1234 -12.000 -> -1
|
||||
cotx634 comparetotal -12.1234 -12.0000 -> -1
|
||||
cotx635 comparetotal -12.1234 -12.00000 -> -1
|
||||
cotx636 comparetotal -12.1234 -12.000000 -> -1
|
||||
cotx637 comparetotal -12.1234 -12.0000000 -> -1
|
||||
cotx638 comparetotal -12.1234 -12.00000000 -> -1
|
||||
cotx639 comparetotal -12.1234 -12.000000000 -> -1
|
||||
precision: 9
|
||||
|
||||
-- extended zeros
|
||||
cotx640 comparetotal 0 0 -> 0
|
||||
cotx641 comparetotal 0 -0 -> 1
|
||||
cotx642 comparetotal 0 -0.0 -> 1
|
||||
cotx643 comparetotal 0 0.0 -> 1
|
||||
cotx644 comparetotal -0 0 -> -1
|
||||
cotx645 comparetotal -0 -0 -> 0
|
||||
cotx646 comparetotal -0 -0.0 -> -1
|
||||
cotx647 comparetotal -0 0.0 -> -1
|
||||
cotx648 comparetotal 0.0 0 -> -1
|
||||
cotx649 comparetotal 0.0 -0 -> 1
|
||||
cotx650 comparetotal 0.0 -0.0 -> 1
|
||||
cotx651 comparetotal 0.0 0.0 -> 0
|
||||
cotx652 comparetotal -0.0 0 -> -1
|
||||
cotx653 comparetotal -0.0 -0 -> 1
|
||||
cotx654 comparetotal -0.0 -0.0 -> 0
|
||||
cotx655 comparetotal -0.0 0.0 -> -1
|
||||
|
||||
cotx656 comparetotal -0E1 0.0 -> -1
|
||||
cotx657 comparetotal -0E2 0.0 -> -1
|
||||
cotx658 comparetotal 0E1 0.0 -> 1
|
||||
cotx659 comparetotal 0E2 0.0 -> 1
|
||||
cotx660 comparetotal -0E1 0 -> -1
|
||||
cotx661 comparetotal -0E2 0 -> -1
|
||||
cotx662 comparetotal 0E1 0 -> 1
|
||||
cotx663 comparetotal 0E2 0 -> 1
|
||||
cotx664 comparetotal -0E1 -0E1 -> 0
|
||||
cotx665 comparetotal -0E2 -0E1 -> -1
|
||||
cotx666 comparetotal 0E1 -0E1 -> 1
|
||||
cotx667 comparetotal 0E2 -0E1 -> 1
|
||||
cotx668 comparetotal -0E1 -0E2 -> 1
|
||||
cotx669 comparetotal -0E2 -0E2 -> 0
|
||||
cotx670 comparetotal 0E1 -0E2 -> 1
|
||||
cotx671 comparetotal 0E2 -0E2 -> 1
|
||||
cotx672 comparetotal -0E1 0E1 -> -1
|
||||
cotx673 comparetotal -0E2 0E1 -> -1
|
||||
cotx674 comparetotal 0E1 0E1 -> 0
|
||||
cotx675 comparetotal 0E2 0E1 -> 1
|
||||
cotx676 comparetotal -0E1 0E2 -> -1
|
||||
cotx677 comparetotal -0E2 0E2 -> -1
|
||||
cotx678 comparetotal 0E1 0E2 -> -1
|
||||
cotx679 comparetotal 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
precision: 20
|
||||
cotx680 comparetotal 12 12 -> 0
|
||||
cotx681 comparetotal 12 12.0 -> 1
|
||||
cotx682 comparetotal 12 12.00 -> 1
|
||||
cotx683 comparetotal 12 12.000 -> 1
|
||||
cotx684 comparetotal 12 12.0000 -> 1
|
||||
cotx685 comparetotal 12 12.00000 -> 1
|
||||
cotx686 comparetotal 12 12.000000 -> 1
|
||||
cotx687 comparetotal 12 12.0000000 -> 1
|
||||
cotx688 comparetotal 12 12.00000000 -> 1
|
||||
cotx689 comparetotal 12 12.000000000 -> 1
|
||||
cotx690 comparetotal 12 12 -> 0
|
||||
cotx691 comparetotal 12.0 12 -> -1
|
||||
cotx692 comparetotal 12.00 12 -> -1
|
||||
cotx693 comparetotal 12.000 12 -> -1
|
||||
cotx694 comparetotal 12.0000 12 -> -1
|
||||
cotx695 comparetotal 12.00000 12 -> -1
|
||||
cotx696 comparetotal 12.000000 12 -> -1
|
||||
cotx697 comparetotal 12.0000000 12 -> -1
|
||||
cotx698 comparetotal 12.00000000 12 -> -1
|
||||
cotx699 comparetotal 12.000000000 12 -> -1
|
||||
|
||||
-- long operand checks
|
||||
maxexponent: 999
|
||||
minexponent: -999
|
||||
precision: 9
|
||||
cotx701 comparetotal 12345678000 1 -> 1
|
||||
cotx702 comparetotal 1 12345678000 -> -1
|
||||
cotx703 comparetotal 1234567800 1 -> 1
|
||||
cotx704 comparetotal 1 1234567800 -> -1
|
||||
cotx705 comparetotal 1234567890 1 -> 1
|
||||
cotx706 comparetotal 1 1234567890 -> -1
|
||||
cotx707 comparetotal 1234567891 1 -> 1
|
||||
cotx708 comparetotal 1 1234567891 -> -1
|
||||
cotx709 comparetotal 12345678901 1 -> 1
|
||||
cotx710 comparetotal 1 12345678901 -> -1
|
||||
cotx711 comparetotal 1234567896 1 -> 1
|
||||
cotx712 comparetotal 1 1234567896 -> -1
|
||||
cotx713 comparetotal -1234567891 1 -> -1
|
||||
cotx714 comparetotal 1 -1234567891 -> 1
|
||||
cotx715 comparetotal -12345678901 1 -> -1
|
||||
cotx716 comparetotal 1 -12345678901 -> 1
|
||||
cotx717 comparetotal -1234567896 1 -> -1
|
||||
cotx718 comparetotal 1 -1234567896 -> 1
|
||||
|
||||
precision: 15
|
||||
-- same with plenty of precision
|
||||
cotx721 comparetotal 12345678000 1 -> 1
|
||||
cotx722 comparetotal 1 12345678000 -> -1
|
||||
cotx723 comparetotal 1234567800 1 -> 1
|
||||
cotx724 comparetotal 1 1234567800 -> -1
|
||||
cotx725 comparetotal 1234567890 1 -> 1
|
||||
cotx726 comparetotal 1 1234567890 -> -1
|
||||
cotx727 comparetotal 1234567891 1 -> 1
|
||||
cotx728 comparetotal 1 1234567891 -> -1
|
||||
cotx729 comparetotal 12345678901 1 -> 1
|
||||
cotx730 comparetotal 1 12345678901 -> -1
|
||||
cotx731 comparetotal 1234567896 1 -> 1
|
||||
cotx732 comparetotal 1 1234567896 -> -1
|
||||
|
||||
-- residue cases
|
||||
precision: 5
|
||||
cotx740 comparetotal 1 0.9999999 -> 1
|
||||
cotx741 comparetotal 1 0.999999 -> 1
|
||||
cotx742 comparetotal 1 0.99999 -> 1
|
||||
cotx743 comparetotal 1 1.0000 -> 1
|
||||
cotx744 comparetotal 1 1.00001 -> -1
|
||||
cotx745 comparetotal 1 1.000001 -> -1
|
||||
cotx746 comparetotal 1 1.0000001 -> -1
|
||||
cotx750 comparetotal 0.9999999 1 -> -1
|
||||
cotx751 comparetotal 0.999999 1 -> -1
|
||||
cotx752 comparetotal 0.99999 1 -> -1
|
||||
cotx753 comparetotal 1.0000 1 -> -1
|
||||
cotx754 comparetotal 1.00001 1 -> 1
|
||||
cotx755 comparetotal 1.000001 1 -> 1
|
||||
cotx756 comparetotal 1.0000001 1 -> 1
|
||||
|
||||
-- a selection of longies
|
||||
cotx760 comparetotal -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
|
||||
cotx761 comparetotal -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
|
||||
cotx762 comparetotal -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
|
||||
cotx763 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
-- precisions above or below the difference should have no effect
|
||||
precision: 11
|
||||
cotx764 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 10
|
||||
cotx765 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 9
|
||||
cotx766 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 8
|
||||
cotx767 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 7
|
||||
cotx768 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 6
|
||||
cotx769 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 5
|
||||
cotx770 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 4
|
||||
cotx771 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 3
|
||||
cotx772 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 2
|
||||
cotx773 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
precision: 1
|
||||
cotx774 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
|
||||
|
||||
-- Specials
|
||||
precision: 9
|
||||
cotx780 comparetotal Inf -Inf -> 1
|
||||
cotx781 comparetotal Inf -1000 -> 1
|
||||
cotx782 comparetotal Inf -1 -> 1
|
||||
cotx783 comparetotal Inf -0 -> 1
|
||||
cotx784 comparetotal Inf 0 -> 1
|
||||
cotx785 comparetotal Inf 1 -> 1
|
||||
cotx786 comparetotal Inf 1000 -> 1
|
||||
cotx787 comparetotal Inf Inf -> 0
|
||||
cotx788 comparetotal -1000 Inf -> -1
|
||||
cotx789 comparetotal -Inf Inf -> -1
|
||||
cotx790 comparetotal -1 Inf -> -1
|
||||
cotx791 comparetotal -0 Inf -> -1
|
||||
cotx792 comparetotal 0 Inf -> -1
|
||||
cotx793 comparetotal 1 Inf -> -1
|
||||
cotx794 comparetotal 1000 Inf -> -1
|
||||
cotx795 comparetotal Inf Inf -> 0
|
||||
|
||||
cotx800 comparetotal -Inf -Inf -> 0
|
||||
cotx801 comparetotal -Inf -1000 -> -1
|
||||
cotx802 comparetotal -Inf -1 -> -1
|
||||
cotx803 comparetotal -Inf -0 -> -1
|
||||
cotx804 comparetotal -Inf 0 -> -1
|
||||
cotx805 comparetotal -Inf 1 -> -1
|
||||
cotx806 comparetotal -Inf 1000 -> -1
|
||||
cotx807 comparetotal -Inf Inf -> -1
|
||||
cotx808 comparetotal -Inf -Inf -> 0
|
||||
cotx809 comparetotal -1000 -Inf -> 1
|
||||
cotx810 comparetotal -1 -Inf -> 1
|
||||
cotx811 comparetotal -0 -Inf -> 1
|
||||
cotx812 comparetotal 0 -Inf -> 1
|
||||
cotx813 comparetotal 1 -Inf -> 1
|
||||
cotx814 comparetotal 1000 -Inf -> 1
|
||||
cotx815 comparetotal Inf -Inf -> 1
|
||||
|
||||
cotx821 comparetotal NaN -Inf -> 1
|
||||
cotx822 comparetotal NaN -1000 -> 1
|
||||
cotx823 comparetotal NaN -1 -> 1
|
||||
cotx824 comparetotal NaN -0 -> 1
|
||||
cotx825 comparetotal NaN 0 -> 1
|
||||
cotx826 comparetotal NaN 1 -> 1
|
||||
cotx827 comparetotal NaN 1000 -> 1
|
||||
cotx828 comparetotal NaN Inf -> 1
|
||||
cotx829 comparetotal NaN NaN -> 0
|
||||
cotx830 comparetotal -Inf NaN -> -1
|
||||
cotx831 comparetotal -1000 NaN -> -1
|
||||
cotx832 comparetotal -1 NaN -> -1
|
||||
cotx833 comparetotal -0 NaN -> -1
|
||||
cotx834 comparetotal 0 NaN -> -1
|
||||
cotx835 comparetotal 1 NaN -> -1
|
||||
cotx836 comparetotal 1000 NaN -> -1
|
||||
cotx837 comparetotal Inf NaN -> -1
|
||||
cotx838 comparetotal -NaN -NaN -> 0
|
||||
cotx839 comparetotal +NaN -NaN -> 1
|
||||
cotx840 comparetotal -NaN +NaN -> -1
|
||||
|
||||
cotx841 comparetotal sNaN -sNaN -> 1
|
||||
cotx842 comparetotal sNaN -NaN -> 1
|
||||
cotx843 comparetotal sNaN -Inf -> 1
|
||||
cotx844 comparetotal sNaN -1000 -> 1
|
||||
cotx845 comparetotal sNaN -1 -> 1
|
||||
cotx846 comparetotal sNaN -0 -> 1
|
||||
cotx847 comparetotal sNaN 0 -> 1
|
||||
cotx848 comparetotal sNaN 1 -> 1
|
||||
cotx849 comparetotal sNaN 1000 -> 1
|
||||
cotx850 comparetotal sNaN NaN -> -1
|
||||
cotx851 comparetotal sNaN sNaN -> 0
|
||||
|
||||
cotx852 comparetotal -sNaN sNaN -> -1
|
||||
cotx853 comparetotal -NaN sNaN -> -1
|
||||
cotx854 comparetotal -Inf sNaN -> -1
|
||||
cotx855 comparetotal -1000 sNaN -> -1
|
||||
cotx856 comparetotal -1 sNaN -> -1
|
||||
cotx857 comparetotal -0 sNaN -> -1
|
||||
cotx858 comparetotal 0 sNaN -> -1
|
||||
cotx859 comparetotal 1 sNaN -> -1
|
||||
cotx860 comparetotal 1000 sNaN -> -1
|
||||
cotx861 comparetotal Inf sNaN -> -1
|
||||
cotx862 comparetotal NaN sNaN -> 1
|
||||
cotx863 comparetotal sNaN sNaN -> 0
|
||||
|
||||
cotx871 comparetotal -sNaN -sNaN -> 0
|
||||
cotx872 comparetotal -sNaN -NaN -> 1
|
||||
cotx873 comparetotal -sNaN -Inf -> -1
|
||||
cotx874 comparetotal -sNaN -1000 -> -1
|
||||
cotx875 comparetotal -sNaN -1 -> -1
|
||||
cotx876 comparetotal -sNaN -0 -> -1
|
||||
cotx877 comparetotal -sNaN 0 -> -1
|
||||
cotx878 comparetotal -sNaN 1 -> -1
|
||||
cotx879 comparetotal -sNaN 1000 -> -1
|
||||
cotx880 comparetotal -sNaN NaN -> -1
|
||||
cotx881 comparetotal -sNaN sNaN -> -1
|
||||
|
||||
cotx882 comparetotal -sNaN -sNaN -> 0
|
||||
cotx883 comparetotal -NaN -sNaN -> -1
|
||||
cotx884 comparetotal -Inf -sNaN -> 1
|
||||
cotx885 comparetotal -1000 -sNaN -> 1
|
||||
cotx886 comparetotal -1 -sNaN -> 1
|
||||
cotx887 comparetotal -0 -sNaN -> 1
|
||||
cotx888 comparetotal 0 -sNaN -> 1
|
||||
cotx889 comparetotal 1 -sNaN -> 1
|
||||
cotx890 comparetotal 1000 -sNaN -> 1
|
||||
cotx891 comparetotal Inf -sNaN -> 1
|
||||
cotx892 comparetotal NaN -sNaN -> 1
|
||||
cotx893 comparetotal sNaN -sNaN -> 1
|
||||
|
||||
-- NaNs with payload
|
||||
cotx960 comparetotal NaN9 -Inf -> 1
|
||||
cotx961 comparetotal NaN8 999 -> 1
|
||||
cotx962 comparetotal NaN77 Inf -> 1
|
||||
cotx963 comparetotal -NaN67 NaN5 -> -1
|
||||
cotx964 comparetotal -Inf -NaN4 -> 1
|
||||
cotx965 comparetotal -999 -NaN33 -> 1
|
||||
cotx966 comparetotal Inf NaN2 -> -1
|
||||
|
||||
cotx970 comparetotal -NaN41 -NaN42 -> 1
|
||||
cotx971 comparetotal +NaN41 -NaN42 -> 1
|
||||
cotx972 comparetotal -NaN41 +NaN42 -> -1
|
||||
cotx973 comparetotal +NaN41 +NaN42 -> -1
|
||||
cotx974 comparetotal -NaN42 -NaN01 -> -1
|
||||
cotx975 comparetotal +NaN42 -NaN01 -> 1
|
||||
cotx976 comparetotal -NaN42 +NaN01 -> -1
|
||||
cotx977 comparetotal +NaN42 +NaN01 -> 1
|
||||
|
||||
cotx980 comparetotal -sNaN771 -sNaN772 -> 1
|
||||
cotx981 comparetotal +sNaN771 -sNaN772 -> 1
|
||||
cotx982 comparetotal -sNaN771 +sNaN772 -> -1
|
||||
cotx983 comparetotal +sNaN771 +sNaN772 -> -1
|
||||
cotx984 comparetotal -sNaN772 -sNaN771 -> -1
|
||||
cotx985 comparetotal +sNaN772 -sNaN771 -> 1
|
||||
cotx986 comparetotal -sNaN772 +sNaN771 -> -1
|
||||
cotx987 comparetotal +sNaN772 +sNaN771 -> 1
|
||||
|
||||
cotx991 comparetotal -sNaN99 -Inf -> -1
|
||||
cotx992 comparetotal sNaN98 -11 -> 1
|
||||
cotx993 comparetotal sNaN97 NaN -> -1
|
||||
cotx994 comparetotal sNaN16 sNaN94 -> -1
|
||||
cotx995 comparetotal NaN85 sNaN83 -> 1
|
||||
cotx996 comparetotal -Inf sNaN92 -> -1
|
||||
cotx997 comparetotal 088 sNaN81 -> -1
|
||||
cotx998 comparetotal Inf sNaN90 -> -1
|
||||
cotx999 comparetotal NaN -sNaN89 -> 1
|
||||
|
||||
-- overflow and underflow tests .. subnormal results now allowed
|
||||
maxExponent: 999999999
|
||||
minexponent: -999999999
|
||||
cotx1080 comparetotal +1.23456789012345E-0 9E+999999999 -> -1
|
||||
cotx1081 comparetotal 9E+999999999 +1.23456789012345E-0 -> 1
|
||||
cotx1082 comparetotal +0.100 9E-999999999 -> 1
|
||||
cotx1083 comparetotal 9E-999999999 +0.100 -> -1
|
||||
cotx1085 comparetotal -1.23456789012345E-0 9E+999999999 -> -1
|
||||
cotx1086 comparetotal 9E+999999999 -1.23456789012345E-0 -> 1
|
||||
cotx1087 comparetotal -0.100 9E-999999999 -> -1
|
||||
cotx1088 comparetotal 9E-999999999 -0.100 -> 1
|
||||
|
||||
cotx1089 comparetotal 1e-599999999 1e-400000001 -> -1
|
||||
cotx1090 comparetotal 1e-599999999 1e-400000000 -> -1
|
||||
cotx1091 comparetotal 1e-600000000 1e-400000000 -> -1
|
||||
cotx1092 comparetotal 9e-999999998 0.01 -> -1
|
||||
cotx1093 comparetotal 9e-999999998 0.1 -> -1
|
||||
cotx1094 comparetotal 0.01 9e-999999998 -> 1
|
||||
cotx1095 comparetotal 1e599999999 1e400000001 -> 1
|
||||
cotx1096 comparetotal 1e599999999 1e400000000 -> 1
|
||||
cotx1097 comparetotal 1e600000000 1e400000000 -> 1
|
||||
cotx1098 comparetotal 9e999999998 100 -> 1
|
||||
cotx1099 comparetotal 9e999999998 10 -> 1
|
||||
cotx1100 comparetotal 100 9e999999998 -> -1
|
||||
-- signs
|
||||
cotx1101 comparetotal 1e+777777777 1e+411111111 -> 1
|
||||
cotx1102 comparetotal 1e+777777777 -1e+411111111 -> 1
|
||||
cotx1103 comparetotal -1e+777777777 1e+411111111 -> -1
|
||||
cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
|
||||
cotx1105 comparetotal 1e-777777777 1e-411111111 -> -1
|
||||
cotx1106 comparetotal 1e-777777777 -1e-411111111 -> 1
|
||||
cotx1107 comparetotal -1e-777777777 1e-411111111 -> -1
|
||||
cotx1108 comparetotal -1e-777777777 -1e-411111111 -> 1
|
||||
|
||||
-- spread zeros
|
||||
cotx1110 comparetotal 0E-383 0 -> -1
|
||||
cotx1111 comparetotal 0E-383 -0 -> 1
|
||||
cotx1112 comparetotal -0E-383 0 -> -1
|
||||
cotx1113 comparetotal -0E-383 -0 -> 1
|
||||
cotx1114 comparetotal 0E-383 0E+384 -> -1
|
||||
cotx1115 comparetotal 0E-383 -0E+384 -> 1
|
||||
cotx1116 comparetotal -0E-383 0E+384 -> -1
|
||||
cotx1117 comparetotal -0E-383 -0E+384 -> 1
|
||||
cotx1118 comparetotal 0 0E+384 -> -1
|
||||
cotx1119 comparetotal 0 -0E+384 -> 1
|
||||
cotx1120 comparetotal -0 0E+384 -> -1
|
||||
cotx1121 comparetotal -0 -0E+384 -> 1
|
||||
|
||||
cotx1130 comparetotal 0E+384 0 -> 1
|
||||
cotx1131 comparetotal 0E+384 -0 -> 1
|
||||
cotx1132 comparetotal -0E+384 0 -> -1
|
||||
cotx1133 comparetotal -0E+384 -0 -> -1
|
||||
cotx1134 comparetotal 0E+384 0E-383 -> 1
|
||||
cotx1135 comparetotal 0E+384 -0E-383 -> 1
|
||||
cotx1136 comparetotal -0E+384 0E-383 -> -1
|
||||
cotx1137 comparetotal -0E+384 -0E-383 -> -1
|
||||
cotx1138 comparetotal 0 0E-383 -> 1
|
||||
cotx1139 comparetotal 0 -0E-383 -> 1
|
||||
cotx1140 comparetotal -0 0E-383 -> -1
|
||||
cotx1141 comparetotal -0 -0E-383 -> -1
|
||||
|
||||
-- Null tests
|
||||
cotx9990 comparetotal 10 # -> NaN Invalid_operation
|
||||
cotx9991 comparetotal # 10 -> NaN Invalid_operation
|
@ -0,0 +1,790 @@
|
||||
------------------------------------------------------------------------
|
||||
-- comparetotmag.decTest -- decimal comparison, abs. total ordering --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that it cannot be assumed that add/subtract tests cover paths
|
||||
-- for this operation adequately, here, because the code might be
|
||||
-- quite different (comparison cannot overflow or underflow, so
|
||||
-- actual subtractions are not necessary). Similarly, comparetotal
|
||||
-- will have some radically different paths than compare.
|
||||
|
||||
extended: 1
|
||||
precision: 16
|
||||
rounding: half_up
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
|
||||
-- sanity checks
|
||||
ctmx001 comparetotmag -2 -2 -> 0
|
||||
ctmx002 comparetotmag -2 -1 -> 1
|
||||
ctmx003 comparetotmag -2 0 -> 1
|
||||
ctmx004 comparetotmag -2 1 -> 1
|
||||
ctmx005 comparetotmag -2 2 -> 0
|
||||
ctmx006 comparetotmag -1 -2 -> -1
|
||||
ctmx007 comparetotmag -1 -1 -> 0
|
||||
ctmx008 comparetotmag -1 0 -> 1
|
||||
ctmx009 comparetotmag -1 1 -> 0
|
||||
ctmx010 comparetotmag -1 2 -> -1
|
||||
ctmx011 comparetotmag 0 -2 -> -1
|
||||
ctmx012 comparetotmag 0 -1 -> -1
|
||||
ctmx013 comparetotmag 0 0 -> 0
|
||||
ctmx014 comparetotmag 0 1 -> -1
|
||||
ctmx015 comparetotmag 0 2 -> -1
|
||||
ctmx016 comparetotmag 1 -2 -> -1
|
||||
ctmx017 comparetotmag 1 -1 -> 0
|
||||
ctmx018 comparetotmag 1 0 -> 1
|
||||
ctmx019 comparetotmag 1 1 -> 0
|
||||
ctmx020 comparetotmag 1 2 -> -1
|
||||
ctmx021 comparetotmag 2 -2 -> 0
|
||||
ctmx022 comparetotmag 2 -1 -> 1
|
||||
ctmx023 comparetotmag 2 0 -> 1
|
||||
ctmx025 comparetotmag 2 1 -> 1
|
||||
ctmx026 comparetotmag 2 2 -> 0
|
||||
|
||||
ctmx031 comparetotmag -20 -20 -> 0
|
||||
ctmx032 comparetotmag -20 -10 -> 1
|
||||
ctmx033 comparetotmag -20 00 -> 1
|
||||
ctmx034 comparetotmag -20 10 -> 1
|
||||
ctmx035 comparetotmag -20 20 -> 0
|
||||
ctmx036 comparetotmag -10 -20 -> -1
|
||||
ctmx037 comparetotmag -10 -10 -> 0
|
||||
ctmx038 comparetotmag -10 00 -> 1
|
||||
ctmx039 comparetotmag -10 10 -> 0
|
||||
ctmx040 comparetotmag -10 20 -> -1
|
||||
ctmx041 comparetotmag 00 -20 -> -1
|
||||
ctmx042 comparetotmag 00 -10 -> -1
|
||||
ctmx043 comparetotmag 00 00 -> 0
|
||||
ctmx044 comparetotmag 00 10 -> -1
|
||||
ctmx045 comparetotmag 00 20 -> -1
|
||||
ctmx046 comparetotmag 10 -20 -> -1
|
||||
ctmx047 comparetotmag 10 -10 -> 0
|
||||
ctmx048 comparetotmag 10 00 -> 1
|
||||
ctmx049 comparetotmag 10 10 -> 0
|
||||
ctmx050 comparetotmag 10 20 -> -1
|
||||
ctmx051 comparetotmag 20 -20 -> 0
|
||||
ctmx052 comparetotmag 20 -10 -> 1
|
||||
ctmx053 comparetotmag 20 00 -> 1
|
||||
ctmx055 comparetotmag 20 10 -> 1
|
||||
ctmx056 comparetotmag 20 20 -> 0
|
||||
|
||||
ctmx061 comparetotmag -2.0 -2.0 -> 0
|
||||
ctmx062 comparetotmag -2.0 -1.0 -> 1
|
||||
ctmx063 comparetotmag -2.0 0.0 -> 1
|
||||
ctmx064 comparetotmag -2.0 1.0 -> 1
|
||||
ctmx065 comparetotmag -2.0 2.0 -> 0
|
||||
ctmx066 comparetotmag -1.0 -2.0 -> -1
|
||||
ctmx067 comparetotmag -1.0 -1.0 -> 0
|
||||
ctmx068 comparetotmag -1.0 0.0 -> 1
|
||||
ctmx069 comparetotmag -1.0 1.0 -> 0
|
||||
ctmx070 comparetotmag -1.0 2.0 -> -1
|
||||
ctmx071 comparetotmag 0.0 -2.0 -> -1
|
||||
ctmx072 comparetotmag 0.0 -1.0 -> -1
|
||||
ctmx073 comparetotmag 0.0 0.0 -> 0
|
||||
ctmx074 comparetotmag 0.0 1.0 -> -1
|
||||
ctmx075 comparetotmag 0.0 2.0 -> -1
|
||||
ctmx076 comparetotmag 1.0 -2.0 -> -1
|
||||
ctmx077 comparetotmag 1.0 -1.0 -> 0
|
||||
ctmx078 comparetotmag 1.0 0.0 -> 1
|
||||
ctmx079 comparetotmag 1.0 1.0 -> 0
|
||||
ctmx080 comparetotmag 1.0 2.0 -> -1
|
||||
ctmx081 comparetotmag 2.0 -2.0 -> 0
|
||||
ctmx082 comparetotmag 2.0 -1.0 -> 1
|
||||
ctmx083 comparetotmag 2.0 0.0 -> 1
|
||||
ctmx085 comparetotmag 2.0 1.0 -> 1
|
||||
ctmx086 comparetotmag 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
maxexponent: 999999999
|
||||
minexponent: -999999999
|
||||
ctmx090 comparetotmag 9.99999999E+999999999 9.99999999E+999999999 -> 0
|
||||
ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999 -> 0
|
||||
ctmx092 comparetotmag 9.99999999E+999999999 -9.99999999E+999999999 -> 0
|
||||
ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
-- in this first group, compare would compare all equal
|
||||
ctmx100 comparetotmag 7.0 7.0 -> 0
|
||||
ctmx101 comparetotmag 7.0 7 -> -1
|
||||
ctmx102 comparetotmag 7 7.0 -> 1
|
||||
ctmx103 comparetotmag 7E+0 7.0 -> 1
|
||||
ctmx104 comparetotmag 70E-1 7.0 -> 0
|
||||
ctmx105 comparetotmag 0.7E+1 7 -> 0
|
||||
ctmx106 comparetotmag 70E-1 7 -> -1
|
||||
ctmx107 comparetotmag 7.0 7E+0 -> -1
|
||||
ctmx108 comparetotmag 7.0 70E-1 -> 0
|
||||
ctmx109 comparetotmag 7 0.7E+1 -> 0
|
||||
ctmx110 comparetotmag 7 70E-1 -> 1
|
||||
|
||||
ctmx120 comparetotmag 8.0 7.0 -> 1
|
||||
ctmx121 comparetotmag 8.0 7 -> 1
|
||||
ctmx122 comparetotmag 8 7.0 -> 1
|
||||
ctmx123 comparetotmag 8E+0 7.0 -> 1
|
||||
ctmx124 comparetotmag 80E-1 7.0 -> 1
|
||||
ctmx125 comparetotmag 0.8E+1 7 -> 1
|
||||
ctmx126 comparetotmag 80E-1 7 -> 1
|
||||
ctmx127 comparetotmag 8.0 7E+0 -> 1
|
||||
ctmx128 comparetotmag 8.0 70E-1 -> 1
|
||||
ctmx129 comparetotmag 8 0.7E+1 -> 1
|
||||
ctmx130 comparetotmag 8 70E-1 -> 1
|
||||
|
||||
ctmx140 comparetotmag 8.0 9.0 -> -1
|
||||
ctmx141 comparetotmag 8.0 9 -> -1
|
||||
ctmx142 comparetotmag 8 9.0 -> -1
|
||||
ctmx143 comparetotmag 8E+0 9.0 -> -1
|
||||
ctmx144 comparetotmag 80E-1 9.0 -> -1
|
||||
ctmx145 comparetotmag 0.8E+1 9 -> -1
|
||||
ctmx146 comparetotmag 80E-1 9 -> -1
|
||||
ctmx147 comparetotmag 8.0 9E+0 -> -1
|
||||
ctmx148 comparetotmag 8.0 90E-1 -> -1
|
||||
ctmx149 comparetotmag 8 0.9E+1 -> -1
|
||||
ctmx150 comparetotmag 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
ctmx200 comparetotmag -7.0 7.0 -> 0
|
||||
ctmx201 comparetotmag -7.0 7 -> -1
|
||||
ctmx202 comparetotmag -7 7.0 -> 1
|
||||
ctmx203 comparetotmag -7E+0 7.0 -> 1
|
||||
ctmx204 comparetotmag -70E-1 7.0 -> 0
|
||||
ctmx205 comparetotmag -0.7E+1 7 -> 0
|
||||
ctmx206 comparetotmag -70E-1 7 -> -1
|
||||
ctmx207 comparetotmag -7.0 7E+0 -> -1
|
||||
ctmx208 comparetotmag -7.0 70E-1 -> 0
|
||||
ctmx209 comparetotmag -7 0.7E+1 -> 0
|
||||
ctmx210 comparetotmag -7 70E-1 -> 1
|
||||
|
||||
ctmx220 comparetotmag -8.0 7.0 -> 1
|
||||
ctmx221 comparetotmag -8.0 7 -> 1
|
||||
ctmx222 comparetotmag -8 7.0 -> 1
|
||||
ctmx223 comparetotmag -8E+0 7.0 -> 1
|
||||
ctmx224 comparetotmag -80E-1 7.0 -> 1
|
||||
ctmx225 comparetotmag -0.8E+1 7 -> 1
|
||||
ctmx226 comparetotmag -80E-1 7 -> 1
|
||||
ctmx227 comparetotmag -8.0 7E+0 -> 1
|
||||
ctmx228 comparetotmag -8.0 70E-1 -> 1
|
||||
ctmx229 comparetotmag -8 0.7E+1 -> 1
|
||||
ctmx230 comparetotmag -8 70E-1 -> 1
|
||||
|
||||
ctmx240 comparetotmag -8.0 9.0 -> -1
|
||||
ctmx241 comparetotmag -8.0 9 -> -1
|
||||
ctmx242 comparetotmag -8 9.0 -> -1
|
||||
ctmx243 comparetotmag -8E+0 9.0 -> -1
|
||||
ctmx244 comparetotmag -80E-1 9.0 -> -1
|
||||
ctmx245 comparetotmag -0.8E+1 9 -> -1
|
||||
ctmx246 comparetotmag -80E-1 9 -> -1
|
||||
ctmx247 comparetotmag -8.0 9E+0 -> -1
|
||||
ctmx248 comparetotmag -8.0 90E-1 -> -1
|
||||
ctmx249 comparetotmag -8 0.9E+1 -> -1
|
||||
ctmx250 comparetotmag -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
ctmx300 comparetotmag 7.0 -7.0 -> 0
|
||||
ctmx301 comparetotmag 7.0 -7 -> -1
|
||||
ctmx302 comparetotmag 7 -7.0 -> 1
|
||||
ctmx303 comparetotmag 7E+0 -7.0 -> 1
|
||||
ctmx304 comparetotmag 70E-1 -7.0 -> 0
|
||||
ctmx305 comparetotmag .7E+1 -7 -> 0
|
||||
ctmx306 comparetotmag 70E-1 -7 -> -1
|
||||
ctmx307 comparetotmag 7.0 -7E+0 -> -1
|
||||
ctmx308 comparetotmag 7.0 -70E-1 -> 0
|
||||
ctmx309 comparetotmag 7 -.7E+1 -> 0
|
||||
ctmx310 comparetotmag 7 -70E-1 -> 1
|
||||
|
||||
ctmx320 comparetotmag 8.0 -7.0 -> 1
|
||||
ctmx321 comparetotmag 8.0 -7 -> 1
|
||||
ctmx322 comparetotmag 8 -7.0 -> 1
|
||||
ctmx323 comparetotmag 8E+0 -7.0 -> 1
|
||||
ctmx324 comparetotmag 80E-1 -7.0 -> 1
|
||||
ctmx325 comparetotmag .8E+1 -7 -> 1
|
||||
ctmx326 comparetotmag 80E-1 -7 -> 1
|
||||
ctmx327 comparetotmag 8.0 -7E+0 -> 1
|
||||
ctmx328 comparetotmag 8.0 -70E-1 -> 1
|
||||
ctmx329 comparetotmag 8 -.7E+1 -> 1
|
||||
ctmx330 comparetotmag 8 -70E-1 -> 1
|
||||
|
||||
ctmx340 comparetotmag 8.0 -9.0 -> -1
|
||||
ctmx341 comparetotmag 8.0 -9 -> -1
|
||||
ctmx342 comparetotmag 8 -9.0 -> -1
|
||||
ctmx343 comparetotmag 8E+0 -9.0 -> -1
|
||||
ctmx344 comparetotmag 80E-1 -9.0 -> -1
|
||||
ctmx345 comparetotmag .8E+1 -9 -> -1
|
||||
ctmx346 comparetotmag 80E-1 -9 -> -1
|
||||
ctmx347 comparetotmag 8.0 -9E+0 -> -1
|
||||
ctmx348 comparetotmag 8.0 -90E-1 -> -1
|
||||
ctmx349 comparetotmag 8 -.9E+1 -> -1
|
||||
ctmx350 comparetotmag 8 -90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
ctmx400 comparetotmag -7.0 -7.0 -> 0
|
||||
ctmx401 comparetotmag -7.0 -7 -> -1
|
||||
ctmx402 comparetotmag -7 -7.0 -> 1
|
||||
ctmx403 comparetotmag -7E+0 -7.0 -> 1
|
||||
ctmx404 comparetotmag -70E-1 -7.0 -> 0
|
||||
ctmx405 comparetotmag -.7E+1 -7 -> 0
|
||||
ctmx406 comparetotmag -70E-1 -7 -> -1
|
||||
ctmx407 comparetotmag -7.0 -7E+0 -> -1
|
||||
ctmx408 comparetotmag -7.0 -70E-1 -> 0
|
||||
ctmx409 comparetotmag -7 -.7E+1 -> 0
|
||||
ctmx410 comparetotmag -7 -70E-1 -> 1
|
||||
|
||||
ctmx420 comparetotmag -8.0 -7.0 -> 1
|
||||
ctmx421 comparetotmag -8.0 -7 -> 1
|
||||
ctmx422 comparetotmag -8 -7.0 -> 1
|
||||
ctmx423 comparetotmag -8E+0 -7.0 -> 1
|
||||
ctmx424 comparetotmag -80E-1 -7.0 -> 1
|
||||
ctmx425 comparetotmag -.8E+1 -7 -> 1
|
||||
ctmx426 comparetotmag -80E-1 -7 -> 1
|
||||
ctmx427 comparetotmag -8.0 -7E+0 -> 1
|
||||
ctmx428 comparetotmag -8.0 -70E-1 -> 1
|
||||
ctmx429 comparetotmag -8 -.7E+1 -> 1
|
||||
ctmx430 comparetotmag -8 -70E-1 -> 1
|
||||
|
||||
ctmx440 comparetotmag -8.0 -9.0 -> -1
|
||||
ctmx441 comparetotmag -8.0 -9 -> -1
|
||||
ctmx442 comparetotmag -8 -9.0 -> -1
|
||||
ctmx443 comparetotmag -8E+0 -9.0 -> -1
|
||||
ctmx444 comparetotmag -80E-1 -9.0 -> -1
|
||||
ctmx445 comparetotmag -.8E+1 -9 -> -1
|
||||
ctmx446 comparetotmag -80E-1 -9 -> -1
|
||||
ctmx447 comparetotmag -8.0 -9E+0 -> -1
|
||||
ctmx448 comparetotmag -8.0 -90E-1 -> -1
|
||||
ctmx449 comparetotmag -8 -.9E+1 -> -1
|
||||
ctmx450 comparetotmag -8 -90E-1 -> -1
|
||||
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
precision: 40
|
||||
ctmx470 comparetotmag 123.4560000000000000E789 123.456E789 -> -1
|
||||
ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89 -> -1
|
||||
ctmx472 comparetotmag 123.45600000000000E789 123.456E789 -> -1
|
||||
ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
|
||||
ctmx474 comparetotmag 123.456000000000E789 123.456E789 -> -1
|
||||
ctmx475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
|
||||
ctmx476 comparetotmag 123.4560000000E789 123.456E789 -> -1
|
||||
ctmx477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
|
||||
ctmx478 comparetotmag 123.45600000E789 123.456E789 -> -1
|
||||
ctmx479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
|
||||
ctmx480 comparetotmag 123.456000E789 123.456E789 -> -1
|
||||
ctmx481 comparetotmag 123.45600E-89 123.456E-89 -> -1
|
||||
ctmx482 comparetotmag 123.4560E789 123.456E789 -> -1
|
||||
ctmx483 comparetotmag 123.456E-89 123.456E-89 -> 0
|
||||
ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89 -> 1
|
||||
ctmx485 comparetotmag 123.456E789 123.456000000000000E789 -> 1
|
||||
ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89 -> 1
|
||||
ctmx487 comparetotmag 123.456E789 123.4560000000000E789 -> 1
|
||||
ctmx488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
|
||||
ctmx489 comparetotmag 123.456E789 123.45600000000E789 -> 1
|
||||
ctmx490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
|
||||
ctmx491 comparetotmag 123.456E789 123.456000000E789 -> 1
|
||||
ctmx492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
|
||||
ctmx493 comparetotmag 123.456E789 123.4560000E789 -> 1
|
||||
ctmx494 comparetotmag 123.456E-89 123.456000E-89 -> 1
|
||||
ctmx495 comparetotmag 123.456E789 123.45600E789 -> 1
|
||||
ctmx496 comparetotmag 123.456E-89 123.4560E-89 -> 1
|
||||
ctmx497 comparetotmag 123.456E789 123.456E789 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
precision: 9
|
||||
ctmx500 comparetotmag 1 1E-15 -> 1
|
||||
ctmx501 comparetotmag 1 1E-14 -> 1
|
||||
ctmx502 comparetotmag 1 1E-13 -> 1
|
||||
ctmx503 comparetotmag 1 1E-12 -> 1
|
||||
ctmx504 comparetotmag 1 1E-11 -> 1
|
||||
ctmx505 comparetotmag 1 1E-10 -> 1
|
||||
ctmx506 comparetotmag 1 1E-9 -> 1
|
||||
ctmx507 comparetotmag 1 1E-8 -> 1
|
||||
ctmx508 comparetotmag 1 1E-7 -> 1
|
||||
ctmx509 comparetotmag 1 1E-6 -> 1
|
||||
ctmx510 comparetotmag 1 1E-5 -> 1
|
||||
ctmx511 comparetotmag 1 1E-4 -> 1
|
||||
ctmx512 comparetotmag 1 1E-3 -> 1
|
||||
ctmx513 comparetotmag 1 1E-2 -> 1
|
||||
ctmx514 comparetotmag 1 1E-1 -> 1
|
||||
ctmx515 comparetotmag 1 1E-0 -> 0
|
||||
ctmx516 comparetotmag 1 1E+1 -> -1
|
||||
ctmx517 comparetotmag 1 1E+2 -> -1
|
||||
ctmx518 comparetotmag 1 1E+3 -> -1
|
||||
ctmx519 comparetotmag 1 1E+4 -> -1
|
||||
ctmx521 comparetotmag 1 1E+5 -> -1
|
||||
ctmx522 comparetotmag 1 1E+6 -> -1
|
||||
ctmx523 comparetotmag 1 1E+7 -> -1
|
||||
ctmx524 comparetotmag 1 1E+8 -> -1
|
||||
ctmx525 comparetotmag 1 1E+9 -> -1
|
||||
ctmx526 comparetotmag 1 1E+10 -> -1
|
||||
ctmx527 comparetotmag 1 1E+11 -> -1
|
||||
ctmx528 comparetotmag 1 1E+12 -> -1
|
||||
ctmx529 comparetotmag 1 1E+13 -> -1
|
||||
ctmx530 comparetotmag 1 1E+14 -> -1
|
||||
ctmx531 comparetotmag 1 1E+15 -> -1
|
||||
-- LR swap
|
||||
ctmx540 comparetotmag 1E-15 1 -> -1
|
||||
ctmx541 comparetotmag 1E-14 1 -> -1
|
||||
ctmx542 comparetotmag 1E-13 1 -> -1
|
||||
ctmx543 comparetotmag 1E-12 1 -> -1
|
||||
ctmx544 comparetotmag 1E-11 1 -> -1
|
||||
ctmx545 comparetotmag 1E-10 1 -> -1
|
||||
ctmx546 comparetotmag 1E-9 1 -> -1
|
||||
ctmx547 comparetotmag 1E-8 1 -> -1
|
||||
ctmx548 comparetotmag 1E-7 1 -> -1
|
||||
ctmx549 comparetotmag 1E-6 1 -> -1
|
||||
ctmx550 comparetotmag 1E-5 1 -> -1
|
||||
ctmx551 comparetotmag 1E-4 1 -> -1
|
||||
ctmx552 comparetotmag 1E-3 1 -> -1
|
||||
ctmx553 comparetotmag 1E-2 1 -> -1
|
||||
ctmx554 comparetotmag 1E-1 1 -> -1
|
||||
ctmx555 comparetotmag 1E-0 1 -> 0
|
||||
ctmx556 comparetotmag 1E+1 1 -> 1
|
||||
ctmx557 comparetotmag 1E+2 1 -> 1
|
||||
ctmx558 comparetotmag 1E+3 1 -> 1
|
||||
ctmx559 comparetotmag 1E+4 1 -> 1
|
||||
ctmx561 comparetotmag 1E+5 1 -> 1
|
||||
ctmx562 comparetotmag 1E+6 1 -> 1
|
||||
ctmx563 comparetotmag 1E+7 1 -> 1
|
||||
ctmx564 comparetotmag 1E+8 1 -> 1
|
||||
ctmx565 comparetotmag 1E+9 1 -> 1
|
||||
ctmx566 comparetotmag 1E+10 1 -> 1
|
||||
ctmx567 comparetotmag 1E+11 1 -> 1
|
||||
ctmx568 comparetotmag 1E+12 1 -> 1
|
||||
ctmx569 comparetotmag 1E+13 1 -> 1
|
||||
ctmx570 comparetotmag 1E+14 1 -> 1
|
||||
ctmx571 comparetotmag 1E+15 1 -> 1
|
||||
-- similar with an useful coefficient, one side only
|
||||
ctmx580 comparetotmag 0.000000987654321 1E-15 -> 1
|
||||
ctmx581 comparetotmag 0.000000987654321 1E-14 -> 1
|
||||
ctmx582 comparetotmag 0.000000987654321 1E-13 -> 1
|
||||
ctmx583 comparetotmag 0.000000987654321 1E-12 -> 1
|
||||
ctmx584 comparetotmag 0.000000987654321 1E-11 -> 1
|
||||
ctmx585 comparetotmag 0.000000987654321 1E-10 -> 1
|
||||
ctmx586 comparetotmag 0.000000987654321 1E-9 -> 1
|
||||
ctmx587 comparetotmag 0.000000987654321 1E-8 -> 1
|
||||
ctmx588 comparetotmag 0.000000987654321 1E-7 -> 1
|
||||
ctmx589 comparetotmag 0.000000987654321 1E-6 -> -1
|
||||
ctmx590 comparetotmag 0.000000987654321 1E-5 -> -1
|
||||
ctmx591 comparetotmag 0.000000987654321 1E-4 -> -1
|
||||
ctmx592 comparetotmag 0.000000987654321 1E-3 -> -1
|
||||
ctmx593 comparetotmag 0.000000987654321 1E-2 -> -1
|
||||
ctmx594 comparetotmag 0.000000987654321 1E-1 -> -1
|
||||
ctmx595 comparetotmag 0.000000987654321 1E-0 -> -1
|
||||
ctmx596 comparetotmag 0.000000987654321 1E+1 -> -1
|
||||
ctmx597 comparetotmag 0.000000987654321 1E+2 -> -1
|
||||
ctmx598 comparetotmag 0.000000987654321 1E+3 -> -1
|
||||
ctmx599 comparetotmag 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
precision: 20
|
||||
ctmx600 comparetotmag 12 12.2345 -> -1
|
||||
ctmx601 comparetotmag 12.0 12.2345 -> -1
|
||||
ctmx602 comparetotmag 12.00 12.2345 -> -1
|
||||
ctmx603 comparetotmag 12.000 12.2345 -> -1
|
||||
ctmx604 comparetotmag 12.0000 12.2345 -> -1
|
||||
ctmx605 comparetotmag 12.00000 12.2345 -> -1
|
||||
ctmx606 comparetotmag 12.000000 12.2345 -> -1
|
||||
ctmx607 comparetotmag 12.0000000 12.2345 -> -1
|
||||
ctmx608 comparetotmag 12.00000000 12.2345 -> -1
|
||||
ctmx609 comparetotmag 12.000000000 12.2345 -> -1
|
||||
ctmx610 comparetotmag 12.1234 12 -> 1
|
||||
ctmx611 comparetotmag 12.1234 12.0 -> 1
|
||||
ctmx612 comparetotmag 12.1234 12.00 -> 1
|
||||
ctmx613 comparetotmag 12.1234 12.000 -> 1
|
||||
ctmx614 comparetotmag 12.1234 12.0000 -> 1
|
||||
ctmx615 comparetotmag 12.1234 12.00000 -> 1
|
||||
ctmx616 comparetotmag 12.1234 12.000000 -> 1
|
||||
ctmx617 comparetotmag 12.1234 12.0000000 -> 1
|
||||
ctmx618 comparetotmag 12.1234 12.00000000 -> 1
|
||||
ctmx619 comparetotmag 12.1234 12.000000000 -> 1
|
||||
ctmx620 comparetotmag -12 -12.2345 -> -1
|
||||
ctmx621 comparetotmag -12.0 -12.2345 -> -1
|
||||
ctmx622 comparetotmag -12.00 -12.2345 -> -1
|
||||
ctmx623 comparetotmag -12.000 -12.2345 -> -1
|
||||
ctmx624 comparetotmag -12.0000 -12.2345 -> -1
|
||||
ctmx625 comparetotmag -12.00000 -12.2345 -> -1
|
||||
ctmx626 comparetotmag -12.000000 -12.2345 -> -1
|
||||
ctmx627 comparetotmag -12.0000000 -12.2345 -> -1
|
||||
ctmx628 comparetotmag -12.00000000 -12.2345 -> -1
|
||||
ctmx629 comparetotmag -12.000000000 -12.2345 -> -1
|
||||
ctmx630 comparetotmag -12.1234 -12 -> 1
|
||||
ctmx631 comparetotmag -12.1234 -12.0 -> 1
|
||||
ctmx632 comparetotmag -12.1234 -12.00 -> 1
|
||||
ctmx633 comparetotmag -12.1234 -12.000 -> 1
|
||||
ctmx634 comparetotmag -12.1234 -12.0000 -> 1
|
||||
ctmx635 comparetotmag -12.1234 -12.00000 -> 1
|
||||
ctmx636 comparetotmag -12.1234 -12.000000 -> 1
|
||||
ctmx637 comparetotmag -12.1234 -12.0000000 -> 1
|
||||
ctmx638 comparetotmag -12.1234 -12.00000000 -> 1
|
||||
ctmx639 comparetotmag -12.1234 -12.000000000 -> 1
|
||||
precision: 9
|
||||
|
||||
-- extended zeros
|
||||
ctmx640 comparetotmag 0 0 -> 0
|
||||
ctmx641 comparetotmag 0 -0 -> 0
|
||||
ctmx642 comparetotmag 0 -0.0 -> 1
|
||||
ctmx643 comparetotmag 0 0.0 -> 1
|
||||
ctmx644 comparetotmag -0 0 -> 0
|
||||
ctmx645 comparetotmag -0 -0 -> 0
|
||||
ctmx646 comparetotmag -0 -0.0 -> 1
|
||||
ctmx647 comparetotmag -0 0.0 -> 1
|
||||
ctmx648 comparetotmag 0.0 0 -> -1
|
||||
ctmx649 comparetotmag 0.0 -0 -> -1
|
||||
ctmx650 comparetotmag 0.0 -0.0 -> 0
|
||||
ctmx651 comparetotmag 0.0 0.0 -> 0
|
||||
ctmx652 comparetotmag -0.0 0 -> -1
|
||||
ctmx653 comparetotmag -0.0 -0 -> -1
|
||||
ctmx654 comparetotmag -0.0 -0.0 -> 0
|
||||
ctmx655 comparetotmag -0.0 0.0 -> 0
|
||||
|
||||
ctmx656 comparetotmag -0E1 0.0 -> 1
|
||||
ctmx657 comparetotmag -0E2 0.0 -> 1
|
||||
ctmx658 comparetotmag 0E1 0.0 -> 1
|
||||
ctmx659 comparetotmag 0E2 0.0 -> 1
|
||||
ctmx660 comparetotmag -0E1 0 -> 1
|
||||
ctmx661 comparetotmag -0E2 0 -> 1
|
||||
ctmx662 comparetotmag 0E1 0 -> 1
|
||||
ctmx663 comparetotmag 0E2 0 -> 1
|
||||
ctmx664 comparetotmag -0E1 -0E1 -> 0
|
||||
ctmx665 comparetotmag -0E2 -0E1 -> 1
|
||||
ctmx666 comparetotmag 0E1 -0E1 -> 0
|
||||
ctmx667 comparetotmag 0E2 -0E1 -> 1
|
||||
ctmx668 comparetotmag -0E1 -0E2 -> -1
|
||||
ctmx669 comparetotmag -0E2 -0E2 -> 0
|
||||
ctmx670 comparetotmag 0E1 -0E2 -> -1
|
||||
ctmx671 comparetotmag 0E2 -0E2 -> 0
|
||||
ctmx672 comparetotmag -0E1 0E1 -> 0
|
||||
ctmx673 comparetotmag -0E2 0E1 -> 1
|
||||
ctmx674 comparetotmag 0E1 0E1 -> 0
|
||||
ctmx675 comparetotmag 0E2 0E1 -> 1
|
||||
ctmx676 comparetotmag -0E1 0E2 -> -1
|
||||
ctmx677 comparetotmag -0E2 0E2 -> 0
|
||||
ctmx678 comparetotmag 0E1 0E2 -> -1
|
||||
ctmx679 comparetotmag 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
precision: 20
|
||||
ctmx680 comparetotmag 12 12 -> 0
|
||||
ctmx681 comparetotmag 12 12.0 -> 1
|
||||
ctmx682 comparetotmag 12 12.00 -> 1
|
||||
ctmx683 comparetotmag 12 12.000 -> 1
|
||||
ctmx684 comparetotmag 12 12.0000 -> 1
|
||||
ctmx685 comparetotmag 12 12.00000 -> 1
|
||||
ctmx686 comparetotmag 12 12.000000 -> 1
|
||||
ctmx687 comparetotmag 12 12.0000000 -> 1
|
||||
ctmx688 comparetotmag 12 12.00000000 -> 1
|
||||
ctmx689 comparetotmag 12 12.000000000 -> 1
|
||||
ctmx690 comparetotmag 12 12 -> 0
|
||||
ctmx691 comparetotmag 12.0 12 -> -1
|
||||
ctmx692 comparetotmag 12.00 12 -> -1
|
||||
ctmx693 comparetotmag 12.000 12 -> -1
|
||||
ctmx694 comparetotmag 12.0000 12 -> -1
|
||||
ctmx695 comparetotmag 12.00000 12 -> -1
|
||||
ctmx696 comparetotmag 12.000000 12 -> -1
|
||||
ctmx697 comparetotmag 12.0000000 12 -> -1
|
||||
ctmx698 comparetotmag 12.00000000 12 -> -1
|
||||
ctmx699 comparetotmag 12.000000000 12 -> -1
|
||||
|
||||
-- long operand checks
|
||||
maxexponent: 999
|
||||
minexponent: -999
|
||||
precision: 9
|
||||
ctmx701 comparetotmag 12345678000 1 -> 1
|
||||
ctmx702 comparetotmag 1 12345678000 -> -1
|
||||
ctmx703 comparetotmag 1234567800 1 -> 1
|
||||
ctmx704 comparetotmag 1 1234567800 -> -1
|
||||
ctmx705 comparetotmag 1234567890 1 -> 1
|
||||
ctmx706 comparetotmag 1 1234567890 -> -1
|
||||
ctmx707 comparetotmag 1234567891 1 -> 1
|
||||
ctmx708 comparetotmag 1 1234567891 -> -1
|
||||
ctmx709 comparetotmag 12345678901 1 -> 1
|
||||
ctmx710 comparetotmag 1 12345678901 -> -1
|
||||
ctmx711 comparetotmag 1234567896 1 -> 1
|
||||
ctmx712 comparetotmag 1 1234567896 -> -1
|
||||
ctmx713 comparetotmag -1234567891 1 -> 1
|
||||
ctmx714 comparetotmag 1 -1234567891 -> -1
|
||||
ctmx715 comparetotmag -12345678901 1 -> 1
|
||||
ctmx716 comparetotmag 1 -12345678901 -> -1
|
||||
ctmx717 comparetotmag -1234567896 1 -> 1
|
||||
ctmx718 comparetotmag 1 -1234567896 -> -1
|
||||
|
||||
precision: 15
|
||||
-- same with plenty of precision
|
||||
ctmx721 comparetotmag 12345678000 1 -> 1
|
||||
ctmx722 comparetotmag 1 12345678000 -> -1
|
||||
ctmx723 comparetotmag 1234567800 1 -> 1
|
||||
ctmx724 comparetotmag 1 1234567800 -> -1
|
||||
ctmx725 comparetotmag 1234567890 1 -> 1
|
||||
ctmx726 comparetotmag 1 1234567890 -> -1
|
||||
ctmx727 comparetotmag 1234567891 1 -> 1
|
||||
ctmx728 comparetotmag 1 1234567891 -> -1
|
||||
ctmx729 comparetotmag 12345678901 1 -> 1
|
||||
ctmx730 comparetotmag 1 12345678901 -> -1
|
||||
ctmx731 comparetotmag 1234567896 1 -> 1
|
||||
ctmx732 comparetotmag 1 1234567896 -> -1
|
||||
|
||||
-- residue cases
|
||||
precision: 5
|
||||
ctmx740 comparetotmag 1 0.9999999 -> 1
|
||||
ctmx741 comparetotmag 1 0.999999 -> 1
|
||||
ctmx742 comparetotmag 1 0.99999 -> 1
|
||||
ctmx743 comparetotmag 1 1.0000 -> 1
|
||||
ctmx744 comparetotmag 1 1.00001 -> -1
|
||||
ctmx745 comparetotmag 1 1.000001 -> -1
|
||||
ctmx746 comparetotmag 1 1.0000001 -> -1
|
||||
ctmx750 comparetotmag 0.9999999 1 -> -1
|
||||
ctmx751 comparetotmag 0.999999 1 -> -1
|
||||
ctmx752 comparetotmag 0.99999 1 -> -1
|
||||
ctmx753 comparetotmag 1.0000 1 -> -1
|
||||
ctmx754 comparetotmag 1.00001 1 -> 1
|
||||
ctmx755 comparetotmag 1.000001 1 -> 1
|
||||
ctmx756 comparetotmag 1.0000001 1 -> 1
|
||||
|
||||
-- a selection of longies
|
||||
ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> 1
|
||||
ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
|
||||
ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> 1
|
||||
ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
-- precisions above or below the difference should have no effect
|
||||
precision: 11
|
||||
ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 10
|
||||
ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 9
|
||||
ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 8
|
||||
ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 7
|
||||
ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 6
|
||||
ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 5
|
||||
ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 4
|
||||
ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 3
|
||||
ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 2
|
||||
ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
precision: 1
|
||||
ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
|
||||
|
||||
-- Specials
|
||||
precision: 9
|
||||
ctmx780 comparetotmag Inf -Inf -> 0
|
||||
ctmx781 comparetotmag Inf -1000 -> 1
|
||||
ctmx782 comparetotmag Inf -1 -> 1
|
||||
ctmx783 comparetotmag Inf -0 -> 1
|
||||
ctmx784 comparetotmag Inf 0 -> 1
|
||||
ctmx785 comparetotmag Inf 1 -> 1
|
||||
ctmx786 comparetotmag Inf 1000 -> 1
|
||||
ctmx787 comparetotmag Inf Inf -> 0
|
||||
ctmx788 comparetotmag -1000 Inf -> -1
|
||||
ctmx789 comparetotmag -Inf Inf -> 0
|
||||
ctmx790 comparetotmag -1 Inf -> -1
|
||||
ctmx791 comparetotmag -0 Inf -> -1
|
||||
ctmx792 comparetotmag 0 Inf -> -1
|
||||
ctmx793 comparetotmag 1 Inf -> -1
|
||||
ctmx794 comparetotmag 1000 Inf -> -1
|
||||
ctmx795 comparetotmag Inf Inf -> 0
|
||||
|
||||
ctmx800 comparetotmag -Inf -Inf -> 0
|
||||
ctmx801 comparetotmag -Inf -1000 -> 1
|
||||
ctmx802 comparetotmag -Inf -1 -> 1
|
||||
ctmx803 comparetotmag -Inf -0 -> 1
|
||||
ctmx804 comparetotmag -Inf 0 -> 1
|
||||
ctmx805 comparetotmag -Inf 1 -> 1
|
||||
ctmx806 comparetotmag -Inf 1000 -> 1
|
||||
ctmx807 comparetotmag -Inf Inf -> 0
|
||||
ctmx808 comparetotmag -Inf -Inf -> 0
|
||||
ctmx809 comparetotmag -1000 -Inf -> -1
|
||||
ctmx810 comparetotmag -1 -Inf -> -1
|
||||
ctmx811 comparetotmag -0 -Inf -> -1
|
||||
ctmx812 comparetotmag 0 -Inf -> -1
|
||||
ctmx813 comparetotmag 1 -Inf -> -1
|
||||
ctmx814 comparetotmag 1000 -Inf -> -1
|
||||
ctmx815 comparetotmag Inf -Inf -> 0
|
||||
|
||||
ctmx821 comparetotmag NaN -Inf -> 1
|
||||
ctmx822 comparetotmag NaN -1000 -> 1
|
||||
ctmx823 comparetotmag NaN -1 -> 1
|
||||
ctmx824 comparetotmag NaN -0 -> 1
|
||||
ctmx825 comparetotmag NaN 0 -> 1
|
||||
ctmx826 comparetotmag NaN 1 -> 1
|
||||
ctmx827 comparetotmag NaN 1000 -> 1
|
||||
ctmx828 comparetotmag NaN Inf -> 1
|
||||
ctmx829 comparetotmag NaN NaN -> 0
|
||||
ctmx830 comparetotmag -Inf NaN -> -1
|
||||
ctmx831 comparetotmag -1000 NaN -> -1
|
||||
ctmx832 comparetotmag -1 NaN -> -1
|
||||
ctmx833 comparetotmag -0 NaN -> -1
|
||||
ctmx834 comparetotmag 0 NaN -> -1
|
||||
ctmx835 comparetotmag 1 NaN -> -1
|
||||
ctmx836 comparetotmag 1000 NaN -> -1
|
||||
ctmx837 comparetotmag Inf NaN -> -1
|
||||
ctmx838 comparetotmag -NaN -NaN -> 0
|
||||
ctmx839 comparetotmag +NaN -NaN -> 0
|
||||
ctmx840 comparetotmag -NaN +NaN -> 0
|
||||
|
||||
ctmx841 comparetotmag sNaN -sNaN -> 0
|
||||
ctmx842 comparetotmag sNaN -NaN -> -1
|
||||
ctmx843 comparetotmag sNaN -Inf -> 1
|
||||
ctmx844 comparetotmag sNaN -1000 -> 1
|
||||
ctmx845 comparetotmag sNaN -1 -> 1
|
||||
ctmx846 comparetotmag sNaN -0 -> 1
|
||||
ctmx847 comparetotmag sNaN 0 -> 1
|
||||
ctmx848 comparetotmag sNaN 1 -> 1
|
||||
ctmx849 comparetotmag sNaN 1000 -> 1
|
||||
ctmx850 comparetotmag sNaN NaN -> -1
|
||||
ctmx851 comparetotmag sNaN sNaN -> 0
|
||||
|
||||
ctmx852 comparetotmag -sNaN sNaN -> 0
|
||||
ctmx853 comparetotmag -NaN sNaN -> 1
|
||||
ctmx854 comparetotmag -Inf sNaN -> -1
|
||||
ctmx855 comparetotmag -1000 sNaN -> -1
|
||||
ctmx856 comparetotmag -1 sNaN -> -1
|
||||
ctmx857 comparetotmag -0 sNaN -> -1
|
||||
ctmx858 comparetotmag 0 sNaN -> -1
|
||||
ctmx859 comparetotmag 1 sNaN -> -1
|
||||
ctmx860 comparetotmag 1000 sNaN -> -1
|
||||
ctmx861 comparetotmag Inf sNaN -> -1
|
||||
ctmx862 comparetotmag NaN sNaN -> 1
|
||||
ctmx863 comparetotmag sNaN sNaN -> 0
|
||||
|
||||
ctmx871 comparetotmag -sNaN -sNaN -> 0
|
||||
ctmx872 comparetotmag -sNaN -NaN -> -1
|
||||
ctmx873 comparetotmag -sNaN -Inf -> 1
|
||||
ctmx874 comparetotmag -sNaN -1000 -> 1
|
||||
ctmx875 comparetotmag -sNaN -1 -> 1
|
||||
ctmx876 comparetotmag -sNaN -0 -> 1
|
||||
ctmx877 comparetotmag -sNaN 0 -> 1
|
||||
ctmx878 comparetotmag -sNaN 1 -> 1
|
||||
ctmx879 comparetotmag -sNaN 1000 -> 1
|
||||
ctmx880 comparetotmag -sNaN NaN -> -1
|
||||
ctmx881 comparetotmag -sNaN sNaN -> 0
|
||||
|
||||
ctmx882 comparetotmag -sNaN -sNaN -> 0
|
||||
ctmx883 comparetotmag -NaN -sNaN -> 1
|
||||
ctmx884 comparetotmag -Inf -sNaN -> -1
|
||||
ctmx885 comparetotmag -1000 -sNaN -> -1
|
||||
ctmx886 comparetotmag -1 -sNaN -> -1
|
||||
ctmx887 comparetotmag -0 -sNaN -> -1
|
||||
ctmx888 comparetotmag 0 -sNaN -> -1
|
||||
ctmx889 comparetotmag 1 -sNaN -> -1
|
||||
ctmx890 comparetotmag 1000 -sNaN -> -1
|
||||
ctmx891 comparetotmag Inf -sNaN -> -1
|
||||
ctmx892 comparetotmag NaN -sNaN -> 1
|
||||
ctmx893 comparetotmag sNaN -sNaN -> 0
|
||||
|
||||
-- NaNs with payload
|
||||
ctmx960 comparetotmag NaN9 -Inf -> 1
|
||||
ctmx961 comparetotmag NaN8 999 -> 1
|
||||
ctmx962 comparetotmag NaN77 Inf -> 1
|
||||
ctmx963 comparetotmag -NaN67 NaN5 -> 1
|
||||
ctmx964 comparetotmag -Inf -NaN4 -> -1
|
||||
ctmx965 comparetotmag -999 -NaN33 -> -1
|
||||
ctmx966 comparetotmag Inf NaN2 -> -1
|
||||
|
||||
ctmx970 comparetotmag -NaN41 -NaN42 -> -1
|
||||
ctmx971 comparetotmag +NaN41 -NaN42 -> -1
|
||||
ctmx972 comparetotmag -NaN41 +NaN42 -> -1
|
||||
ctmx973 comparetotmag +NaN41 +NaN42 -> -1
|
||||
ctmx974 comparetotmag -NaN42 -NaN01 -> 1
|
||||
ctmx975 comparetotmag +NaN42 -NaN01 -> 1
|
||||
ctmx976 comparetotmag -NaN42 +NaN01 -> 1
|
||||
ctmx977 comparetotmag +NaN42 +NaN01 -> 1
|
||||
|
||||
ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
|
||||
ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
|
||||
ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
|
||||
ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
|
||||
ctmx984 comparetotmag -sNaN772 -sNaN771 -> 1
|
||||
ctmx985 comparetotmag +sNaN772 -sNaN771 -> 1
|
||||
ctmx986 comparetotmag -sNaN772 +sNaN771 -> 1
|
||||
ctmx987 comparetotmag +sNaN772 +sNaN771 -> 1
|
||||
|
||||
ctmx991 comparetotmag -sNaN99 -Inf -> 1
|
||||
ctmx992 comparetotmag sNaN98 -11 -> 1
|
||||
ctmx993 comparetotmag sNaN97 NaN -> -1
|
||||
ctmx994 comparetotmag sNaN16 sNaN94 -> -1
|
||||
ctmx995 comparetotmag NaN85 sNaN83 -> 1
|
||||
ctmx996 comparetotmag -Inf sNaN92 -> -1
|
||||
ctmx997 comparetotmag 088 sNaN81 -> -1
|
||||
ctmx998 comparetotmag Inf sNaN90 -> -1
|
||||
ctmx999 comparetotmag NaN -sNaN89 -> 1
|
||||
|
||||
-- overflow and underflow tests .. subnormal results now allowed
|
||||
maxExponent: 999999999
|
||||
minexponent: -999999999
|
||||
ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999 -> -1
|
||||
ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0 -> 1
|
||||
ctmx1082 comparetotmag +0.100 9E-999999999 -> 1
|
||||
ctmx1083 comparetotmag 9E-999999999 +0.100 -> -1
|
||||
ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999 -> -1
|
||||
ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0 -> 1
|
||||
ctmx1087 comparetotmag -0.100 9E-999999999 -> 1
|
||||
ctmx1088 comparetotmag 9E-999999999 -0.100 -> -1
|
||||
|
||||
ctmx1089 comparetotmag 1e-599999999 1e-400000001 -> -1
|
||||
ctmx1090 comparetotmag 1e-599999999 1e-400000000 -> -1
|
||||
ctmx1091 comparetotmag 1e-600000000 1e-400000000 -> -1
|
||||
ctmx1092 comparetotmag 9e-999999998 0.01 -> -1
|
||||
ctmx1093 comparetotmag 9e-999999998 0.1 -> -1
|
||||
ctmx1094 comparetotmag 0.01 9e-999999998 -> 1
|
||||
ctmx1095 comparetotmag 1e599999999 1e400000001 -> 1
|
||||
ctmx1096 comparetotmag 1e599999999 1e400000000 -> 1
|
||||
ctmx1097 comparetotmag 1e600000000 1e400000000 -> 1
|
||||
ctmx1098 comparetotmag 9e999999998 100 -> 1
|
||||
ctmx1099 comparetotmag 9e999999998 10 -> 1
|
||||
ctmx1100 comparetotmag 100 9e999999998 -> -1
|
||||
-- signs
|
||||
ctmx1101 comparetotmag 1e+777777777 1e+411111111 -> 1
|
||||
ctmx1102 comparetotmag 1e+777777777 -1e+411111111 -> 1
|
||||
ctmx1103 comparetotmag -1e+777777777 1e+411111111 -> 1
|
||||
ctmx1104 comparetotmag -1e+777777777 -1e+411111111 -> 1
|
||||
ctmx1105 comparetotmag 1e-777777777 1e-411111111 -> -1
|
||||
ctmx1106 comparetotmag 1e-777777777 -1e-411111111 -> -1
|
||||
ctmx1107 comparetotmag -1e-777777777 1e-411111111 -> -1
|
||||
ctmx1108 comparetotmag -1e-777777777 -1e-411111111 -> -1
|
||||
|
||||
-- spread zeros
|
||||
ctmx1110 comparetotmag 0E-383 0 -> -1
|
||||
ctmx1111 comparetotmag 0E-383 -0 -> -1
|
||||
ctmx1112 comparetotmag -0E-383 0 -> -1
|
||||
ctmx1113 comparetotmag -0E-383 -0 -> -1
|
||||
ctmx1114 comparetotmag 0E-383 0E+384 -> -1
|
||||
ctmx1115 comparetotmag 0E-383 -0E+384 -> -1
|
||||
ctmx1116 comparetotmag -0E-383 0E+384 -> -1
|
||||
ctmx1117 comparetotmag -0E-383 -0E+384 -> -1
|
||||
ctmx1118 comparetotmag 0 0E+384 -> -1
|
||||
ctmx1119 comparetotmag 0 -0E+384 -> -1
|
||||
ctmx1120 comparetotmag -0 0E+384 -> -1
|
||||
ctmx1121 comparetotmag -0 -0E+384 -> -1
|
||||
|
||||
ctmx1130 comparetotmag 0E+384 0 -> 1
|
||||
ctmx1131 comparetotmag 0E+384 -0 -> 1
|
||||
ctmx1132 comparetotmag -0E+384 0 -> 1
|
||||
ctmx1133 comparetotmag -0E+384 -0 -> 1
|
||||
ctmx1134 comparetotmag 0E+384 0E-383 -> 1
|
||||
ctmx1135 comparetotmag 0E+384 -0E-383 -> 1
|
||||
ctmx1136 comparetotmag -0E+384 0E-383 -> 1
|
||||
ctmx1137 comparetotmag -0E+384 -0E-383 -> 1
|
||||
ctmx1138 comparetotmag 0 0E-383 -> 1
|
||||
ctmx1139 comparetotmag 0 -0E-383 -> 1
|
||||
ctmx1140 comparetotmag -0 0E-383 -> 1
|
||||
ctmx1141 comparetotmag -0 -0E-383 -> 1
|
||||
|
||||
-- Null tests
|
||||
ctmx9990 comparetotmag 10 # -> NaN Invalid_operation
|
||||
ctmx9991 comparetotmag # 10 -> NaN Invalid_operation
|
@ -0,0 +1,86 @@
|
||||
------------------------------------------------------------------------
|
||||
-- copy.decTest -- quiet copy --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
extended: 1
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
|
||||
-- Sanity check
|
||||
cpyx001 copy +7.50 -> 7.50
|
||||
|
||||
-- Infinities
|
||||
cpyx011 copy Infinity -> Infinity
|
||||
cpyx012 copy -Infinity -> -Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
cpyx021 copy NaN -> NaN
|
||||
cpyx022 copy -NaN -> -NaN
|
||||
cpyx023 copy sNaN -> sNaN
|
||||
cpyx024 copy -sNaN -> -sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
cpyx031 copy NaN10 -> NaN10
|
||||
cpyx032 copy -NaN10 -> -NaN10
|
||||
cpyx033 copy sNaN10 -> sNaN10
|
||||
cpyx034 copy -sNaN10 -> -sNaN10
|
||||
cpyx035 copy NaN7 -> NaN7
|
||||
cpyx036 copy -NaN7 -> -NaN7
|
||||
cpyx037 copy sNaN101 -> sNaN101
|
||||
cpyx038 copy -sNaN101 -> -sNaN101
|
||||
|
||||
-- finites
|
||||
cpyx101 copy 7 -> 7
|
||||
cpyx102 copy -7 -> -7
|
||||
cpyx103 copy 75 -> 75
|
||||
cpyx104 copy -75 -> -75
|
||||
cpyx105 copy 7.50 -> 7.50
|
||||
cpyx106 copy -7.50 -> -7.50
|
||||
cpyx107 copy 7.500 -> 7.500
|
||||
cpyx108 copy -7.500 -> -7.500
|
||||
|
||||
-- zeros
|
||||
cpyx111 copy 0 -> 0
|
||||
cpyx112 copy -0 -> -0
|
||||
cpyx113 copy 0E+4 -> 0E+4
|
||||
cpyx114 copy -0E+4 -> -0E+4
|
||||
cpyx115 copy 0.0000 -> 0.0000
|
||||
cpyx116 copy -0.0000 -> -0.0000
|
||||
cpyx117 copy 0E-141 -> 0E-141
|
||||
cpyx118 copy -0E-141 -> -0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
cpyx121 copy 268268268 -> 268268268
|
||||
cpyx122 copy -268268268 -> -268268268
|
||||
cpyx123 copy 134134134 -> 134134134
|
||||
cpyx124 copy -134134134 -> -134134134
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
cpyx131 copy 9.99999999E+999 -> 9.99999999E+999
|
||||
cpyx132 copy 1E-999 -> 1E-999
|
||||
cpyx133 copy 1.00000000E-999 -> 1.00000000E-999
|
||||
cpyx134 copy 1E-1007 -> 1E-1007
|
||||
|
||||
cpyx135 copy -1E-1007 -> -1E-1007
|
||||
cpyx136 copy -1.00000000E-999 -> -1.00000000E-999
|
||||
cpyx137 copy -1E-999 -> -1E-999
|
||||
cpyx138 copy -9.99999999E+999 -> -9.99999999E+999
|
@ -0,0 +1,86 @@
|
||||
------------------------------------------------------------------------
|
||||
-- copyAbs.decTest -- quiet copy and set sign to zero --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
extended: 1
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
|
||||
-- Sanity check
|
||||
cpax001 copyabs +7.50 -> 7.50
|
||||
|
||||
-- Infinities
|
||||
cpax011 copyabs Infinity -> Infinity
|
||||
cpax012 copyabs -Infinity -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
cpax021 copyabs NaN -> NaN
|
||||
cpax022 copyabs -NaN -> NaN
|
||||
cpax023 copyabs sNaN -> sNaN
|
||||
cpax024 copyabs -sNaN -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
cpax031 copyabs NaN10 -> NaN10
|
||||
cpax032 copyabs -NaN15 -> NaN15
|
||||
cpax033 copyabs sNaN15 -> sNaN15
|
||||
cpax034 copyabs -sNaN10 -> sNaN10
|
||||
cpax035 copyabs NaN7 -> NaN7
|
||||
cpax036 copyabs -NaN7 -> NaN7
|
||||
cpax037 copyabs sNaN101 -> sNaN101
|
||||
cpax038 copyabs -sNaN101 -> sNaN101
|
||||
|
||||
-- finites
|
||||
cpax101 copyabs 7 -> 7
|
||||
cpax102 copyabs -7 -> 7
|
||||
cpax103 copyabs 75 -> 75
|
||||
cpax104 copyabs -75 -> 75
|
||||
cpax105 copyabs 7.10 -> 7.10
|
||||
cpax106 copyabs -7.10 -> 7.10
|
||||
cpax107 copyabs 7.500 -> 7.500
|
||||
cpax108 copyabs -7.500 -> 7.500
|
||||
|
||||
-- zeros
|
||||
cpax111 copyabs 0 -> 0
|
||||
cpax112 copyabs -0 -> 0
|
||||
cpax113 copyabs 0E+6 -> 0E+6
|
||||
cpax114 copyabs -0E+6 -> 0E+6
|
||||
cpax115 copyabs 0.0000 -> 0.0000
|
||||
cpax116 copyabs -0.0000 -> 0.0000
|
||||
cpax117 copyabs 0E-141 -> 0E-141
|
||||
cpax118 copyabs -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
cpax121 copyabs 268268268 -> 268268268
|
||||
cpax122 copyabs -268268268 -> 268268268
|
||||
cpax123 copyabs 134134134 -> 134134134
|
||||
cpax124 copyabs -134134134 -> 134134134
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
cpax131 copyabs 9.99999999E+999 -> 9.99999999E+999
|
||||
cpax132 copyabs 1E-999 -> 1E-999
|
||||
cpax133 copyabs 1.00000000E-999 -> 1.00000000E-999
|
||||
cpax134 copyabs 1E-1007 -> 1E-1007
|
||||
|
||||
cpax135 copyabs -1E-1007 -> 1E-1007
|
||||
cpax136 copyabs -1.00000000E-999 -> 1.00000000E-999
|
||||
cpax137 copyabs -1E-999 -> 1E-999
|
||||
cpax199 copyabs -9.99999999E+999 -> 9.99999999E+999
|
@ -0,0 +1,86 @@
|
||||
------------------------------------------------------------------------
|
||||
-- copyNegate.decTest -- quiet copy and negate --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
extended: 1
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
|
||||
-- Sanity check
|
||||
cpnx001 copynegate +7.50 -> -7.50
|
||||
|
||||
-- Infinities
|
||||
cpnx011 copynegate Infinity -> -Infinity
|
||||
cpnx012 copynegate -Infinity -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
cpnx021 copynegate NaN -> -NaN
|
||||
cpnx022 copynegate -NaN -> NaN
|
||||
cpnx023 copynegate sNaN -> -sNaN
|
||||
cpnx024 copynegate -sNaN -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
cpnx031 copynegate NaN13 -> -NaN13
|
||||
cpnx032 copynegate -NaN13 -> NaN13
|
||||
cpnx033 copynegate sNaN13 -> -sNaN13
|
||||
cpnx034 copynegate -sNaN13 -> sNaN13
|
||||
cpnx035 copynegate NaN70 -> -NaN70
|
||||
cpnx036 copynegate -NaN70 -> NaN70
|
||||
cpnx037 copynegate sNaN101 -> -sNaN101
|
||||
cpnx038 copynegate -sNaN101 -> sNaN101
|
||||
|
||||
-- finites
|
||||
cpnx101 copynegate 7 -> -7
|
||||
cpnx102 copynegate -7 -> 7
|
||||
cpnx103 copynegate 75 -> -75
|
||||
cpnx104 copynegate -75 -> 75
|
||||
cpnx105 copynegate 7.50 -> -7.50
|
||||
cpnx106 copynegate -7.50 -> 7.50
|
||||
cpnx107 copynegate 7.500 -> -7.500
|
||||
cpnx108 copynegate -7.500 -> 7.500
|
||||
|
||||
-- zeros
|
||||
cpnx111 copynegate 0 -> -0
|
||||
cpnx112 copynegate -0 -> 0
|
||||
cpnx113 copynegate 0E+4 -> -0E+4
|
||||
cpnx114 copynegate -0E+4 -> 0E+4
|
||||
cpnx115 copynegate 0.0000 -> -0.0000
|
||||
cpnx116 copynegate -0.0000 -> 0.0000
|
||||
cpnx117 copynegate 0E-141 -> -0E-141
|
||||
cpnx118 copynegate -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
cpnx121 copynegate 268268268 -> -268268268
|
||||
cpnx122 copynegate -268268268 -> 268268268
|
||||
cpnx123 copynegate 134134134 -> -134134134
|
||||
cpnx124 copynegate -134134134 -> 134134134
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
cpnx131 copynegate 9.99999999E+999 -> -9.99999999E+999
|
||||
cpnx132 copynegate 1E-999 -> -1E-999
|
||||
cpnx133 copynegate 1.00000000E-999 -> -1.00000000E-999
|
||||
cpnx134 copynegate 1E-1007 -> -1E-1007
|
||||
|
||||
cpnx135 copynegate -1E-1007 -> 1E-1007
|
||||
cpnx136 copynegate -1.00000000E-999 -> 1.00000000E-999
|
||||
cpnx137 copynegate -1E-999 -> 1E-999
|
||||
cpnx138 copynegate -9.99999999E+999 -> 9.99999999E+999
|
@ -0,0 +1,177 @@
|
||||
------------------------------------------------------------------------
|
||||
-- copysign.decTest -- quiet copy with sign from rhs --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
extended: 1
|
||||
precision: 9
|
||||
rounding: half_up
|
||||
maxExponent: 999
|
||||
minExponent: -999
|
||||
|
||||
-- Sanity check, and examples from decArith
|
||||
cpsx001 copysign +7.50 11 -> 7.50
|
||||
cpsx002 copysign '1.50' '7.33' -> 1.50
|
||||
cpsx003 copysign '-1.50' '7.33' -> 1.50
|
||||
cpsx004 copysign '1.50' '-7.33' -> -1.50
|
||||
cpsx005 copysign '-1.50' '-7.33' -> -1.50
|
||||
|
||||
-- Infinities
|
||||
cpsx011 copysign Infinity 11 -> Infinity
|
||||
cpsx012 copysign -Infinity 11 -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
cpsx021 copysign NaN 11 -> NaN
|
||||
cpsx022 copysign -NaN 11 -> NaN
|
||||
cpsx023 copysign sNaN 11 -> sNaN
|
||||
cpsx024 copysign -sNaN 11 -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
cpsx031 copysign NaN10 11 -> NaN10
|
||||
cpsx032 copysign -NaN10 11 -> NaN10
|
||||
cpsx033 copysign sNaN10 11 -> sNaN10
|
||||
cpsx034 copysign -sNaN10 11 -> sNaN10
|
||||
cpsx035 copysign NaN7 11 -> NaN7
|
||||
cpsx036 copysign -NaN7 11 -> NaN7
|
||||
cpsx037 copysign sNaN101 11 -> sNaN101
|
||||
cpsx038 copysign -sNaN101 11 -> sNaN101
|
||||
|
||||
-- finites
|
||||
cpsx101 copysign 7 11 -> 7
|
||||
cpsx102 copysign -7 11 -> 7
|
||||
cpsx103 copysign 75 11 -> 75
|
||||
cpsx104 copysign -75 11 -> 75
|
||||
cpsx105 copysign 7.50 11 -> 7.50
|
||||
cpsx106 copysign -7.50 11 -> 7.50
|
||||
cpsx107 copysign 7.500 11 -> 7.500
|
||||
cpsx108 copysign -7.500 11 -> 7.500
|
||||
|
||||
-- zeros
|
||||
cpsx111 copysign 0 11 -> 0
|
||||
cpsx112 copysign -0 11 -> 0
|
||||
cpsx113 copysign 0E+4 11 -> 0E+4
|
||||
cpsx114 copysign -0E+4 11 -> 0E+4
|
||||
cpsx115 copysign 0.0000 11 -> 0.0000
|
||||
cpsx116 copysign -0.0000 11 -> 0.0000
|
||||
cpsx117 copysign 0E-141 11 -> 0E-141
|
||||
cpsx118 copysign -0E-141 11 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
cpsx121 copysign 268268268 11 -> 268268268
|
||||
cpsx122 copysign -268268268 11 -> 268268268
|
||||
cpsx123 copysign 134134134 11 -> 134134134
|
||||
cpsx124 copysign -134134134 11 -> 134134134
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999
|
||||
cpsx132 copysign 1E-999 11 -> 1E-999
|
||||
cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999
|
||||
cpsx134 copysign 1E-1007 11 -> 1E-1007
|
||||
|
||||
cpsx135 copysign -1E-1007 11 -> 1E-1007
|
||||
cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999
|
||||
cpsx137 copysign -1E-999 11 -> 1E-999
|
||||
cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999
|
||||
|
||||
-- repeat with negative RHS
|
||||
|
||||
-- Infinities
|
||||
cpsx211 copysign Infinity -34 -> -Infinity
|
||||
cpsx212 copysign -Infinity -34 -> -Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
cpsx221 copysign NaN -34 -> -NaN
|
||||
cpsx222 copysign -NaN -34 -> -NaN
|
||||
cpsx223 copysign sNaN -34 -> -sNaN
|
||||
cpsx224 copysign -sNaN -34 -> -sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
cpsx231 copysign NaN10 -34 -> -NaN10
|
||||
cpsx232 copysign -NaN10 -34 -> -NaN10
|
||||
cpsx233 copysign sNaN10 -34 -> -sNaN10
|
||||
cpsx234 copysign -sNaN10 -34 -> -sNaN10
|
||||
cpsx235 copysign NaN7 -34 -> -NaN7
|
||||
cpsx236 copysign -NaN7 -34 -> -NaN7
|
||||
cpsx237 copysign sNaN101 -34 -> -sNaN101
|
||||
cpsx238 copysign -sNaN101 -34 -> -sNaN101
|
||||
|
||||
-- finites
|
||||
cpsx301 copysign 7 -34 -> -7
|
||||
cpsx302 copysign -7 -34 -> -7
|
||||
cpsx303 copysign 75 -34 -> -75
|
||||
cpsx304 copysign -75 -34 -> -75
|
||||
cpsx305 copysign 7.50 -34 -> -7.50
|
||||
cpsx306 copysign -7.50 -34 -> -7.50
|
||||
cpsx307 copysign 7.500 -34 -> -7.500
|
||||
cpsx308 copysign -7.500 -34 -> -7.500
|
||||
|
||||
-- zeros
|
||||
cpsx311 copysign 0 -34 -> -0
|
||||
cpsx312 copysign -0 -34 -> -0
|
||||
cpsx313 copysign 0E+4 -34 -> -0E+4
|
||||
cpsx314 copysign -0E+4 -34 -> -0E+4
|
||||
cpsx315 copysign 0.0000 -34 -> -0.0000
|
||||
cpsx316 copysign -0.0000 -34 -> -0.0000
|
||||
cpsx317 copysign 0E-141 -34 -> -0E-141
|
||||
cpsx318 copysign -0E-141 -34 -> -0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
cpsx321 copysign 268268268 -18 -> -268268268
|
||||
cpsx322 copysign -268268268 -18 -> -268268268
|
||||
cpsx323 copysign 134134134 -18 -> -134134134
|
||||
cpsx324 copysign -134134134 -18 -> -134134134
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999
|
||||
cpsx332 copysign 1E-999 -18 -> -1E-999
|
||||
cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999
|
||||
cpsx334 copysign 1E-1007 -18 -> -1E-1007
|
||||
|
||||
cpsx335 copysign -1E-1007 -18 -> -1E-1007
|
||||
cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999
|
||||
cpsx337 copysign -1E-999 -18 -> -1E-999
|
||||
cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999
|
||||
|
||||
-- Other kinds of RHS
|
||||
cpsx401 copysign 701 -34 -> -701
|
||||
cpsx402 copysign -720 -34 -> -720
|
||||
cpsx403 copysign 701 -0 -> -701
|
||||
cpsx404 copysign -720 -0 -> -720
|
||||
cpsx405 copysign 701 +0 -> 701
|
||||
cpsx406 copysign -720 +0 -> 720
|
||||
cpsx407 copysign 701 +34 -> 701
|
||||
cpsx408 copysign -720 +34 -> 720
|
||||
|
||||
cpsx413 copysign 701 -Inf -> -701
|
||||
cpsx414 copysign -720 -Inf -> -720
|
||||
cpsx415 copysign 701 +Inf -> 701
|
||||
cpsx416 copysign -720 +Inf -> 720
|
||||
|
||||
cpsx420 copysign 701 -NaN -> -701
|
||||
cpsx421 copysign -720 -NaN -> -720
|
||||
cpsx422 copysign 701 +NaN -> 701
|
||||
cpsx423 copysign -720 +NaN -> 720
|
||||
cpsx425 copysign -720 +NaN8 -> 720
|
||||
|
||||
cpsx426 copysign 701 -sNaN -> -701
|
||||
cpsx427 copysign -720 -sNaN -> -720
|
||||
cpsx428 copysign 701 +sNaN -> 701
|
||||
cpsx429 copysign -720 +sNaN -> 720
|
||||
cpsx430 copysign -720 +sNaN3 -> 720
|
||||
|
@ -0,0 +1,126 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddAbs.decTest -- decDouble absolute value, heeding sNaN --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
ddabs001 abs '1' -> '1'
|
||||
ddabs002 abs '-1' -> '1'
|
||||
ddabs003 abs '1.00' -> '1.00'
|
||||
ddabs004 abs '-1.00' -> '1.00'
|
||||
ddabs005 abs '0' -> '0'
|
||||
ddabs006 abs '0.00' -> '0.00'
|
||||
ddabs007 abs '00.0' -> '0.0'
|
||||
ddabs008 abs '00.00' -> '0.00'
|
||||
ddabs009 abs '00' -> '0'
|
||||
|
||||
ddabs010 abs '-2' -> '2'
|
||||
ddabs011 abs '2' -> '2'
|
||||
ddabs012 abs '-2.00' -> '2.00'
|
||||
ddabs013 abs '2.00' -> '2.00'
|
||||
ddabs014 abs '-0' -> '0'
|
||||
ddabs015 abs '-0.00' -> '0.00'
|
||||
ddabs016 abs '-00.0' -> '0.0'
|
||||
ddabs017 abs '-00.00' -> '0.00'
|
||||
ddabs018 abs '-00' -> '0'
|
||||
|
||||
ddabs020 abs '-2000000' -> '2000000'
|
||||
ddabs021 abs '2000000' -> '2000000'
|
||||
|
||||
ddabs030 abs '+0.1' -> '0.1'
|
||||
ddabs031 abs '-0.1' -> '0.1'
|
||||
ddabs032 abs '+0.01' -> '0.01'
|
||||
ddabs033 abs '-0.01' -> '0.01'
|
||||
ddabs034 abs '+0.001' -> '0.001'
|
||||
ddabs035 abs '-0.001' -> '0.001'
|
||||
ddabs036 abs '+0.000001' -> '0.000001'
|
||||
ddabs037 abs '-0.000001' -> '0.000001'
|
||||
ddabs038 abs '+0.000000000001' -> '1E-12'
|
||||
ddabs039 abs '-0.000000000001' -> '1E-12'
|
||||
|
||||
-- examples from decArith
|
||||
ddabs040 abs '2.1' -> '2.1'
|
||||
ddabs041 abs '-100' -> '100'
|
||||
ddabs042 abs '101.5' -> '101.5'
|
||||
ddabs043 abs '-101.5' -> '101.5'
|
||||
|
||||
-- more fixed, potential LHS swaps/overlays if done by subtract 0
|
||||
ddabs060 abs '-56267E-10' -> '0.0000056267'
|
||||
ddabs061 abs '-56267E-5' -> '0.56267'
|
||||
ddabs062 abs '-56267E-2' -> '562.67'
|
||||
ddabs063 abs '-56267E-1' -> '5626.7'
|
||||
ddabs065 abs '-56267E-0' -> '56267'
|
||||
|
||||
-- subnormals and underflow
|
||||
|
||||
-- long operand tests
|
||||
ddabs321 abs 1234567890123456 -> 1234567890123456
|
||||
ddabs322 abs 12345678000 -> 12345678000
|
||||
ddabs323 abs 1234567800 -> 1234567800
|
||||
ddabs324 abs 1234567890 -> 1234567890
|
||||
ddabs325 abs 1234567891 -> 1234567891
|
||||
ddabs326 abs 12345678901 -> 12345678901
|
||||
ddabs327 abs 1234567896 -> 1234567896
|
||||
|
||||
-- zeros
|
||||
ddabs111 abs 0 -> 0
|
||||
ddabs112 abs -0 -> 0
|
||||
ddabs113 abs 0E+6 -> 0E+6
|
||||
ddabs114 abs -0E+6 -> 0E+6
|
||||
ddabs115 abs 0.0000 -> 0.0000
|
||||
ddabs116 abs -0.0000 -> 0.0000
|
||||
ddabs117 abs 0E-141 -> 0E-141
|
||||
ddabs118 abs -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddabs121 abs 2682682682682682 -> 2682682682682682
|
||||
ddabs122 abs -2682682682682682 -> 2682682682682682
|
||||
ddabs123 abs 1341341341341341 -> 1341341341341341
|
||||
ddabs124 abs -1341341341341341 -> 1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddabs131 abs 9.999999999999999E+384 -> 9.999999999999999E+384
|
||||
ddabs132 abs 1E-383 -> 1E-383
|
||||
ddabs133 abs 1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddabs134 abs 1E-398 -> 1E-398 Subnormal
|
||||
|
||||
ddabs135 abs -1E-398 -> 1E-398 Subnormal
|
||||
ddabs136 abs -1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddabs137 abs -1E-383 -> 1E-383
|
||||
ddabs138 abs -9.999999999999999E+384 -> 9.999999999999999E+384
|
||||
|
||||
-- specials
|
||||
ddabs520 abs 'Inf' -> 'Infinity'
|
||||
ddabs521 abs '-Inf' -> 'Infinity'
|
||||
ddabs522 abs NaN -> NaN
|
||||
ddabs523 abs sNaN -> NaN Invalid_operation
|
||||
ddabs524 abs NaN22 -> NaN22
|
||||
ddabs525 abs sNaN33 -> NaN33 Invalid_operation
|
||||
ddabs526 abs -NaN22 -> -NaN22
|
||||
ddabs527 abs -sNaN33 -> -NaN33 Invalid_operation
|
||||
|
||||
-- Null tests
|
||||
ddabs900 abs # -> NaN Invalid_operation
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,347 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddAnd.decTest -- digitwise logical AND for decDoubles --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check (truth table)
|
||||
ddand001 and 0 0 -> 0
|
||||
ddand002 and 0 1 -> 0
|
||||
ddand003 and 1 0 -> 0
|
||||
ddand004 and 1 1 -> 1
|
||||
ddand005 and 1100 1010 -> 1000
|
||||
-- and at msd and msd-1
|
||||
-- 1234567890123456 1234567890123456 1234567890123456
|
||||
ddand006 and 0000000000000000 0000000000000000 -> 0
|
||||
ddand007 and 0000000000000000 1000000000000000 -> 0
|
||||
ddand008 and 1000000000000000 0000000000000000 -> 0
|
||||
ddand009 and 1000000000000000 1000000000000000 -> 1000000000000000
|
||||
ddand010 and 0000000000000000 0000000000000000 -> 0
|
||||
ddand011 and 0000000000000000 0100000000000000 -> 0
|
||||
ddand012 and 0100000000000000 0000000000000000 -> 0
|
||||
ddand013 and 0100000000000000 0100000000000000 -> 100000000000000
|
||||
|
||||
-- Various lengths
|
||||
-- 1234567890123456 1234567890123456 1234567890123456
|
||||
ddand021 and 1111111111111111 1111111111111111 -> 1111111111111111
|
||||
ddand024 and 1111111111111111 111111111111111 -> 111111111111111
|
||||
ddand025 and 1111111111111111 11111111111111 -> 11111111111111
|
||||
ddand026 and 1111111111111111 1111111111111 -> 1111111111111
|
||||
ddand027 and 1111111111111111 111111111111 -> 111111111111
|
||||
ddand028 and 1111111111111111 11111111111 -> 11111111111
|
||||
ddand029 and 1111111111111111 1111111111 -> 1111111111
|
||||
ddand030 and 1111111111111111 111111111 -> 111111111
|
||||
ddand031 and 1111111111111111 11111111 -> 11111111
|
||||
ddand032 and 1111111111111111 1111111 -> 1111111
|
||||
ddand033 and 1111111111111111 111111 -> 111111
|
||||
ddand034 and 1111111111111111 11111 -> 11111
|
||||
ddand035 and 1111111111111111 1111 -> 1111
|
||||
ddand036 and 1111111111111111 111 -> 111
|
||||
ddand037 and 1111111111111111 11 -> 11
|
||||
ddand038 and 1111111111111111 1 -> 1
|
||||
ddand039 and 1111111111111111 0 -> 0
|
||||
|
||||
ddand040 and 1111111111111111 1111111111111111 -> 1111111111111111
|
||||
ddand041 and 111111111111111 1111111111111111 -> 111111111111111
|
||||
ddand042 and 111111111111111 1111111111111111 -> 111111111111111
|
||||
ddand043 and 11111111111111 1111111111111111 -> 11111111111111
|
||||
ddand044 and 1111111111111 1111111111111111 -> 1111111111111
|
||||
ddand045 and 111111111111 1111111111111111 -> 111111111111
|
||||
ddand046 and 11111111111 1111111111111111 -> 11111111111
|
||||
ddand047 and 1111111111 1111111111111111 -> 1111111111
|
||||
ddand048 and 111111111 1111111111111111 -> 111111111
|
||||
ddand049 and 11111111 1111111111111111 -> 11111111
|
||||
ddand050 and 1111111 1111111111111111 -> 1111111
|
||||
ddand051 and 111111 1111111111111111 -> 111111
|
||||
ddand052 and 11111 1111111111111111 -> 11111
|
||||
ddand053 and 1111 1111111111111111 -> 1111
|
||||
ddand054 and 111 1111111111111111 -> 111
|
||||
ddand055 and 11 1111111111111111 -> 11
|
||||
ddand056 and 1 1111111111111111 -> 1
|
||||
ddand057 and 0 1111111111111111 -> 0
|
||||
|
||||
ddand150 and 1111111111 1 -> 1
|
||||
ddand151 and 111111111 1 -> 1
|
||||
ddand152 and 11111111 1 -> 1
|
||||
ddand153 and 1111111 1 -> 1
|
||||
ddand154 and 111111 1 -> 1
|
||||
ddand155 and 11111 1 -> 1
|
||||
ddand156 and 1111 1 -> 1
|
||||
ddand157 and 111 1 -> 1
|
||||
ddand158 and 11 1 -> 1
|
||||
ddand159 and 1 1 -> 1
|
||||
|
||||
ddand160 and 1111111111 0 -> 0
|
||||
ddand161 and 111111111 0 -> 0
|
||||
ddand162 and 11111111 0 -> 0
|
||||
ddand163 and 1111111 0 -> 0
|
||||
ddand164 and 111111 0 -> 0
|
||||
ddand165 and 11111 0 -> 0
|
||||
ddand166 and 1111 0 -> 0
|
||||
ddand167 and 111 0 -> 0
|
||||
ddand168 and 11 0 -> 0
|
||||
ddand169 and 1 0 -> 0
|
||||
|
||||
ddand170 and 1 1111111111 -> 1
|
||||
ddand171 and 1 111111111 -> 1
|
||||
ddand172 and 1 11111111 -> 1
|
||||
ddand173 and 1 1111111 -> 1
|
||||
ddand174 and 1 111111 -> 1
|
||||
ddand175 and 1 11111 -> 1
|
||||
ddand176 and 1 1111 -> 1
|
||||
ddand177 and 1 111 -> 1
|
||||
ddand178 and 1 11 -> 1
|
||||
ddand179 and 1 1 -> 1
|
||||
|
||||
ddand180 and 0 1111111111 -> 0
|
||||
ddand181 and 0 111111111 -> 0
|
||||
ddand182 and 0 11111111 -> 0
|
||||
ddand183 and 0 1111111 -> 0
|
||||
ddand184 and 0 111111 -> 0
|
||||
ddand185 and 0 11111 -> 0
|
||||
ddand186 and 0 1111 -> 0
|
||||
ddand187 and 0 111 -> 0
|
||||
ddand188 and 0 11 -> 0
|
||||
ddand189 and 0 1 -> 0
|
||||
|
||||
ddand090 and 011111111 111111111 -> 11111111
|
||||
ddand091 and 101111111 111111111 -> 101111111
|
||||
ddand092 and 110111111 111111111 -> 110111111
|
||||
ddand093 and 111011111 111111111 -> 111011111
|
||||
ddand094 and 111101111 111111111 -> 111101111
|
||||
ddand095 and 111110111 111111111 -> 111110111
|
||||
ddand096 and 111111011 111111111 -> 111111011
|
||||
ddand097 and 111111101 111111111 -> 111111101
|
||||
ddand098 and 111111110 111111111 -> 111111110
|
||||
|
||||
ddand100 and 111111111 011111111 -> 11111111
|
||||
ddand101 and 111111111 101111111 -> 101111111
|
||||
ddand102 and 111111111 110111111 -> 110111111
|
||||
ddand103 and 111111111 111011111 -> 111011111
|
||||
ddand104 and 111111111 111101111 -> 111101111
|
||||
ddand105 and 111111111 111110111 -> 111110111
|
||||
ddand106 and 111111111 111111011 -> 111111011
|
||||
ddand107 and 111111111 111111101 -> 111111101
|
||||
ddand108 and 111111111 111111110 -> 111111110
|
||||
|
||||
-- non-0/1 should not be accepted, nor should signs
|
||||
ddand220 and 111111112 111111111 -> NaN Invalid_operation
|
||||
ddand221 and 333333333 333333333 -> NaN Invalid_operation
|
||||
ddand222 and 555555555 555555555 -> NaN Invalid_operation
|
||||
ddand223 and 777777777 777777777 -> NaN Invalid_operation
|
||||
ddand224 and 999999999 999999999 -> NaN Invalid_operation
|
||||
ddand225 and 222222222 999999999 -> NaN Invalid_operation
|
||||
ddand226 and 444444444 999999999 -> NaN Invalid_operation
|
||||
ddand227 and 666666666 999999999 -> NaN Invalid_operation
|
||||
ddand228 and 888888888 999999999 -> NaN Invalid_operation
|
||||
ddand229 and 999999999 222222222 -> NaN Invalid_operation
|
||||
ddand230 and 999999999 444444444 -> NaN Invalid_operation
|
||||
ddand231 and 999999999 666666666 -> NaN Invalid_operation
|
||||
ddand232 and 999999999 888888888 -> NaN Invalid_operation
|
||||
-- a few randoms
|
||||
ddand240 and 567468689 -934981942 -> NaN Invalid_operation
|
||||
ddand241 and 567367689 934981942 -> NaN Invalid_operation
|
||||
ddand242 and -631917772 -706014634 -> NaN Invalid_operation
|
||||
ddand243 and -756253257 138579234 -> NaN Invalid_operation
|
||||
ddand244 and 835590149 567435400 -> NaN Invalid_operation
|
||||
-- test MSD
|
||||
ddand250 and 2000000000000000 1000000000000000 -> NaN Invalid_operation
|
||||
ddand251 and 7000000000000000 1000000000000000 -> NaN Invalid_operation
|
||||
ddand252 and 8000000000000000 1000000000000000 -> NaN Invalid_operation
|
||||
ddand253 and 9000000000000000 1000000000000000 -> NaN Invalid_operation
|
||||
ddand254 and 2000000000000000 0000000000000000 -> NaN Invalid_operation
|
||||
ddand255 and 7000000000000000 0000000000000000 -> NaN Invalid_operation
|
||||
ddand256 and 8000000000000000 0000000000000000 -> NaN Invalid_operation
|
||||
ddand257 and 9000000000000000 0000000000000000 -> NaN Invalid_operation
|
||||
ddand258 and 1000000000000000 2000000000000000 -> NaN Invalid_operation
|
||||
ddand259 and 1000000000000000 7000000000000000 -> NaN Invalid_operation
|
||||
ddand260 and 1000000000000000 8000000000000000 -> NaN Invalid_operation
|
||||
ddand261 and 1000000000000000 9000000000000000 -> NaN Invalid_operation
|
||||
ddand262 and 0000000000000000 2000000000000000 -> NaN Invalid_operation
|
||||
ddand263 and 0000000000000000 7000000000000000 -> NaN Invalid_operation
|
||||
ddand264 and 0000000000000000 8000000000000000 -> NaN Invalid_operation
|
||||
ddand265 and 0000000000000000 9000000000000000 -> NaN Invalid_operation
|
||||
-- test MSD-1
|
||||
ddand270 and 0200001000000000 1000100000000010 -> NaN Invalid_operation
|
||||
ddand271 and 0700000100000000 1000010000000100 -> NaN Invalid_operation
|
||||
ddand272 and 0800000010000000 1000001000001000 -> NaN Invalid_operation
|
||||
ddand273 and 0900000001000000 1000000100010000 -> NaN Invalid_operation
|
||||
ddand274 and 1000000000100000 0200000010100000 -> NaN Invalid_operation
|
||||
ddand275 and 1000000000010000 0700000001000000 -> NaN Invalid_operation
|
||||
ddand276 and 1000000000001000 0800000010100000 -> NaN Invalid_operation
|
||||
ddand277 and 1000000000000100 0900000000010000 -> NaN Invalid_operation
|
||||
-- test LSD
|
||||
ddand280 and 0010000000000002 1000000100000001 -> NaN Invalid_operation
|
||||
ddand281 and 0001000000000007 1000001000000011 -> NaN Invalid_operation
|
||||
ddand282 and 0000100000000008 1000010000000001 -> NaN Invalid_operation
|
||||
ddand283 and 0000010000000009 1000100000000001 -> NaN Invalid_operation
|
||||
ddand284 and 1000001000000000 0001000000000002 -> NaN Invalid_operation
|
||||
ddand285 and 1000000100000000 0010000000000007 -> NaN Invalid_operation
|
||||
ddand286 and 1000000010000000 0100000000000008 -> NaN Invalid_operation
|
||||
ddand287 and 1000000001000000 1000000000000009 -> NaN Invalid_operation
|
||||
-- test Middie
|
||||
ddand288 and 0010000020000000 1000001000000000 -> NaN Invalid_operation
|
||||
ddand289 and 0001000070000001 1000000100000000 -> NaN Invalid_operation
|
||||
ddand290 and 0000100080000010 1000000010000000 -> NaN Invalid_operation
|
||||
ddand291 and 0000010090000100 1000000001000000 -> NaN Invalid_operation
|
||||
ddand292 and 1000001000001000 0000000020100000 -> NaN Invalid_operation
|
||||
ddand293 and 1000000100010000 0000000070010000 -> NaN Invalid_operation
|
||||
ddand294 and 1000000010100000 0000000080001000 -> NaN Invalid_operation
|
||||
ddand295 and 1000000001000000 0000000090000100 -> NaN Invalid_operation
|
||||
-- signs
|
||||
ddand296 and -1000000001000000 -0000010000000100 -> NaN Invalid_operation
|
||||
ddand297 and -1000000001000000 0000000010000100 -> NaN Invalid_operation
|
||||
ddand298 and 1000000001000000 -0000001000000100 -> NaN Invalid_operation
|
||||
ddand299 and 1000000001000000 0000000011000100 -> 1000000
|
||||
|
||||
-- Nmax, Nmin, Ntiny-like
|
||||
ddand331 and 2 9.99999999E+199 -> NaN Invalid_operation
|
||||
ddand332 and 3 1E-199 -> NaN Invalid_operation
|
||||
ddand333 and 4 1.00000000E-199 -> NaN Invalid_operation
|
||||
ddand334 and 5 1E-100 -> NaN Invalid_operation
|
||||
ddand335 and 6 -1E-100 -> NaN Invalid_operation
|
||||
ddand336 and 7 -1.00000000E-199 -> NaN Invalid_operation
|
||||
ddand337 and 8 -1E-199 -> NaN Invalid_operation
|
||||
ddand338 and 9 -9.99999999E+199 -> NaN Invalid_operation
|
||||
ddand341 and 9.99999999E+199 -18 -> NaN Invalid_operation
|
||||
ddand342 and 1E-199 01 -> NaN Invalid_operation
|
||||
ddand343 and 1.00000000E-199 -18 -> NaN Invalid_operation
|
||||
ddand344 and 1E-100 18 -> NaN Invalid_operation
|
||||
ddand345 and -1E-100 -10 -> NaN Invalid_operation
|
||||
ddand346 and -1.00000000E-199 18 -> NaN Invalid_operation
|
||||
ddand347 and -1E-199 10 -> NaN Invalid_operation
|
||||
ddand348 and -9.99999999E+199 -18 -> NaN Invalid_operation
|
||||
|
||||
-- A few other non-integers
|
||||
ddand361 and 1.0 1 -> NaN Invalid_operation
|
||||
ddand362 and 1E+1 1 -> NaN Invalid_operation
|
||||
ddand363 and 0.0 1 -> NaN Invalid_operation
|
||||
ddand364 and 0E+1 1 -> NaN Invalid_operation
|
||||
ddand365 and 9.9 1 -> NaN Invalid_operation
|
||||
ddand366 and 9E+1 1 -> NaN Invalid_operation
|
||||
ddand371 and 0 1.0 -> NaN Invalid_operation
|
||||
ddand372 and 0 1E+1 -> NaN Invalid_operation
|
||||
ddand373 and 0 0.0 -> NaN Invalid_operation
|
||||
ddand374 and 0 0E+1 -> NaN Invalid_operation
|
||||
ddand375 and 0 9.9 -> NaN Invalid_operation
|
||||
ddand376 and 0 9E+1 -> NaN Invalid_operation
|
||||
|
||||
-- All Specials are in error
|
||||
ddand780 and -Inf -Inf -> NaN Invalid_operation
|
||||
ddand781 and -Inf -1000 -> NaN Invalid_operation
|
||||
ddand782 and -Inf -1 -> NaN Invalid_operation
|
||||
ddand783 and -Inf -0 -> NaN Invalid_operation
|
||||
ddand784 and -Inf 0 -> NaN Invalid_operation
|
||||
ddand785 and -Inf 1 -> NaN Invalid_operation
|
||||
ddand786 and -Inf 1000 -> NaN Invalid_operation
|
||||
ddand787 and -1000 -Inf -> NaN Invalid_operation
|
||||
ddand788 and -Inf -Inf -> NaN Invalid_operation
|
||||
ddand789 and -1 -Inf -> NaN Invalid_operation
|
||||
ddand790 and -0 -Inf -> NaN Invalid_operation
|
||||
ddand791 and 0 -Inf -> NaN Invalid_operation
|
||||
ddand792 and 1 -Inf -> NaN Invalid_operation
|
||||
ddand793 and 1000 -Inf -> NaN Invalid_operation
|
||||
ddand794 and Inf -Inf -> NaN Invalid_operation
|
||||
|
||||
ddand800 and Inf -Inf -> NaN Invalid_operation
|
||||
ddand801 and Inf -1000 -> NaN Invalid_operation
|
||||
ddand802 and Inf -1 -> NaN Invalid_operation
|
||||
ddand803 and Inf -0 -> NaN Invalid_operation
|
||||
ddand804 and Inf 0 -> NaN Invalid_operation
|
||||
ddand805 and Inf 1 -> NaN Invalid_operation
|
||||
ddand806 and Inf 1000 -> NaN Invalid_operation
|
||||
ddand807 and Inf Inf -> NaN Invalid_operation
|
||||
ddand808 and -1000 Inf -> NaN Invalid_operation
|
||||
ddand809 and -Inf Inf -> NaN Invalid_operation
|
||||
ddand810 and -1 Inf -> NaN Invalid_operation
|
||||
ddand811 and -0 Inf -> NaN Invalid_operation
|
||||
ddand812 and 0 Inf -> NaN Invalid_operation
|
||||
ddand813 and 1 Inf -> NaN Invalid_operation
|
||||
ddand814 and 1000 Inf -> NaN Invalid_operation
|
||||
ddand815 and Inf Inf -> NaN Invalid_operation
|
||||
|
||||
ddand821 and NaN -Inf -> NaN Invalid_operation
|
||||
ddand822 and NaN -1000 -> NaN Invalid_operation
|
||||
ddand823 and NaN -1 -> NaN Invalid_operation
|
||||
ddand824 and NaN -0 -> NaN Invalid_operation
|
||||
ddand825 and NaN 0 -> NaN Invalid_operation
|
||||
ddand826 and NaN 1 -> NaN Invalid_operation
|
||||
ddand827 and NaN 1000 -> NaN Invalid_operation
|
||||
ddand828 and NaN Inf -> NaN Invalid_operation
|
||||
ddand829 and NaN NaN -> NaN Invalid_operation
|
||||
ddand830 and -Inf NaN -> NaN Invalid_operation
|
||||
ddand831 and -1000 NaN -> NaN Invalid_operation
|
||||
ddand832 and -1 NaN -> NaN Invalid_operation
|
||||
ddand833 and -0 NaN -> NaN Invalid_operation
|
||||
ddand834 and 0 NaN -> NaN Invalid_operation
|
||||
ddand835 and 1 NaN -> NaN Invalid_operation
|
||||
ddand836 and 1000 NaN -> NaN Invalid_operation
|
||||
ddand837 and Inf NaN -> NaN Invalid_operation
|
||||
|
||||
ddand841 and sNaN -Inf -> NaN Invalid_operation
|
||||
ddand842 and sNaN -1000 -> NaN Invalid_operation
|
||||
ddand843 and sNaN -1 -> NaN Invalid_operation
|
||||
ddand844 and sNaN -0 -> NaN Invalid_operation
|
||||
ddand845 and sNaN 0 -> NaN Invalid_operation
|
||||
ddand846 and sNaN 1 -> NaN Invalid_operation
|
||||
ddand847 and sNaN 1000 -> NaN Invalid_operation
|
||||
ddand848 and sNaN NaN -> NaN Invalid_operation
|
||||
ddand849 and sNaN sNaN -> NaN Invalid_operation
|
||||
ddand850 and NaN sNaN -> NaN Invalid_operation
|
||||
ddand851 and -Inf sNaN -> NaN Invalid_operation
|
||||
ddand852 and -1000 sNaN -> NaN Invalid_operation
|
||||
ddand853 and -1 sNaN -> NaN Invalid_operation
|
||||
ddand854 and -0 sNaN -> NaN Invalid_operation
|
||||
ddand855 and 0 sNaN -> NaN Invalid_operation
|
||||
ddand856 and 1 sNaN -> NaN Invalid_operation
|
||||
ddand857 and 1000 sNaN -> NaN Invalid_operation
|
||||
ddand858 and Inf sNaN -> NaN Invalid_operation
|
||||
ddand859 and NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddand861 and NaN1 -Inf -> NaN Invalid_operation
|
||||
ddand862 and +NaN2 -1000 -> NaN Invalid_operation
|
||||
ddand863 and NaN3 1000 -> NaN Invalid_operation
|
||||
ddand864 and NaN4 Inf -> NaN Invalid_operation
|
||||
ddand865 and NaN5 +NaN6 -> NaN Invalid_operation
|
||||
ddand866 and -Inf NaN7 -> NaN Invalid_operation
|
||||
ddand867 and -1000 NaN8 -> NaN Invalid_operation
|
||||
ddand868 and 1000 NaN9 -> NaN Invalid_operation
|
||||
ddand869 and Inf +NaN10 -> NaN Invalid_operation
|
||||
ddand871 and sNaN11 -Inf -> NaN Invalid_operation
|
||||
ddand872 and sNaN12 -1000 -> NaN Invalid_operation
|
||||
ddand873 and sNaN13 1000 -> NaN Invalid_operation
|
||||
ddand874 and sNaN14 NaN17 -> NaN Invalid_operation
|
||||
ddand875 and sNaN15 sNaN18 -> NaN Invalid_operation
|
||||
ddand876 and NaN16 sNaN19 -> NaN Invalid_operation
|
||||
ddand877 and -Inf +sNaN20 -> NaN Invalid_operation
|
||||
ddand878 and -1000 sNaN21 -> NaN Invalid_operation
|
||||
ddand879 and 1000 sNaN22 -> NaN Invalid_operation
|
||||
ddand880 and Inf sNaN23 -> NaN Invalid_operation
|
||||
ddand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
|
||||
ddand882 and -NaN26 NaN28 -> NaN Invalid_operation
|
||||
ddand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
|
||||
ddand884 and 1000 -NaN30 -> NaN Invalid_operation
|
||||
ddand885 and 1000 -sNaN31 -> NaN Invalid_operation
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,357 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCanonical.decTest -- test decDouble canonical results --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- This file tests that copy operations leave uncanonical operands
|
||||
-- unchanged, and vice versa
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Uncanonical declets are: abc, where:
|
||||
-- a=1,2,3
|
||||
-- b=6,7,e,f
|
||||
-- c=e,f
|
||||
|
||||
-- assert some standard (canonical) values; this tests that FromString
|
||||
-- produces canonical results (many more in decimalNN)
|
||||
ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
|
||||
ddcan002 apply 0 -> #2238000000000000
|
||||
ddcan003 apply 1 -> #2238000000000001
|
||||
ddcan004 apply -1 -> #a238000000000001
|
||||
ddcan005 apply Infinity -> #7800000000000000
|
||||
ddcan006 apply -Infinity -> #f800000000000000
|
||||
ddcan007 apply -NaN -> #fc00000000000000
|
||||
ddcan008 apply -sNaN -> #fe00000000000000
|
||||
ddcan009 apply NaN999999999999999 -> #7c00ff3fcff3fcff
|
||||
ddcan010 apply sNaN999999999999999 -> #7e00ff3fcff3fcff
|
||||
decan011 apply 9999999999999999 -> #6e38ff3fcff3fcff
|
||||
ddcan012 apply 7.50 -> #22300000000003d0
|
||||
ddcan013 apply 9.99 -> #22300000000000ff
|
||||
|
||||
-- Base tests for canonical encodings (individual operator
|
||||
-- propagation is tested later)
|
||||
|
||||
-- Finites: declets in coefficient
|
||||
ddcan021 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan022 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan023 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan024 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan025 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan026 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan027 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan028 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan030 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
|
||||
ddcan031 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
|
||||
ddcan032 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
|
||||
ddcan033 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
|
||||
ddcan035 canonical #77fcff3fdff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan036 canonical #77fcff3feff3fcff -> #77fcff3fcff3fcff
|
||||
|
||||
-- NaN: declets in payload
|
||||
ddcan100 canonical NaN999999999999999 -> #7c00ff3fcff3fcff
|
||||
ddcan101 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan102 canonical #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan103 canonical #7c00ffffcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan104 canonical #7c00ff3ffff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan105 canonical #7c00ff3fcffffcff -> #7c00ff3fcff3fcff
|
||||
ddcan106 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
|
||||
ddcan107 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
|
||||
-- NaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan110 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan112 canonical #7d00ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan113 canonical #7c80ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan114 canonical #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan115 canonical #7c20ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan116 canonical #7c10ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan117 canonical #7c08ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan118 canonical #7c04ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
|
||||
-- sNaN: declets in payload
|
||||
ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
|
||||
ddcan121 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan122 canonical #7e03ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan123 canonical #7e00ffffcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan124 canonical #7e00ff3ffff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan125 canonical #7e00ff3fcffffcff -> #7e00ff3fcff3fcff
|
||||
ddcan126 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
|
||||
ddcan127 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
|
||||
-- sNaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan130 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan132 canonical #7f00ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan133 canonical #7e80ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan134 canonical #7e40ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan135 canonical #7e20ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan136 canonical #7e10ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan137 canonical #7e08ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
ddcan138 canonical #7e04ff3fcff3fcff -> #7e00ff3fcff3fcff
|
||||
|
||||
-- Inf: exponent continuation bits
|
||||
ddcan140 canonical #7800000000000000 -> #7800000000000000
|
||||
ddcan141 canonical #7900000000000000 -> #7800000000000000
|
||||
ddcan142 canonical #7a00000000000000 -> #7800000000000000
|
||||
ddcan143 canonical #7880000000000000 -> #7800000000000000
|
||||
ddcan144 canonical #7840000000000000 -> #7800000000000000
|
||||
ddcan145 canonical #7820000000000000 -> #7800000000000000
|
||||
ddcan146 canonical #7810000000000000 -> #7800000000000000
|
||||
ddcan147 canonical #7808000000000000 -> #7800000000000000
|
||||
ddcan148 canonical #7804000000000000 -> #7800000000000000
|
||||
|
||||
-- Inf: coefficient continuation bits (first, last, and a few others)
|
||||
ddcan150 canonical #7800000000000000 -> #7800000000000000
|
||||
ddcan151 canonical #7802000000000000 -> #7800000000000000
|
||||
ddcan152 canonical #7800000000000001 -> #7800000000000000
|
||||
ddcan153 canonical #7801000000000000 -> #7800000000000000
|
||||
ddcan154 canonical #7800200000000000 -> #7800000000000000
|
||||
ddcan155 canonical #7800080000000000 -> #7800000000000000
|
||||
ddcan156 canonical #7800002000000000 -> #7800000000000000
|
||||
ddcan157 canonical #7800000400000000 -> #7800000000000000
|
||||
ddcan158 canonical #7800000040000000 -> #7800000000000000
|
||||
ddcan159 canonical #7800000008000000 -> #7800000000000000
|
||||
ddcan160 canonical #7800000000400000 -> #7800000000000000
|
||||
ddcan161 canonical #7800000000020000 -> #7800000000000000
|
||||
ddcan162 canonical #7800000000008000 -> #7800000000000000
|
||||
ddcan163 canonical #7800000000000200 -> #7800000000000000
|
||||
ddcan164 canonical #7800000000000040 -> #7800000000000000
|
||||
ddcan165 canonical #7800000000000008 -> #7800000000000000
|
||||
|
||||
|
||||
-- Now the operators -- trying to check paths that might fail to
|
||||
-- canonicalize propagated operands
|
||||
|
||||
----- Add:
|
||||
-- Finites: neutral 0
|
||||
ddcan202 add 0E+384 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan203 add #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
|
||||
-- tiny zero
|
||||
ddcan204 add 0E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Rounded
|
||||
ddcan205 add #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
|
||||
-- tiny non zero
|
||||
ddcan206 add -1E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Inexact Rounded
|
||||
ddcan207 add #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
|
||||
-- NaN: declets in payload
|
||||
ddcan211 add 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan212 add #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
|
||||
-- NaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan213 add 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan214 add #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
|
||||
-- sNaN: declets in payload
|
||||
ddcan215 add 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan216 add #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- sNaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan217 add 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan218 add #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- Inf: exponent continuation bits
|
||||
ddcan220 add 0 #7880000000000000 -> #7800000000000000
|
||||
ddcan221 add #7880000000000000 0 -> #7800000000000000
|
||||
-- Inf: coefficient continuation bits
|
||||
ddcan222 add 0 #7802000000000000 -> #7800000000000000
|
||||
ddcan223 add #7802000000000000 0 -> #7800000000000000
|
||||
ddcan224 add 0 #7800000000000001 -> #7800000000000000
|
||||
ddcan225 add #7800000000000001 0 -> #7800000000000000
|
||||
ddcan226 add 0 #7800002000000000 -> #7800000000000000
|
||||
ddcan227 add #7800002000000000 0 -> #7800000000000000
|
||||
|
||||
----- Class: [does not return encoded]
|
||||
|
||||
----- Compare:
|
||||
ddcan231 compare -Inf 1 -> #a238000000000001
|
||||
ddcan232 compare -Inf -Inf -> #2238000000000000
|
||||
ddcan233 compare 1 -Inf -> #2238000000000001
|
||||
ddcan234 compare #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff
|
||||
ddcan235 compare #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
|
||||
----- CompareSig:
|
||||
ddcan241 comparesig -Inf 1 -> #a238000000000001
|
||||
ddcan242 comparesig -Inf -Inf -> #2238000000000000
|
||||
ddcan243 comparesig 1 -Inf -> #2238000000000001
|
||||
ddcan244 comparesig #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan245 comparesig #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
|
||||
----- Copy: [does not usually canonicalize]
|
||||
-- finites
|
||||
ddcan250 copy #77ffff3fcff3fcff -> #77ffff3fcff3fcff
|
||||
ddcan251 copy #77fcff3fdff3fcff -> #77fcff3fdff3fcff
|
||||
-- NaNs
|
||||
ddcan252 copy #7c03ff3fcff3fcff -> #7c03ff3fcff3fcff
|
||||
ddcan253 copy #7c00ff3fcff3ffff -> #7c00ff3fcff3ffff
|
||||
ddcan254 copy #7d00ff3fcff3fcff -> #7d00ff3fcff3fcff
|
||||
ddcan255 copy #7c04ff3fcff3fcff -> #7c04ff3fcff3fcff
|
||||
-- sNaN
|
||||
ddcan256 copy #7e00ff3fcffffcff -> #7e00ff3fcffffcff
|
||||
ddcan257 copy #7e40ff3fcff3fcff -> #7e40ff3fcff3fcff
|
||||
-- Inf
|
||||
ddcan258 copy #7a00000000000000 -> #7a00000000000000
|
||||
ddcan259 copy #7800200000000000 -> #7800200000000000
|
||||
|
||||
----- CopyAbs: [does not usually canonicalize]
|
||||
-- finites
|
||||
ddcan260 copyabs #f7ffff3fcff3fcff -> #77ffff3fcff3fcff
|
||||
ddcan261 copyabs #f7fcff3fdff3fcff -> #77fcff3fdff3fcff
|
||||
-- NaNs
|
||||
ddcan262 copyabs #fc03ff3fcff3fcff -> #7c03ff3fcff3fcff
|
||||
ddcan263 copyabs #fc00ff3fcff3ffff -> #7c00ff3fcff3ffff
|
||||
ddcan264 copyabs #fd00ff3fcff3fcff -> #7d00ff3fcff3fcff
|
||||
ddcan265 copyabs #fc04ff3fcff3fcff -> #7c04ff3fcff3fcff
|
||||
-- sNaN
|
||||
ddcan266 copyabs #fe00ff3fcffffcff -> #7e00ff3fcffffcff
|
||||
ddcan267 copyabs #fe40ff3fcff3fcff -> #7e40ff3fcff3fcff
|
||||
-- Inf
|
||||
ddcan268 copyabs #fa00000000000000 -> #7a00000000000000
|
||||
ddcan269 copyabs #f800200000000000 -> #7800200000000000
|
||||
|
||||
----- CopyNegate: [does not usually canonicalize]
|
||||
-- finites
|
||||
ddcan270 copynegate #77ffff3fcff3fcff -> #f7ffff3fcff3fcff
|
||||
ddcan271 copynegate #77fcff3fdff3fcff -> #f7fcff3fdff3fcff
|
||||
-- NaNs
|
||||
ddcan272 copynegate #7c03ff3fcff3fcff -> #fc03ff3fcff3fcff
|
||||
ddcan273 copynegate #7c00ff3fcff3ffff -> #fc00ff3fcff3ffff
|
||||
ddcan274 copynegate #7d00ff3fcff3fcff -> #fd00ff3fcff3fcff
|
||||
ddcan275 copynegate #7c04ff3fcff3fcff -> #fc04ff3fcff3fcff
|
||||
-- sNaN
|
||||
ddcan276 copynegate #7e00ff3fcffffcff -> #fe00ff3fcffffcff
|
||||
ddcan277 copynegate #7e40ff3fcff3fcff -> #fe40ff3fcff3fcff
|
||||
-- Inf
|
||||
ddcan278 copynegate #7a00000000000000 -> #fa00000000000000
|
||||
ddcan279 copynegate #7800200000000000 -> #f800200000000000
|
||||
|
||||
----- CopySign: [does not usually canonicalize]
|
||||
-- finites
|
||||
ddcan280 copysign #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
|
||||
ddcan281 copysign #77fcff3fdff3fcff 1 -> #77fcff3fdff3fcff
|
||||
-- NaNs
|
||||
ddcan282 copysign #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
|
||||
ddcan283 copysign #7c00ff3fcff3ffff 1 -> #7c00ff3fcff3ffff
|
||||
ddcan284 copysign #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
|
||||
ddcan285 copysign #7c04ff3fcff3fcff 1 -> #7c04ff3fcff3fcff
|
||||
-- sNaN
|
||||
ddcan286 copysign #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
|
||||
ddcan287 copysign #7e40ff3fcff3fcff 1 -> #7e40ff3fcff3fcff
|
||||
-- Inf
|
||||
ddcan288 copysign #7a00000000000000 -1 -> #fa00000000000000
|
||||
ddcan289 copysign #7800200000000000 1 -> #7800200000000000
|
||||
|
||||
----- Multiply:
|
||||
-- Finites: neutral 0
|
||||
ddcan302 multiply 1 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
|
||||
ddcan303 multiply #77fcffffcff3fcff 1 -> #77fcff3fcff3fcff
|
||||
-- negative
|
||||
ddcan306 multiply -1 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
|
||||
ddcan307 multiply #77fcffffcff3fcff -1 -> #f7fcff3fcff3fcff
|
||||
-- NaN: declets in payload
|
||||
ddcan311 multiply 1 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan312 multiply #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
-- NaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan313 multiply 1 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan314 multiply #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
-- sNaN: declets in payload
|
||||
ddcan315 multiply 1 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan316 multiply #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- sNaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan317 multiply 1 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan318 multiply #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- Inf: exponent continuation bits
|
||||
ddcan320 multiply 1 #7880000000000000 -> #7800000000000000
|
||||
ddcan321 multiply #7880000000000000 1 -> #7800000000000000
|
||||
-- Inf: coefficient continuation bits
|
||||
ddcan322 multiply 1 #7802000000000000 -> #7800000000000000
|
||||
ddcan323 multiply #7802000000000000 1 -> #7800000000000000
|
||||
ddcan324 multiply 1 #7800000000000001 -> #7800000000000000
|
||||
ddcan325 multiply #7800000000000001 1 -> #7800000000000000
|
||||
ddcan326 multiply 1 #7800002000000000 -> #7800000000000000
|
||||
ddcan327 multiply #7800002000000000 1 -> #7800000000000000
|
||||
|
||||
----- Quantize:
|
||||
ddcan401 quantize #6e38ff3ffff3fcff 1 -> #6e38ff3fcff3fcff
|
||||
ddcan402 quantize #6e38ff3fcff3fdff 0 -> #6e38ff3fcff3fcff
|
||||
ddcan403 quantize #7880000000000000 Inf -> #7800000000000000
|
||||
ddcan404 quantize #7802000000000000 -Inf -> #7800000000000000
|
||||
ddcan410 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
ddcan411 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
ddcan412 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
ddcan413 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
|
||||
ddcan414 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan415 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan416 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan417 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
|
||||
----- Subtract:
|
||||
-- Finites: neutral 0
|
||||
ddcan502 subtract 0E+384 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
|
||||
ddcan503 subtract #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
|
||||
-- tiny zero
|
||||
ddcan504 subtract 0E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Rounded
|
||||
ddcan505 subtract #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
|
||||
-- tiny non zero
|
||||
ddcan506 subtract -1E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Inexact Rounded
|
||||
ddcan507 subtract #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
|
||||
-- NaN: declets in payload
|
||||
ddcan511 subtract 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan512 subtract #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
|
||||
-- NaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan513 subtract 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan514 subtract #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
|
||||
-- sNaN: declets in payload
|
||||
ddcan515 subtract 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan516 subtract #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- sNaN: exponent continuation bits [excluding sNaN selector]
|
||||
ddcan517 subtract 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan518 subtract #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- Inf: exponent continuation bits
|
||||
ddcan520 subtract 0 #7880000000000000 -> #f800000000000000
|
||||
ddcan521 subtract #7880000000000000 0 -> #7800000000000000
|
||||
-- Inf: coefficient continuation bits
|
||||
ddcan522 subtract 0 #7802000000000000 -> #f800000000000000
|
||||
ddcan523 subtract #7802000000000000 0 -> #7800000000000000
|
||||
ddcan524 subtract 0 #7800000000000001 -> #f800000000000000
|
||||
ddcan525 subtract #7800000000000001 0 -> #7800000000000000
|
||||
ddcan526 subtract 0 #7800002000000000 -> #f800000000000000
|
||||
ddcan527 subtract #7800002000000000 0 -> #7800000000000000
|
||||
|
||||
----- ToIntegral:
|
||||
ddcan601 tointegralx #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
|
||||
ddcan602 tointegralx #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
|
||||
ddcan603 tointegralx #7880000000000000 -> #7800000000000000
|
||||
ddcan604 tointegralx #7802000000000000 -> #7800000000000000
|
||||
ddcan610 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan611 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan612 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan613 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
|
||||
ddcan614 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan615 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan616 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
ddcan617 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
|
||||
-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
|
||||
ddcan618 tointegralx #2238000000000fff -> #2238000000000cff
|
||||
ddcan619 tointegralx #2230000000000fff -> #2238000000000040 Inexact Rounded
|
||||
ddcan620 tointegralx #222c000000000fff -> #2238000000000004 Inexact Rounded
|
||||
ddcan621 tointegralx #2228000000000fff -> #2238000000000000 Inexact Rounded
|
||||
ddcan622 tointegralx #a238000000000fff -> #a238000000000cff
|
||||
ddcan623 tointegralx #a230000000000fff -> #a238000000000040 Inexact Rounded
|
||||
ddcan624 tointegralx #a22c000000000fff -> #a238000000000004 Inexact Rounded
|
||||
ddcan625 tointegralx #a228000000000fff -> #a238000000000000 Inexact Rounded
|
||||
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddClass.decTest -- decDouble Class operations --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- [New 2006.11.27]
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
ddcla001 class 0 -> +Zero
|
||||
ddcla002 class 0.00 -> +Zero
|
||||
ddcla003 class 0E+5 -> +Zero
|
||||
ddcla004 class 1E-396 -> +Subnormal
|
||||
ddcla005 class 0.1E-383 -> +Subnormal
|
||||
ddcla006 class 0.999999999999999E-383 -> +Subnormal
|
||||
ddcla007 class 1.000000000000000E-383 -> +Normal
|
||||
ddcla008 class 1E-383 -> +Normal
|
||||
ddcla009 class 1E-100 -> +Normal
|
||||
ddcla010 class 1E-10 -> +Normal
|
||||
ddcla012 class 1E-1 -> +Normal
|
||||
ddcla013 class 1 -> +Normal
|
||||
ddcla014 class 2.50 -> +Normal
|
||||
ddcla015 class 100.100 -> +Normal
|
||||
ddcla016 class 1E+30 -> +Normal
|
||||
ddcla017 class 1E+384 -> +Normal
|
||||
ddcla018 class 9.999999999999999E+384 -> +Normal
|
||||
ddcla019 class Inf -> +Infinity
|
||||
|
||||
ddcla021 class -0 -> -Zero
|
||||
ddcla022 class -0.00 -> -Zero
|
||||
ddcla023 class -0E+5 -> -Zero
|
||||
ddcla024 class -1E-396 -> -Subnormal
|
||||
ddcla025 class -0.1E-383 -> -Subnormal
|
||||
ddcla026 class -0.999999999999999E-383 -> -Subnormal
|
||||
ddcla027 class -1.000000000000000E-383 -> -Normal
|
||||
ddcla028 class -1E-383 -> -Normal
|
||||
ddcla029 class -1E-100 -> -Normal
|
||||
ddcla030 class -1E-10 -> -Normal
|
||||
ddcla032 class -1E-1 -> -Normal
|
||||
ddcla033 class -1 -> -Normal
|
||||
ddcla034 class -2.50 -> -Normal
|
||||
ddcla035 class -100.100 -> -Normal
|
||||
ddcla036 class -1E+30 -> -Normal
|
||||
ddcla037 class -1E+384 -> -Normal
|
||||
ddcla038 class -9.999999999999999E+384 -> -Normal
|
||||
ddcla039 class -Inf -> -Infinity
|
||||
|
||||
ddcla041 class NaN -> NaN
|
||||
ddcla042 class -NaN -> NaN
|
||||
ddcla043 class +NaN12345 -> NaN
|
||||
ddcla044 class sNaN -> sNaN
|
||||
ddcla045 class -sNaN -> sNaN
|
||||
ddcla046 class +sNaN12345 -> sNaN
|
||||
|
||||
|
||||
|
@ -0,0 +1,744 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCompare.decTest -- decDouble comparison that allows quiet NaNs --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddcom001 compare -2 -2 -> 0
|
||||
ddcom002 compare -2 -1 -> -1
|
||||
ddcom003 compare -2 0 -> -1
|
||||
ddcom004 compare -2 1 -> -1
|
||||
ddcom005 compare -2 2 -> -1
|
||||
ddcom006 compare -1 -2 -> 1
|
||||
ddcom007 compare -1 -1 -> 0
|
||||
ddcom008 compare -1 0 -> -1
|
||||
ddcom009 compare -1 1 -> -1
|
||||
ddcom010 compare -1 2 -> -1
|
||||
ddcom011 compare 0 -2 -> 1
|
||||
ddcom012 compare 0 -1 -> 1
|
||||
ddcom013 compare 0 0 -> 0
|
||||
ddcom014 compare 0 1 -> -1
|
||||
ddcom015 compare 0 2 -> -1
|
||||
ddcom016 compare 1 -2 -> 1
|
||||
ddcom017 compare 1 -1 -> 1
|
||||
ddcom018 compare 1 0 -> 1
|
||||
ddcom019 compare 1 1 -> 0
|
||||
ddcom020 compare 1 2 -> -1
|
||||
ddcom021 compare 2 -2 -> 1
|
||||
ddcom022 compare 2 -1 -> 1
|
||||
ddcom023 compare 2 0 -> 1
|
||||
ddcom025 compare 2 1 -> 1
|
||||
ddcom026 compare 2 2 -> 0
|
||||
|
||||
ddcom031 compare -20 -20 -> 0
|
||||
ddcom032 compare -20 -10 -> -1
|
||||
ddcom033 compare -20 00 -> -1
|
||||
ddcom034 compare -20 10 -> -1
|
||||
ddcom035 compare -20 20 -> -1
|
||||
ddcom036 compare -10 -20 -> 1
|
||||
ddcom037 compare -10 -10 -> 0
|
||||
ddcom038 compare -10 00 -> -1
|
||||
ddcom039 compare -10 10 -> -1
|
||||
ddcom040 compare -10 20 -> -1
|
||||
ddcom041 compare 00 -20 -> 1
|
||||
ddcom042 compare 00 -10 -> 1
|
||||
ddcom043 compare 00 00 -> 0
|
||||
ddcom044 compare 00 10 -> -1
|
||||
ddcom045 compare 00 20 -> -1
|
||||
ddcom046 compare 10 -20 -> 1
|
||||
ddcom047 compare 10 -10 -> 1
|
||||
ddcom048 compare 10 00 -> 1
|
||||
ddcom049 compare 10 10 -> 0
|
||||
ddcom050 compare 10 20 -> -1
|
||||
ddcom051 compare 20 -20 -> 1
|
||||
ddcom052 compare 20 -10 -> 1
|
||||
ddcom053 compare 20 00 -> 1
|
||||
ddcom055 compare 20 10 -> 1
|
||||
ddcom056 compare 20 20 -> 0
|
||||
|
||||
ddcom061 compare -2.0 -2.0 -> 0
|
||||
ddcom062 compare -2.0 -1.0 -> -1
|
||||
ddcom063 compare -2.0 0.0 -> -1
|
||||
ddcom064 compare -2.0 1.0 -> -1
|
||||
ddcom065 compare -2.0 2.0 -> -1
|
||||
ddcom066 compare -1.0 -2.0 -> 1
|
||||
ddcom067 compare -1.0 -1.0 -> 0
|
||||
ddcom068 compare -1.0 0.0 -> -1
|
||||
ddcom069 compare -1.0 1.0 -> -1
|
||||
ddcom070 compare -1.0 2.0 -> -1
|
||||
ddcom071 compare 0.0 -2.0 -> 1
|
||||
ddcom072 compare 0.0 -1.0 -> 1
|
||||
ddcom073 compare 0.0 0.0 -> 0
|
||||
ddcom074 compare 0.0 1.0 -> -1
|
||||
ddcom075 compare 0.0 2.0 -> -1
|
||||
ddcom076 compare 1.0 -2.0 -> 1
|
||||
ddcom077 compare 1.0 -1.0 -> 1
|
||||
ddcom078 compare 1.0 0.0 -> 1
|
||||
ddcom079 compare 1.0 1.0 -> 0
|
||||
ddcom080 compare 1.0 2.0 -> -1
|
||||
ddcom081 compare 2.0 -2.0 -> 1
|
||||
ddcom082 compare 2.0 -1.0 -> 1
|
||||
ddcom083 compare 2.0 0.0 -> 1
|
||||
ddcom085 compare 2.0 1.0 -> 1
|
||||
ddcom086 compare 2.0 2.0 -> 0
|
||||
ddcom087 compare 1.0 0.1 -> 1
|
||||
ddcom088 compare 0.1 1.0 -> -1
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
ddcom095 compare 9.999999999999999E+384 9.999999999999999E+384 -> 0
|
||||
ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384 -> -1
|
||||
ddcom097 compare 9.999999999999999E+384 -9.999999999999999E+384 -> 1
|
||||
ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
ddcom100 compare 7.0 7.0 -> 0
|
||||
ddcom101 compare 7.0 7 -> 0
|
||||
ddcom102 compare 7 7.0 -> 0
|
||||
ddcom103 compare 7E+0 7.0 -> 0
|
||||
ddcom104 compare 70E-1 7.0 -> 0
|
||||
ddcom105 compare 0.7E+1 7 -> 0
|
||||
ddcom106 compare 70E-1 7 -> 0
|
||||
ddcom107 compare 7.0 7E+0 -> 0
|
||||
ddcom108 compare 7.0 70E-1 -> 0
|
||||
ddcom109 compare 7 0.7E+1 -> 0
|
||||
ddcom110 compare 7 70E-1 -> 0
|
||||
|
||||
ddcom120 compare 8.0 7.0 -> 1
|
||||
ddcom121 compare 8.0 7 -> 1
|
||||
ddcom122 compare 8 7.0 -> 1
|
||||
ddcom123 compare 8E+0 7.0 -> 1
|
||||
ddcom124 compare 80E-1 7.0 -> 1
|
||||
ddcom125 compare 0.8E+1 7 -> 1
|
||||
ddcom126 compare 80E-1 7 -> 1
|
||||
ddcom127 compare 8.0 7E+0 -> 1
|
||||
ddcom128 compare 8.0 70E-1 -> 1
|
||||
ddcom129 compare 8 0.7E+1 -> 1
|
||||
ddcom130 compare 8 70E-1 -> 1
|
||||
|
||||
ddcom140 compare 8.0 9.0 -> -1
|
||||
ddcom141 compare 8.0 9 -> -1
|
||||
ddcom142 compare 8 9.0 -> -1
|
||||
ddcom143 compare 8E+0 9.0 -> -1
|
||||
ddcom144 compare 80E-1 9.0 -> -1
|
||||
ddcom145 compare 0.8E+1 9 -> -1
|
||||
ddcom146 compare 80E-1 9 -> -1
|
||||
ddcom147 compare 8.0 9E+0 -> -1
|
||||
ddcom148 compare 8.0 90E-1 -> -1
|
||||
ddcom149 compare 8 0.9E+1 -> -1
|
||||
ddcom150 compare 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
ddcom200 compare -7.0 7.0 -> -1
|
||||
ddcom201 compare -7.0 7 -> -1
|
||||
ddcom202 compare -7 7.0 -> -1
|
||||
ddcom203 compare -7E+0 7.0 -> -1
|
||||
ddcom204 compare -70E-1 7.0 -> -1
|
||||
ddcom205 compare -0.7E+1 7 -> -1
|
||||
ddcom206 compare -70E-1 7 -> -1
|
||||
ddcom207 compare -7.0 7E+0 -> -1
|
||||
ddcom208 compare -7.0 70E-1 -> -1
|
||||
ddcom209 compare -7 0.7E+1 -> -1
|
||||
ddcom210 compare -7 70E-1 -> -1
|
||||
|
||||
ddcom220 compare -8.0 7.0 -> -1
|
||||
ddcom221 compare -8.0 7 -> -1
|
||||
ddcom222 compare -8 7.0 -> -1
|
||||
ddcom223 compare -8E+0 7.0 -> -1
|
||||
ddcom224 compare -80E-1 7.0 -> -1
|
||||
ddcom225 compare -0.8E+1 7 -> -1
|
||||
ddcom226 compare -80E-1 7 -> -1
|
||||
ddcom227 compare -8.0 7E+0 -> -1
|
||||
ddcom228 compare -8.0 70E-1 -> -1
|
||||
ddcom229 compare -8 0.7E+1 -> -1
|
||||
ddcom230 compare -8 70E-1 -> -1
|
||||
|
||||
ddcom240 compare -8.0 9.0 -> -1
|
||||
ddcom241 compare -8.0 9 -> -1
|
||||
ddcom242 compare -8 9.0 -> -1
|
||||
ddcom243 compare -8E+0 9.0 -> -1
|
||||
ddcom244 compare -80E-1 9.0 -> -1
|
||||
ddcom245 compare -0.8E+1 9 -> -1
|
||||
ddcom246 compare -80E-1 9 -> -1
|
||||
ddcom247 compare -8.0 9E+0 -> -1
|
||||
ddcom248 compare -8.0 90E-1 -> -1
|
||||
ddcom249 compare -8 0.9E+1 -> -1
|
||||
ddcom250 compare -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
ddcom300 compare 7.0 -7.0 -> 1
|
||||
ddcom301 compare 7.0 -7 -> 1
|
||||
ddcom302 compare 7 -7.0 -> 1
|
||||
ddcom303 compare 7E+0 -7.0 -> 1
|
||||
ddcom304 compare 70E-1 -7.0 -> 1
|
||||
ddcom305 compare .7E+1 -7 -> 1
|
||||
ddcom306 compare 70E-1 -7 -> 1
|
||||
ddcom307 compare 7.0 -7E+0 -> 1
|
||||
ddcom308 compare 7.0 -70E-1 -> 1
|
||||
ddcom309 compare 7 -.7E+1 -> 1
|
||||
ddcom310 compare 7 -70E-1 -> 1
|
||||
|
||||
ddcom320 compare 8.0 -7.0 -> 1
|
||||
ddcom321 compare 8.0 -7 -> 1
|
||||
ddcom322 compare 8 -7.0 -> 1
|
||||
ddcom323 compare 8E+0 -7.0 -> 1
|
||||
ddcom324 compare 80E-1 -7.0 -> 1
|
||||
ddcom325 compare .8E+1 -7 -> 1
|
||||
ddcom326 compare 80E-1 -7 -> 1
|
||||
ddcom327 compare 8.0 -7E+0 -> 1
|
||||
ddcom328 compare 8.0 -70E-1 -> 1
|
||||
ddcom329 compare 8 -.7E+1 -> 1
|
||||
ddcom330 compare 8 -70E-1 -> 1
|
||||
|
||||
ddcom340 compare 8.0 -9.0 -> 1
|
||||
ddcom341 compare 8.0 -9 -> 1
|
||||
ddcom342 compare 8 -9.0 -> 1
|
||||
ddcom343 compare 8E+0 -9.0 -> 1
|
||||
ddcom344 compare 80E-1 -9.0 -> 1
|
||||
ddcom345 compare .8E+1 -9 -> 1
|
||||
ddcom346 compare 80E-1 -9 -> 1
|
||||
ddcom347 compare 8.0 -9E+0 -> 1
|
||||
ddcom348 compare 8.0 -90E-1 -> 1
|
||||
ddcom349 compare 8 -.9E+1 -> 1
|
||||
ddcom350 compare 8 -90E-1 -> 1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
ddcom400 compare -7.0 -7.0 -> 0
|
||||
ddcom401 compare -7.0 -7 -> 0
|
||||
ddcom402 compare -7 -7.0 -> 0
|
||||
ddcom403 compare -7E+0 -7.0 -> 0
|
||||
ddcom404 compare -70E-1 -7.0 -> 0
|
||||
ddcom405 compare -.7E+1 -7 -> 0
|
||||
ddcom406 compare -70E-1 -7 -> 0
|
||||
ddcom407 compare -7.0 -7E+0 -> 0
|
||||
ddcom408 compare -7.0 -70E-1 -> 0
|
||||
ddcom409 compare -7 -.7E+1 -> 0
|
||||
ddcom410 compare -7 -70E-1 -> 0
|
||||
|
||||
ddcom420 compare -8.0 -7.0 -> -1
|
||||
ddcom421 compare -8.0 -7 -> -1
|
||||
ddcom422 compare -8 -7.0 -> -1
|
||||
ddcom423 compare -8E+0 -7.0 -> -1
|
||||
ddcom424 compare -80E-1 -7.0 -> -1
|
||||
ddcom425 compare -.8E+1 -7 -> -1
|
||||
ddcom426 compare -80E-1 -7 -> -1
|
||||
ddcom427 compare -8.0 -7E+0 -> -1
|
||||
ddcom428 compare -8.0 -70E-1 -> -1
|
||||
ddcom429 compare -8 -.7E+1 -> -1
|
||||
ddcom430 compare -8 -70E-1 -> -1
|
||||
|
||||
ddcom440 compare -8.0 -9.0 -> 1
|
||||
ddcom441 compare -8.0 -9 -> 1
|
||||
ddcom442 compare -8 -9.0 -> 1
|
||||
ddcom443 compare -8E+0 -9.0 -> 1
|
||||
ddcom444 compare -80E-1 -9.0 -> 1
|
||||
ddcom445 compare -.8E+1 -9 -> 1
|
||||
ddcom446 compare -80E-1 -9 -> 1
|
||||
ddcom447 compare -8.0 -9E+0 -> 1
|
||||
ddcom448 compare -8.0 -90E-1 -> 1
|
||||
ddcom449 compare -8 -.9E+1 -> 1
|
||||
ddcom450 compare -8 -90E-1 -> 1
|
||||
|
||||
-- misalignment traps for little-endian
|
||||
ddcom451 compare 1.0 0.1 -> 1
|
||||
ddcom452 compare 0.1 1.0 -> -1
|
||||
ddcom453 compare 10.0 0.1 -> 1
|
||||
ddcom454 compare 0.1 10.0 -> -1
|
||||
ddcom455 compare 100 1.0 -> 1
|
||||
ddcom456 compare 1.0 100 -> -1
|
||||
ddcom457 compare 1000 10.0 -> 1
|
||||
ddcom458 compare 10.0 1000 -> -1
|
||||
ddcom459 compare 10000 100.0 -> 1
|
||||
ddcom460 compare 100.0 10000 -> -1
|
||||
ddcom461 compare 100000 1000.0 -> 1
|
||||
ddcom462 compare 1000.0 100000 -> -1
|
||||
ddcom463 compare 1000000 10000.0 -> 1
|
||||
ddcom464 compare 10000.0 1000000 -> -1
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
|
||||
ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
|
||||
ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
|
||||
ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
|
||||
ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
|
||||
ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
|
||||
ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
|
||||
ddcom480 compare 123.456000E+89 123.456E+89 -> 0
|
||||
ddcom481 compare 123.45600E-89 123.456E-89 -> 0
|
||||
ddcom482 compare 123.4560E+89 123.456E+89 -> 0
|
||||
ddcom483 compare 123.456E-89 123.456E-89 -> 0
|
||||
ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
|
||||
ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
|
||||
ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
|
||||
ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
|
||||
ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
|
||||
ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
|
||||
ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
|
||||
ddcom494 compare 123.456E-89 123.456000E-89 -> 0
|
||||
ddcom495 compare 123.456E+89 123.45600E+89 -> 0
|
||||
ddcom496 compare 123.456E-89 123.4560E-89 -> 0
|
||||
ddcom497 compare 123.456E+89 123.456E+89 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
ddcom500 compare 1 1E-15 -> 1
|
||||
ddcom501 compare 1 1E-14 -> 1
|
||||
ddcom502 compare 1 1E-13 -> 1
|
||||
ddcom503 compare 1 1E-12 -> 1
|
||||
ddcom504 compare 1 1E-11 -> 1
|
||||
ddcom505 compare 1 1E-10 -> 1
|
||||
ddcom506 compare 1 1E-9 -> 1
|
||||
ddcom507 compare 1 1E-8 -> 1
|
||||
ddcom508 compare 1 1E-7 -> 1
|
||||
ddcom509 compare 1 1E-6 -> 1
|
||||
ddcom510 compare 1 1E-5 -> 1
|
||||
ddcom511 compare 1 1E-4 -> 1
|
||||
ddcom512 compare 1 1E-3 -> 1
|
||||
ddcom513 compare 1 1E-2 -> 1
|
||||
ddcom514 compare 1 1E-1 -> 1
|
||||
ddcom515 compare 1 1E-0 -> 0
|
||||
ddcom516 compare 1 1E+1 -> -1
|
||||
ddcom517 compare 1 1E+2 -> -1
|
||||
ddcom518 compare 1 1E+3 -> -1
|
||||
ddcom519 compare 1 1E+4 -> -1
|
||||
ddcom521 compare 1 1E+5 -> -1
|
||||
ddcom522 compare 1 1E+6 -> -1
|
||||
ddcom523 compare 1 1E+7 -> -1
|
||||
ddcom524 compare 1 1E+8 -> -1
|
||||
ddcom525 compare 1 1E+9 -> -1
|
||||
ddcom526 compare 1 1E+10 -> -1
|
||||
ddcom527 compare 1 1E+11 -> -1
|
||||
ddcom528 compare 1 1E+12 -> -1
|
||||
ddcom529 compare 1 1E+13 -> -1
|
||||
ddcom530 compare 1 1E+14 -> -1
|
||||
ddcom531 compare 1 1E+15 -> -1
|
||||
-- LR swap
|
||||
ddcom540 compare 1E-15 1 -> -1
|
||||
ddcom541 compare 1E-14 1 -> -1
|
||||
ddcom542 compare 1E-13 1 -> -1
|
||||
ddcom543 compare 1E-12 1 -> -1
|
||||
ddcom544 compare 1E-11 1 -> -1
|
||||
ddcom545 compare 1E-10 1 -> -1
|
||||
ddcom546 compare 1E-9 1 -> -1
|
||||
ddcom547 compare 1E-8 1 -> -1
|
||||
ddcom548 compare 1E-7 1 -> -1
|
||||
ddcom549 compare 1E-6 1 -> -1
|
||||
ddcom550 compare 1E-5 1 -> -1
|
||||
ddcom551 compare 1E-4 1 -> -1
|
||||
ddcom552 compare 1E-3 1 -> -1
|
||||
ddcom553 compare 1E-2 1 -> -1
|
||||
ddcom554 compare 1E-1 1 -> -1
|
||||
ddcom555 compare 1E-0 1 -> 0
|
||||
ddcom556 compare 1E+1 1 -> 1
|
||||
ddcom557 compare 1E+2 1 -> 1
|
||||
ddcom558 compare 1E+3 1 -> 1
|
||||
ddcom559 compare 1E+4 1 -> 1
|
||||
ddcom561 compare 1E+5 1 -> 1
|
||||
ddcom562 compare 1E+6 1 -> 1
|
||||
ddcom563 compare 1E+7 1 -> 1
|
||||
ddcom564 compare 1E+8 1 -> 1
|
||||
ddcom565 compare 1E+9 1 -> 1
|
||||
ddcom566 compare 1E+10 1 -> 1
|
||||
ddcom567 compare 1E+11 1 -> 1
|
||||
ddcom568 compare 1E+12 1 -> 1
|
||||
ddcom569 compare 1E+13 1 -> 1
|
||||
ddcom570 compare 1E+14 1 -> 1
|
||||
ddcom571 compare 1E+15 1 -> 1
|
||||
-- similar with a useful coefficient, one side only
|
||||
ddcom580 compare 0.000000987654321 1E-15 -> 1
|
||||
ddcom581 compare 0.000000987654321 1E-14 -> 1
|
||||
ddcom582 compare 0.000000987654321 1E-13 -> 1
|
||||
ddcom583 compare 0.000000987654321 1E-12 -> 1
|
||||
ddcom584 compare 0.000000987654321 1E-11 -> 1
|
||||
ddcom585 compare 0.000000987654321 1E-10 -> 1
|
||||
ddcom586 compare 0.000000987654321 1E-9 -> 1
|
||||
ddcom587 compare 0.000000987654321 1E-8 -> 1
|
||||
ddcom588 compare 0.000000987654321 1E-7 -> 1
|
||||
ddcom589 compare 0.000000987654321 1E-6 -> -1
|
||||
ddcom590 compare 0.000000987654321 1E-5 -> -1
|
||||
ddcom591 compare 0.000000987654321 1E-4 -> -1
|
||||
ddcom592 compare 0.000000987654321 1E-3 -> -1
|
||||
ddcom593 compare 0.000000987654321 1E-2 -> -1
|
||||
ddcom594 compare 0.000000987654321 1E-1 -> -1
|
||||
ddcom595 compare 0.000000987654321 1E-0 -> -1
|
||||
ddcom596 compare 0.000000987654321 1E+1 -> -1
|
||||
ddcom597 compare 0.000000987654321 1E+2 -> -1
|
||||
ddcom598 compare 0.000000987654321 1E+3 -> -1
|
||||
ddcom599 compare 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
ddcom600 compare 12 12.2345 -> -1
|
||||
ddcom601 compare 12.0 12.2345 -> -1
|
||||
ddcom602 compare 12.00 12.2345 -> -1
|
||||
ddcom603 compare 12.000 12.2345 -> -1
|
||||
ddcom604 compare 12.0000 12.2345 -> -1
|
||||
ddcom605 compare 12.00000 12.2345 -> -1
|
||||
ddcom606 compare 12.000000 12.2345 -> -1
|
||||
ddcom607 compare 12.0000000 12.2345 -> -1
|
||||
ddcom608 compare 12.00000000 12.2345 -> -1
|
||||
ddcom609 compare 12.000000000 12.2345 -> -1
|
||||
ddcom610 compare 12.1234 12 -> 1
|
||||
ddcom611 compare 12.1234 12.0 -> 1
|
||||
ddcom612 compare 12.1234 12.00 -> 1
|
||||
ddcom613 compare 12.1234 12.000 -> 1
|
||||
ddcom614 compare 12.1234 12.0000 -> 1
|
||||
ddcom615 compare 12.1234 12.00000 -> 1
|
||||
ddcom616 compare 12.1234 12.000000 -> 1
|
||||
ddcom617 compare 12.1234 12.0000000 -> 1
|
||||
ddcom618 compare 12.1234 12.00000000 -> 1
|
||||
ddcom619 compare 12.1234 12.000000000 -> 1
|
||||
ddcom620 compare -12 -12.2345 -> 1
|
||||
ddcom621 compare -12.0 -12.2345 -> 1
|
||||
ddcom622 compare -12.00 -12.2345 -> 1
|
||||
ddcom623 compare -12.000 -12.2345 -> 1
|
||||
ddcom624 compare -12.0000 -12.2345 -> 1
|
||||
ddcom625 compare -12.00000 -12.2345 -> 1
|
||||
ddcom626 compare -12.000000 -12.2345 -> 1
|
||||
ddcom627 compare -12.0000000 -12.2345 -> 1
|
||||
ddcom628 compare -12.00000000 -12.2345 -> 1
|
||||
ddcom629 compare -12.000000000 -12.2345 -> 1
|
||||
ddcom630 compare -12.1234 -12 -> -1
|
||||
ddcom631 compare -12.1234 -12.0 -> -1
|
||||
ddcom632 compare -12.1234 -12.00 -> -1
|
||||
ddcom633 compare -12.1234 -12.000 -> -1
|
||||
ddcom634 compare -12.1234 -12.0000 -> -1
|
||||
ddcom635 compare -12.1234 -12.00000 -> -1
|
||||
ddcom636 compare -12.1234 -12.000000 -> -1
|
||||
ddcom637 compare -12.1234 -12.0000000 -> -1
|
||||
ddcom638 compare -12.1234 -12.00000000 -> -1
|
||||
ddcom639 compare -12.1234 -12.000000000 -> -1
|
||||
|
||||
-- extended zeros
|
||||
ddcom640 compare 0 0 -> 0
|
||||
ddcom641 compare 0 -0 -> 0
|
||||
ddcom642 compare 0 -0.0 -> 0
|
||||
ddcom643 compare 0 0.0 -> 0
|
||||
ddcom644 compare -0 0 -> 0
|
||||
ddcom645 compare -0 -0 -> 0
|
||||
ddcom646 compare -0 -0.0 -> 0
|
||||
ddcom647 compare -0 0.0 -> 0
|
||||
ddcom648 compare 0.0 0 -> 0
|
||||
ddcom649 compare 0.0 -0 -> 0
|
||||
ddcom650 compare 0.0 -0.0 -> 0
|
||||
ddcom651 compare 0.0 0.0 -> 0
|
||||
ddcom652 compare -0.0 0 -> 0
|
||||
ddcom653 compare -0.0 -0 -> 0
|
||||
ddcom654 compare -0.0 -0.0 -> 0
|
||||
ddcom655 compare -0.0 0.0 -> 0
|
||||
|
||||
ddcom656 compare -0E1 0.0 -> 0
|
||||
ddcom657 compare -0E2 0.0 -> 0
|
||||
ddcom658 compare 0E1 0.0 -> 0
|
||||
ddcom659 compare 0E2 0.0 -> 0
|
||||
ddcom660 compare -0E1 0 -> 0
|
||||
ddcom661 compare -0E2 0 -> 0
|
||||
ddcom662 compare 0E1 0 -> 0
|
||||
ddcom663 compare 0E2 0 -> 0
|
||||
ddcom664 compare -0E1 -0E1 -> 0
|
||||
ddcom665 compare -0E2 -0E1 -> 0
|
||||
ddcom666 compare 0E1 -0E1 -> 0
|
||||
ddcom667 compare 0E2 -0E1 -> 0
|
||||
ddcom668 compare -0E1 -0E2 -> 0
|
||||
ddcom669 compare -0E2 -0E2 -> 0
|
||||
ddcom670 compare 0E1 -0E2 -> 0
|
||||
ddcom671 compare 0E2 -0E2 -> 0
|
||||
ddcom672 compare -0E1 0E1 -> 0
|
||||
ddcom673 compare -0E2 0E1 -> 0
|
||||
ddcom674 compare 0E1 0E1 -> 0
|
||||
ddcom675 compare 0E2 0E1 -> 0
|
||||
ddcom676 compare -0E1 0E2 -> 0
|
||||
ddcom677 compare -0E2 0E2 -> 0
|
||||
ddcom678 compare 0E1 0E2 -> 0
|
||||
ddcom679 compare 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
ddcom680 compare 12 12 -> 0
|
||||
ddcom681 compare 12 12.0 -> 0
|
||||
ddcom682 compare 12 12.00 -> 0
|
||||
ddcom683 compare 12 12.000 -> 0
|
||||
ddcom684 compare 12 12.0000 -> 0
|
||||
ddcom685 compare 12 12.00000 -> 0
|
||||
ddcom686 compare 12 12.000000 -> 0
|
||||
ddcom687 compare 12 12.0000000 -> 0
|
||||
ddcom688 compare 12 12.00000000 -> 0
|
||||
ddcom689 compare 12 12.000000000 -> 0
|
||||
ddcom690 compare 12 12 -> 0
|
||||
ddcom691 compare 12.0 12 -> 0
|
||||
ddcom692 compare 12.00 12 -> 0
|
||||
ddcom693 compare 12.000 12 -> 0
|
||||
ddcom694 compare 12.0000 12 -> 0
|
||||
ddcom695 compare 12.00000 12 -> 0
|
||||
ddcom696 compare 12.000000 12 -> 0
|
||||
ddcom697 compare 12.0000000 12 -> 0
|
||||
ddcom698 compare 12.00000000 12 -> 0
|
||||
ddcom699 compare 12.000000000 12 -> 0
|
||||
|
||||
-- first, second, & last digit
|
||||
ddcom700 compare 1234567890123456 1234567890123455 -> 1
|
||||
ddcom701 compare 1234567890123456 1234567890123456 -> 0
|
||||
ddcom702 compare 1234567890123456 1234567890123457 -> -1
|
||||
ddcom703 compare 1234567890123456 0234567890123456 -> 1
|
||||
ddcom704 compare 1234567890123456 1234567890123456 -> 0
|
||||
ddcom705 compare 1234567890123456 2234567890123456 -> -1
|
||||
ddcom706 compare 1134567890123456 1034567890123456 -> 1
|
||||
ddcom707 compare 1134567890123456 1134567890123456 -> 0
|
||||
ddcom708 compare 1134567890123456 1234567890123456 -> -1
|
||||
|
||||
-- miscellaneous
|
||||
ddcom721 compare 12345678000 1 -> 1
|
||||
ddcom722 compare 1 12345678000 -> -1
|
||||
ddcom723 compare 1234567800 1 -> 1
|
||||
ddcom724 compare 1 1234567800 -> -1
|
||||
ddcom725 compare 1234567890 1 -> 1
|
||||
ddcom726 compare 1 1234567890 -> -1
|
||||
ddcom727 compare 1234567891 1 -> 1
|
||||
ddcom728 compare 1 1234567891 -> -1
|
||||
ddcom729 compare 12345678901 1 -> 1
|
||||
ddcom730 compare 1 12345678901 -> -1
|
||||
ddcom731 compare 1234567896 1 -> 1
|
||||
ddcom732 compare 1 1234567896 -> -1
|
||||
|
||||
-- residue cases at lower precision
|
||||
ddcom740 compare 1 0.9999999 -> 1
|
||||
ddcom741 compare 1 0.999999 -> 1
|
||||
ddcom742 compare 1 0.99999 -> 1
|
||||
ddcom743 compare 1 1.0000 -> 0
|
||||
ddcom744 compare 1 1.00001 -> -1
|
||||
ddcom745 compare 1 1.000001 -> -1
|
||||
ddcom746 compare 1 1.0000001 -> -1
|
||||
ddcom750 compare 0.9999999 1 -> -1
|
||||
ddcom751 compare 0.999999 1 -> -1
|
||||
ddcom752 compare 0.99999 1 -> -1
|
||||
ddcom753 compare 1.0000 1 -> 0
|
||||
ddcom754 compare 1.00001 1 -> 1
|
||||
ddcom755 compare 1.000001 1 -> 1
|
||||
ddcom756 compare 1.0000001 1 -> 1
|
||||
|
||||
-- Specials
|
||||
ddcom780 compare Inf -Inf -> 1
|
||||
ddcom781 compare Inf -1000 -> 1
|
||||
ddcom782 compare Inf -1 -> 1
|
||||
ddcom783 compare Inf -0 -> 1
|
||||
ddcom784 compare Inf 0 -> 1
|
||||
ddcom785 compare Inf 1 -> 1
|
||||
ddcom786 compare Inf 1000 -> 1
|
||||
ddcom787 compare Inf Inf -> 0
|
||||
ddcom788 compare -1000 Inf -> -1
|
||||
ddcom789 compare -Inf Inf -> -1
|
||||
ddcom790 compare -1 Inf -> -1
|
||||
ddcom791 compare -0 Inf -> -1
|
||||
ddcom792 compare 0 Inf -> -1
|
||||
ddcom793 compare 1 Inf -> -1
|
||||
ddcom794 compare 1000 Inf -> -1
|
||||
ddcom795 compare Inf Inf -> 0
|
||||
|
||||
ddcom800 compare -Inf -Inf -> 0
|
||||
ddcom801 compare -Inf -1000 -> -1
|
||||
ddcom802 compare -Inf -1 -> -1
|
||||
ddcom803 compare -Inf -0 -> -1
|
||||
ddcom804 compare -Inf 0 -> -1
|
||||
ddcom805 compare -Inf 1 -> -1
|
||||
ddcom806 compare -Inf 1000 -> -1
|
||||
ddcom807 compare -Inf Inf -> -1
|
||||
ddcom808 compare -Inf -Inf -> 0
|
||||
ddcom809 compare -1000 -Inf -> 1
|
||||
ddcom810 compare -1 -Inf -> 1
|
||||
ddcom811 compare -0 -Inf -> 1
|
||||
ddcom812 compare 0 -Inf -> 1
|
||||
ddcom813 compare 1 -Inf -> 1
|
||||
ddcom814 compare 1000 -Inf -> 1
|
||||
ddcom815 compare Inf -Inf -> 1
|
||||
|
||||
ddcom821 compare NaN -Inf -> NaN
|
||||
ddcom822 compare NaN -1000 -> NaN
|
||||
ddcom823 compare NaN -1 -> NaN
|
||||
ddcom824 compare NaN -0 -> NaN
|
||||
ddcom825 compare NaN 0 -> NaN
|
||||
ddcom826 compare NaN 1 -> NaN
|
||||
ddcom827 compare NaN 1000 -> NaN
|
||||
ddcom828 compare NaN Inf -> NaN
|
||||
ddcom829 compare NaN NaN -> NaN
|
||||
ddcom830 compare -Inf NaN -> NaN
|
||||
ddcom831 compare -1000 NaN -> NaN
|
||||
ddcom832 compare -1 NaN -> NaN
|
||||
ddcom833 compare -0 NaN -> NaN
|
||||
ddcom834 compare 0 NaN -> NaN
|
||||
ddcom835 compare 1 NaN -> NaN
|
||||
ddcom836 compare 1000 NaN -> NaN
|
||||
ddcom837 compare Inf NaN -> NaN
|
||||
ddcom838 compare -NaN -NaN -> -NaN
|
||||
ddcom839 compare +NaN -NaN -> NaN
|
||||
ddcom840 compare -NaN +NaN -> -NaN
|
||||
|
||||
ddcom841 compare sNaN -Inf -> NaN Invalid_operation
|
||||
ddcom842 compare sNaN -1000 -> NaN Invalid_operation
|
||||
ddcom843 compare sNaN -1 -> NaN Invalid_operation
|
||||
ddcom844 compare sNaN -0 -> NaN Invalid_operation
|
||||
ddcom845 compare sNaN 0 -> NaN Invalid_operation
|
||||
ddcom846 compare sNaN 1 -> NaN Invalid_operation
|
||||
ddcom847 compare sNaN 1000 -> NaN Invalid_operation
|
||||
ddcom848 compare sNaN NaN -> NaN Invalid_operation
|
||||
ddcom849 compare sNaN sNaN -> NaN Invalid_operation
|
||||
ddcom850 compare NaN sNaN -> NaN Invalid_operation
|
||||
ddcom851 compare -Inf sNaN -> NaN Invalid_operation
|
||||
ddcom852 compare -1000 sNaN -> NaN Invalid_operation
|
||||
ddcom853 compare -1 sNaN -> NaN Invalid_operation
|
||||
ddcom854 compare -0 sNaN -> NaN Invalid_operation
|
||||
ddcom855 compare 0 sNaN -> NaN Invalid_operation
|
||||
ddcom856 compare 1 sNaN -> NaN Invalid_operation
|
||||
ddcom857 compare 1000 sNaN -> NaN Invalid_operation
|
||||
ddcom858 compare Inf sNaN -> NaN Invalid_operation
|
||||
ddcom859 compare NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddcom860 compare NaN9 -Inf -> NaN9
|
||||
ddcom861 compare NaN8 999 -> NaN8
|
||||
ddcom862 compare NaN77 Inf -> NaN77
|
||||
ddcom863 compare -NaN67 NaN5 -> -NaN67
|
||||
ddcom864 compare -Inf -NaN4 -> -NaN4
|
||||
ddcom865 compare -999 -NaN33 -> -NaN33
|
||||
ddcom866 compare Inf NaN2 -> NaN2
|
||||
ddcom867 compare -NaN41 -NaN42 -> -NaN41
|
||||
ddcom868 compare +NaN41 -NaN42 -> NaN41
|
||||
ddcom869 compare -NaN41 +NaN42 -> -NaN41
|
||||
ddcom870 compare +NaN41 +NaN42 -> NaN41
|
||||
|
||||
ddcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
ddcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
|
||||
ddcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
|
||||
ddcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
|
||||
ddcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
|
||||
ddcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
|
||||
ddcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
|
||||
ddcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
|
||||
|
||||
-- wide range
|
||||
ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
|
||||
ddcom881 compare 9E+384 +1.23456789012345E-0 -> 1
|
||||
ddcom882 compare +0.100 9E-383 -> 1
|
||||
ddcom883 compare 9E-383 +0.100 -> -1
|
||||
ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
|
||||
ddcom886 compare 9E+384 -1.23456789012345E-0 -> 1
|
||||
ddcom887 compare -0.100 9E-383 -> -1
|
||||
ddcom888 compare 9E-383 -0.100 -> 1
|
||||
|
||||
-- spread zeros
|
||||
ddcom900 compare 0E-383 0 -> 0
|
||||
ddcom901 compare 0E-383 -0 -> 0
|
||||
ddcom902 compare -0E-383 0 -> 0
|
||||
ddcom903 compare -0E-383 -0 -> 0
|
||||
ddcom904 compare 0E-383 0E+384 -> 0
|
||||
ddcom905 compare 0E-383 -0E+384 -> 0
|
||||
ddcom906 compare -0E-383 0E+384 -> 0
|
||||
ddcom907 compare -0E-383 -0E+384 -> 0
|
||||
ddcom908 compare 0 0E+384 -> 0
|
||||
ddcom909 compare 0 -0E+384 -> 0
|
||||
ddcom910 compare -0 0E+384 -> 0
|
||||
ddcom911 compare -0 -0E+384 -> 0
|
||||
ddcom930 compare 0E+384 0 -> 0
|
||||
ddcom931 compare 0E+384 -0 -> 0
|
||||
ddcom932 compare -0E+384 0 -> 0
|
||||
ddcom933 compare -0E+384 -0 -> 0
|
||||
ddcom934 compare 0E+384 0E-383 -> 0
|
||||
ddcom935 compare 0E+384 -0E-383 -> 0
|
||||
ddcom936 compare -0E+384 0E-383 -> 0
|
||||
ddcom937 compare -0E+384 -0E-383 -> 0
|
||||
ddcom938 compare 0 0E-383 -> 0
|
||||
ddcom939 compare 0 -0E-383 -> 0
|
||||
ddcom940 compare -0 0E-383 -> 0
|
||||
ddcom941 compare -0 -0E-383 -> 0
|
||||
|
||||
-- signs
|
||||
ddcom961 compare 1e+77 1e+11 -> 1
|
||||
ddcom962 compare 1e+77 -1e+11 -> 1
|
||||
ddcom963 compare -1e+77 1e+11 -> -1
|
||||
ddcom964 compare -1e+77 -1e+11 -> -1
|
||||
ddcom965 compare 1e-77 1e-11 -> -1
|
||||
ddcom966 compare 1e-77 -1e-11 -> 1
|
||||
ddcom967 compare -1e-77 1e-11 -> -1
|
||||
ddcom968 compare -1e-77 -1e-11 -> 1
|
||||
|
||||
-- full alignment range, both ways
|
||||
ddcomp1001 compare 1 1.000000000000000 -> 0
|
||||
ddcomp1002 compare 1 1.00000000000000 -> 0
|
||||
ddcomp1003 compare 1 1.0000000000000 -> 0
|
||||
ddcomp1004 compare 1 1.000000000000 -> 0
|
||||
ddcomp1005 compare 1 1.00000000000 -> 0
|
||||
ddcomp1006 compare 1 1.0000000000 -> 0
|
||||
ddcomp1007 compare 1 1.000000000 -> 0
|
||||
ddcomp1008 compare 1 1.00000000 -> 0
|
||||
ddcomp1009 compare 1 1.0000000 -> 0
|
||||
ddcomp1010 compare 1 1.000000 -> 0
|
||||
ddcomp1011 compare 1 1.00000 -> 0
|
||||
ddcomp1012 compare 1 1.0000 -> 0
|
||||
ddcomp1013 compare 1 1.000 -> 0
|
||||
ddcomp1014 compare 1 1.00 -> 0
|
||||
ddcomp1015 compare 1 1.0 -> 0
|
||||
ddcomp1021 compare 1.000000000000000 1 -> 0
|
||||
ddcomp1022 compare 1.00000000000000 1 -> 0
|
||||
ddcomp1023 compare 1.0000000000000 1 -> 0
|
||||
ddcomp1024 compare 1.000000000000 1 -> 0
|
||||
ddcomp1025 compare 1.00000000000 1 -> 0
|
||||
ddcomp1026 compare 1.0000000000 1 -> 0
|
||||
ddcomp1027 compare 1.000000000 1 -> 0
|
||||
ddcomp1028 compare 1.00000000 1 -> 0
|
||||
ddcomp1029 compare 1.0000000 1 -> 0
|
||||
ddcomp1030 compare 1.000000 1 -> 0
|
||||
ddcomp1031 compare 1.00000 1 -> 0
|
||||
ddcomp1032 compare 1.0000 1 -> 0
|
||||
ddcomp1033 compare 1.000 1 -> 0
|
||||
ddcomp1034 compare 1.00 1 -> 0
|
||||
ddcomp1035 compare 1.0 1 -> 0
|
||||
|
||||
-- check MSD always detected non-zero
|
||||
ddcomp1040 compare 0 0.000000000000000 -> 0
|
||||
ddcomp1041 compare 0 1.000000000000000 -> -1
|
||||
ddcomp1042 compare 0 2.000000000000000 -> -1
|
||||
ddcomp1043 compare 0 3.000000000000000 -> -1
|
||||
ddcomp1044 compare 0 4.000000000000000 -> -1
|
||||
ddcomp1045 compare 0 5.000000000000000 -> -1
|
||||
ddcomp1046 compare 0 6.000000000000000 -> -1
|
||||
ddcomp1047 compare 0 7.000000000000000 -> -1
|
||||
ddcomp1048 compare 0 8.000000000000000 -> -1
|
||||
ddcomp1049 compare 0 9.000000000000000 -> -1
|
||||
ddcomp1050 compare 0.000000000000000 0 -> 0
|
||||
ddcomp1051 compare 1.000000000000000 0 -> 1
|
||||
ddcomp1052 compare 2.000000000000000 0 -> 1
|
||||
ddcomp1053 compare 3.000000000000000 0 -> 1
|
||||
ddcomp1054 compare 4.000000000000000 0 -> 1
|
||||
ddcomp1055 compare 5.000000000000000 0 -> 1
|
||||
ddcomp1056 compare 6.000000000000000 0 -> 1
|
||||
ddcomp1057 compare 7.000000000000000 0 -> 1
|
||||
ddcomp1058 compare 8.000000000000000 0 -> 1
|
||||
ddcomp1059 compare 9.000000000000000 0 -> 1
|
||||
|
||||
-- Null tests
|
||||
ddcom9990 compare 10 # -> NaN Invalid_operation
|
||||
ddcom9991 compare # 10 -> NaN Invalid_operation
|
@ -0,0 +1,647 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCompareSig.decTest -- decDouble comparison; all NaNs signal --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddcms001 comparesig -2 -2 -> 0
|
||||
ddcms002 comparesig -2 -1 -> -1
|
||||
ddcms003 comparesig -2 0 -> -1
|
||||
ddcms004 comparesig -2 1 -> -1
|
||||
ddcms005 comparesig -2 2 -> -1
|
||||
ddcms006 comparesig -1 -2 -> 1
|
||||
ddcms007 comparesig -1 -1 -> 0
|
||||
ddcms008 comparesig -1 0 -> -1
|
||||
ddcms009 comparesig -1 1 -> -1
|
||||
ddcms010 comparesig -1 2 -> -1
|
||||
ddcms011 comparesig 0 -2 -> 1
|
||||
ddcms012 comparesig 0 -1 -> 1
|
||||
ddcms013 comparesig 0 0 -> 0
|
||||
ddcms014 comparesig 0 1 -> -1
|
||||
ddcms015 comparesig 0 2 -> -1
|
||||
ddcms016 comparesig 1 -2 -> 1
|
||||
ddcms017 comparesig 1 -1 -> 1
|
||||
ddcms018 comparesig 1 0 -> 1
|
||||
ddcms019 comparesig 1 1 -> 0
|
||||
ddcms020 comparesig 1 2 -> -1
|
||||
ddcms021 comparesig 2 -2 -> 1
|
||||
ddcms022 comparesig 2 -1 -> 1
|
||||
ddcms023 comparesig 2 0 -> 1
|
||||
ddcms025 comparesig 2 1 -> 1
|
||||
ddcms026 comparesig 2 2 -> 0
|
||||
|
||||
ddcms031 comparesig -20 -20 -> 0
|
||||
ddcms032 comparesig -20 -10 -> -1
|
||||
ddcms033 comparesig -20 00 -> -1
|
||||
ddcms034 comparesig -20 10 -> -1
|
||||
ddcms035 comparesig -20 20 -> -1
|
||||
ddcms036 comparesig -10 -20 -> 1
|
||||
ddcms037 comparesig -10 -10 -> 0
|
||||
ddcms038 comparesig -10 00 -> -1
|
||||
ddcms039 comparesig -10 10 -> -1
|
||||
ddcms040 comparesig -10 20 -> -1
|
||||
ddcms041 comparesig 00 -20 -> 1
|
||||
ddcms042 comparesig 00 -10 -> 1
|
||||
ddcms043 comparesig 00 00 -> 0
|
||||
ddcms044 comparesig 00 10 -> -1
|
||||
ddcms045 comparesig 00 20 -> -1
|
||||
ddcms046 comparesig 10 -20 -> 1
|
||||
ddcms047 comparesig 10 -10 -> 1
|
||||
ddcms048 comparesig 10 00 -> 1
|
||||
ddcms049 comparesig 10 10 -> 0
|
||||
ddcms050 comparesig 10 20 -> -1
|
||||
ddcms051 comparesig 20 -20 -> 1
|
||||
ddcms052 comparesig 20 -10 -> 1
|
||||
ddcms053 comparesig 20 00 -> 1
|
||||
ddcms055 comparesig 20 10 -> 1
|
||||
ddcms056 comparesig 20 20 -> 0
|
||||
|
||||
ddcms061 comparesig -2.0 -2.0 -> 0
|
||||
ddcms062 comparesig -2.0 -1.0 -> -1
|
||||
ddcms063 comparesig -2.0 0.0 -> -1
|
||||
ddcms064 comparesig -2.0 1.0 -> -1
|
||||
ddcms065 comparesig -2.0 2.0 -> -1
|
||||
ddcms066 comparesig -1.0 -2.0 -> 1
|
||||
ddcms067 comparesig -1.0 -1.0 -> 0
|
||||
ddcms068 comparesig -1.0 0.0 -> -1
|
||||
ddcms069 comparesig -1.0 1.0 -> -1
|
||||
ddcms070 comparesig -1.0 2.0 -> -1
|
||||
ddcms071 comparesig 0.0 -2.0 -> 1
|
||||
ddcms072 comparesig 0.0 -1.0 -> 1
|
||||
ddcms073 comparesig 0.0 0.0 -> 0
|
||||
ddcms074 comparesig 0.0 1.0 -> -1
|
||||
ddcms075 comparesig 0.0 2.0 -> -1
|
||||
ddcms076 comparesig 1.0 -2.0 -> 1
|
||||
ddcms077 comparesig 1.0 -1.0 -> 1
|
||||
ddcms078 comparesig 1.0 0.0 -> 1
|
||||
ddcms079 comparesig 1.0 1.0 -> 0
|
||||
ddcms080 comparesig 1.0 2.0 -> -1
|
||||
ddcms081 comparesig 2.0 -2.0 -> 1
|
||||
ddcms082 comparesig 2.0 -1.0 -> 1
|
||||
ddcms083 comparesig 2.0 0.0 -> 1
|
||||
ddcms085 comparesig 2.0 1.0 -> 1
|
||||
ddcms086 comparesig 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
ddcms090 comparesig 9.999999999999999E+384 9.999999999999999E+384 -> 0
|
||||
ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384 -> -1
|
||||
ddcms092 comparesig 9.999999999999999E+384 -9.999999999999999E+384 -> 1
|
||||
ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
ddcms100 comparesig 7.0 7.0 -> 0
|
||||
ddcms101 comparesig 7.0 7 -> 0
|
||||
ddcms102 comparesig 7 7.0 -> 0
|
||||
ddcms103 comparesig 7E+0 7.0 -> 0
|
||||
ddcms104 comparesig 70E-1 7.0 -> 0
|
||||
ddcms105 comparesig 0.7E+1 7 -> 0
|
||||
ddcms106 comparesig 70E-1 7 -> 0
|
||||
ddcms107 comparesig 7.0 7E+0 -> 0
|
||||
ddcms108 comparesig 7.0 70E-1 -> 0
|
||||
ddcms109 comparesig 7 0.7E+1 -> 0
|
||||
ddcms110 comparesig 7 70E-1 -> 0
|
||||
|
||||
ddcms120 comparesig 8.0 7.0 -> 1
|
||||
ddcms121 comparesig 8.0 7 -> 1
|
||||
ddcms122 comparesig 8 7.0 -> 1
|
||||
ddcms123 comparesig 8E+0 7.0 -> 1
|
||||
ddcms124 comparesig 80E-1 7.0 -> 1
|
||||
ddcms125 comparesig 0.8E+1 7 -> 1
|
||||
ddcms126 comparesig 80E-1 7 -> 1
|
||||
ddcms127 comparesig 8.0 7E+0 -> 1
|
||||
ddcms128 comparesig 8.0 70E-1 -> 1
|
||||
ddcms129 comparesig 8 0.7E+1 -> 1
|
||||
ddcms130 comparesig 8 70E-1 -> 1
|
||||
|
||||
ddcms140 comparesig 8.0 9.0 -> -1
|
||||
ddcms141 comparesig 8.0 9 -> -1
|
||||
ddcms142 comparesig 8 9.0 -> -1
|
||||
ddcms143 comparesig 8E+0 9.0 -> -1
|
||||
ddcms144 comparesig 80E-1 9.0 -> -1
|
||||
ddcms145 comparesig 0.8E+1 9 -> -1
|
||||
ddcms146 comparesig 80E-1 9 -> -1
|
||||
ddcms147 comparesig 8.0 9E+0 -> -1
|
||||
ddcms148 comparesig 8.0 90E-1 -> -1
|
||||
ddcms149 comparesig 8 0.9E+1 -> -1
|
||||
ddcms150 comparesig 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
ddcms200 comparesig -7.0 7.0 -> -1
|
||||
ddcms201 comparesig -7.0 7 -> -1
|
||||
ddcms202 comparesig -7 7.0 -> -1
|
||||
ddcms203 comparesig -7E+0 7.0 -> -1
|
||||
ddcms204 comparesig -70E-1 7.0 -> -1
|
||||
ddcms205 comparesig -0.7E+1 7 -> -1
|
||||
ddcms206 comparesig -70E-1 7 -> -1
|
||||
ddcms207 comparesig -7.0 7E+0 -> -1
|
||||
ddcms208 comparesig -7.0 70E-1 -> -1
|
||||
ddcms209 comparesig -7 0.7E+1 -> -1
|
||||
ddcms210 comparesig -7 70E-1 -> -1
|
||||
|
||||
ddcms220 comparesig -8.0 7.0 -> -1
|
||||
ddcms221 comparesig -8.0 7 -> -1
|
||||
ddcms222 comparesig -8 7.0 -> -1
|
||||
ddcms223 comparesig -8E+0 7.0 -> -1
|
||||
ddcms224 comparesig -80E-1 7.0 -> -1
|
||||
ddcms225 comparesig -0.8E+1 7 -> -1
|
||||
ddcms226 comparesig -80E-1 7 -> -1
|
||||
ddcms227 comparesig -8.0 7E+0 -> -1
|
||||
ddcms228 comparesig -8.0 70E-1 -> -1
|
||||
ddcms229 comparesig -8 0.7E+1 -> -1
|
||||
ddcms230 comparesig -8 70E-1 -> -1
|
||||
|
||||
ddcms240 comparesig -8.0 9.0 -> -1
|
||||
ddcms241 comparesig -8.0 9 -> -1
|
||||
ddcms242 comparesig -8 9.0 -> -1
|
||||
ddcms243 comparesig -8E+0 9.0 -> -1
|
||||
ddcms244 comparesig -80E-1 9.0 -> -1
|
||||
ddcms245 comparesig -0.8E+1 9 -> -1
|
||||
ddcms246 comparesig -80E-1 9 -> -1
|
||||
ddcms247 comparesig -8.0 9E+0 -> -1
|
||||
ddcms248 comparesig -8.0 90E-1 -> -1
|
||||
ddcms249 comparesig -8 0.9E+1 -> -1
|
||||
ddcms250 comparesig -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
ddcms300 comparesig 7.0 -7.0 -> 1
|
||||
ddcms301 comparesig 7.0 -7 -> 1
|
||||
ddcms302 comparesig 7 -7.0 -> 1
|
||||
ddcms303 comparesig 7E+0 -7.0 -> 1
|
||||
ddcms304 comparesig 70E-1 -7.0 -> 1
|
||||
ddcms305 comparesig .7E+1 -7 -> 1
|
||||
ddcms306 comparesig 70E-1 -7 -> 1
|
||||
ddcms307 comparesig 7.0 -7E+0 -> 1
|
||||
ddcms308 comparesig 7.0 -70E-1 -> 1
|
||||
ddcms309 comparesig 7 -.7E+1 -> 1
|
||||
ddcms310 comparesig 7 -70E-1 -> 1
|
||||
|
||||
ddcms320 comparesig 8.0 -7.0 -> 1
|
||||
ddcms321 comparesig 8.0 -7 -> 1
|
||||
ddcms322 comparesig 8 -7.0 -> 1
|
||||
ddcms323 comparesig 8E+0 -7.0 -> 1
|
||||
ddcms324 comparesig 80E-1 -7.0 -> 1
|
||||
ddcms325 comparesig .8E+1 -7 -> 1
|
||||
ddcms326 comparesig 80E-1 -7 -> 1
|
||||
ddcms327 comparesig 8.0 -7E+0 -> 1
|
||||
ddcms328 comparesig 8.0 -70E-1 -> 1
|
||||
ddcms329 comparesig 8 -.7E+1 -> 1
|
||||
ddcms330 comparesig 8 -70E-1 -> 1
|
||||
|
||||
ddcms340 comparesig 8.0 -9.0 -> 1
|
||||
ddcms341 comparesig 8.0 -9 -> 1
|
||||
ddcms342 comparesig 8 -9.0 -> 1
|
||||
ddcms343 comparesig 8E+0 -9.0 -> 1
|
||||
ddcms344 comparesig 80E-1 -9.0 -> 1
|
||||
ddcms345 comparesig .8E+1 -9 -> 1
|
||||
ddcms346 comparesig 80E-1 -9 -> 1
|
||||
ddcms347 comparesig 8.0 -9E+0 -> 1
|
||||
ddcms348 comparesig 8.0 -90E-1 -> 1
|
||||
ddcms349 comparesig 8 -.9E+1 -> 1
|
||||
ddcms350 comparesig 8 -90E-1 -> 1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
ddcms400 comparesig -7.0 -7.0 -> 0
|
||||
ddcms401 comparesig -7.0 -7 -> 0
|
||||
ddcms402 comparesig -7 -7.0 -> 0
|
||||
ddcms403 comparesig -7E+0 -7.0 -> 0
|
||||
ddcms404 comparesig -70E-1 -7.0 -> 0
|
||||
ddcms405 comparesig -.7E+1 -7 -> 0
|
||||
ddcms406 comparesig -70E-1 -7 -> 0
|
||||
ddcms407 comparesig -7.0 -7E+0 -> 0
|
||||
ddcms408 comparesig -7.0 -70E-1 -> 0
|
||||
ddcms409 comparesig -7 -.7E+1 -> 0
|
||||
ddcms410 comparesig -7 -70E-1 -> 0
|
||||
|
||||
ddcms420 comparesig -8.0 -7.0 -> -1
|
||||
ddcms421 comparesig -8.0 -7 -> -1
|
||||
ddcms422 comparesig -8 -7.0 -> -1
|
||||
ddcms423 comparesig -8E+0 -7.0 -> -1
|
||||
ddcms424 comparesig -80E-1 -7.0 -> -1
|
||||
ddcms425 comparesig -.8E+1 -7 -> -1
|
||||
ddcms426 comparesig -80E-1 -7 -> -1
|
||||
ddcms427 comparesig -8.0 -7E+0 -> -1
|
||||
ddcms428 comparesig -8.0 -70E-1 -> -1
|
||||
ddcms429 comparesig -8 -.7E+1 -> -1
|
||||
ddcms430 comparesig -8 -70E-1 -> -1
|
||||
|
||||
ddcms440 comparesig -8.0 -9.0 -> 1
|
||||
ddcms441 comparesig -8.0 -9 -> 1
|
||||
ddcms442 comparesig -8 -9.0 -> 1
|
||||
ddcms443 comparesig -8E+0 -9.0 -> 1
|
||||
ddcms444 comparesig -80E-1 -9.0 -> 1
|
||||
ddcms445 comparesig -.8E+1 -9 -> 1
|
||||
ddcms446 comparesig -80E-1 -9 -> 1
|
||||
ddcms447 comparesig -8.0 -9E+0 -> 1
|
||||
ddcms448 comparesig -8.0 -90E-1 -> 1
|
||||
ddcms449 comparesig -8 -.9E+1 -> 1
|
||||
ddcms450 comparesig -8 -90E-1 -> 1
|
||||
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
|
||||
ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
|
||||
ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
|
||||
ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
|
||||
ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
|
||||
ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
|
||||
ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
|
||||
ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
|
||||
ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
|
||||
ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
|
||||
ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
|
||||
ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
|
||||
ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
|
||||
ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
|
||||
ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
|
||||
ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
|
||||
ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
|
||||
ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
|
||||
ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
|
||||
ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
|
||||
ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
|
||||
ddcms497 comparesig 123.456E+89 123.456E+89 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
ddcms500 comparesig 1 1E-15 -> 1
|
||||
ddcms501 comparesig 1 1E-14 -> 1
|
||||
ddcms502 comparesig 1 1E-13 -> 1
|
||||
ddcms503 comparesig 1 1E-12 -> 1
|
||||
ddcms504 comparesig 1 1E-11 -> 1
|
||||
ddcms505 comparesig 1 1E-10 -> 1
|
||||
ddcms506 comparesig 1 1E-9 -> 1
|
||||
ddcms507 comparesig 1 1E-8 -> 1
|
||||
ddcms508 comparesig 1 1E-7 -> 1
|
||||
ddcms509 comparesig 1 1E-6 -> 1
|
||||
ddcms510 comparesig 1 1E-5 -> 1
|
||||
ddcms511 comparesig 1 1E-4 -> 1
|
||||
ddcms512 comparesig 1 1E-3 -> 1
|
||||
ddcms513 comparesig 1 1E-2 -> 1
|
||||
ddcms514 comparesig 1 1E-1 -> 1
|
||||
ddcms515 comparesig 1 1E-0 -> 0
|
||||
ddcms516 comparesig 1 1E+1 -> -1
|
||||
ddcms517 comparesig 1 1E+2 -> -1
|
||||
ddcms518 comparesig 1 1E+3 -> -1
|
||||
ddcms519 comparesig 1 1E+4 -> -1
|
||||
ddcms521 comparesig 1 1E+5 -> -1
|
||||
ddcms522 comparesig 1 1E+6 -> -1
|
||||
ddcms523 comparesig 1 1E+7 -> -1
|
||||
ddcms524 comparesig 1 1E+8 -> -1
|
||||
ddcms525 comparesig 1 1E+9 -> -1
|
||||
ddcms526 comparesig 1 1E+10 -> -1
|
||||
ddcms527 comparesig 1 1E+11 -> -1
|
||||
ddcms528 comparesig 1 1E+12 -> -1
|
||||
ddcms529 comparesig 1 1E+13 -> -1
|
||||
ddcms530 comparesig 1 1E+14 -> -1
|
||||
ddcms531 comparesig 1 1E+15 -> -1
|
||||
-- LR swap
|
||||
ddcms540 comparesig 1E-15 1 -> -1
|
||||
ddcms541 comparesig 1E-14 1 -> -1
|
||||
ddcms542 comparesig 1E-13 1 -> -1
|
||||
ddcms543 comparesig 1E-12 1 -> -1
|
||||
ddcms544 comparesig 1E-11 1 -> -1
|
||||
ddcms545 comparesig 1E-10 1 -> -1
|
||||
ddcms546 comparesig 1E-9 1 -> -1
|
||||
ddcms547 comparesig 1E-8 1 -> -1
|
||||
ddcms548 comparesig 1E-7 1 -> -1
|
||||
ddcms549 comparesig 1E-6 1 -> -1
|
||||
ddcms550 comparesig 1E-5 1 -> -1
|
||||
ddcms551 comparesig 1E-4 1 -> -1
|
||||
ddcms552 comparesig 1E-3 1 -> -1
|
||||
ddcms553 comparesig 1E-2 1 -> -1
|
||||
ddcms554 comparesig 1E-1 1 -> -1
|
||||
ddcms555 comparesig 1E-0 1 -> 0
|
||||
ddcms556 comparesig 1E+1 1 -> 1
|
||||
ddcms557 comparesig 1E+2 1 -> 1
|
||||
ddcms558 comparesig 1E+3 1 -> 1
|
||||
ddcms559 comparesig 1E+4 1 -> 1
|
||||
ddcms561 comparesig 1E+5 1 -> 1
|
||||
ddcms562 comparesig 1E+6 1 -> 1
|
||||
ddcms563 comparesig 1E+7 1 -> 1
|
||||
ddcms564 comparesig 1E+8 1 -> 1
|
||||
ddcms565 comparesig 1E+9 1 -> 1
|
||||
ddcms566 comparesig 1E+10 1 -> 1
|
||||
ddcms567 comparesig 1E+11 1 -> 1
|
||||
ddcms568 comparesig 1E+12 1 -> 1
|
||||
ddcms569 comparesig 1E+13 1 -> 1
|
||||
ddcms570 comparesig 1E+14 1 -> 1
|
||||
ddcms571 comparesig 1E+15 1 -> 1
|
||||
-- similar with a useful coefficient, one side only
|
||||
ddcms580 comparesig 0.000000987654321 1E-15 -> 1
|
||||
ddcms581 comparesig 0.000000987654321 1E-14 -> 1
|
||||
ddcms582 comparesig 0.000000987654321 1E-13 -> 1
|
||||
ddcms583 comparesig 0.000000987654321 1E-12 -> 1
|
||||
ddcms584 comparesig 0.000000987654321 1E-11 -> 1
|
||||
ddcms585 comparesig 0.000000987654321 1E-10 -> 1
|
||||
ddcms586 comparesig 0.000000987654321 1E-9 -> 1
|
||||
ddcms587 comparesig 0.000000987654321 1E-8 -> 1
|
||||
ddcms588 comparesig 0.000000987654321 1E-7 -> 1
|
||||
ddcms589 comparesig 0.000000987654321 1E-6 -> -1
|
||||
ddcms590 comparesig 0.000000987654321 1E-5 -> -1
|
||||
ddcms591 comparesig 0.000000987654321 1E-4 -> -1
|
||||
ddcms592 comparesig 0.000000987654321 1E-3 -> -1
|
||||
ddcms593 comparesig 0.000000987654321 1E-2 -> -1
|
||||
ddcms594 comparesig 0.000000987654321 1E-1 -> -1
|
||||
ddcms595 comparesig 0.000000987654321 1E-0 -> -1
|
||||
ddcms596 comparesig 0.000000987654321 1E+1 -> -1
|
||||
ddcms597 comparesig 0.000000987654321 1E+2 -> -1
|
||||
ddcms598 comparesig 0.000000987654321 1E+3 -> -1
|
||||
ddcms599 comparesig 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
ddcms600 comparesig 12 12.2345 -> -1
|
||||
ddcms601 comparesig 12.0 12.2345 -> -1
|
||||
ddcms602 comparesig 12.00 12.2345 -> -1
|
||||
ddcms603 comparesig 12.000 12.2345 -> -1
|
||||
ddcms604 comparesig 12.0000 12.2345 -> -1
|
||||
ddcms605 comparesig 12.00000 12.2345 -> -1
|
||||
ddcms606 comparesig 12.000000 12.2345 -> -1
|
||||
ddcms607 comparesig 12.0000000 12.2345 -> -1
|
||||
ddcms608 comparesig 12.00000000 12.2345 -> -1
|
||||
ddcms609 comparesig 12.000000000 12.2345 -> -1
|
||||
ddcms610 comparesig 12.1234 12 -> 1
|
||||
ddcms611 comparesig 12.1234 12.0 -> 1
|
||||
ddcms612 comparesig 12.1234 12.00 -> 1
|
||||
ddcms613 comparesig 12.1234 12.000 -> 1
|
||||
ddcms614 comparesig 12.1234 12.0000 -> 1
|
||||
ddcms615 comparesig 12.1234 12.00000 -> 1
|
||||
ddcms616 comparesig 12.1234 12.000000 -> 1
|
||||
ddcms617 comparesig 12.1234 12.0000000 -> 1
|
||||
ddcms618 comparesig 12.1234 12.00000000 -> 1
|
||||
ddcms619 comparesig 12.1234 12.000000000 -> 1
|
||||
ddcms620 comparesig -12 -12.2345 -> 1
|
||||
ddcms621 comparesig -12.0 -12.2345 -> 1
|
||||
ddcms622 comparesig -12.00 -12.2345 -> 1
|
||||
ddcms623 comparesig -12.000 -12.2345 -> 1
|
||||
ddcms624 comparesig -12.0000 -12.2345 -> 1
|
||||
ddcms625 comparesig -12.00000 -12.2345 -> 1
|
||||
ddcms626 comparesig -12.000000 -12.2345 -> 1
|
||||
ddcms627 comparesig -12.0000000 -12.2345 -> 1
|
||||
ddcms628 comparesig -12.00000000 -12.2345 -> 1
|
||||
ddcms629 comparesig -12.000000000 -12.2345 -> 1
|
||||
ddcms630 comparesig -12.1234 -12 -> -1
|
||||
ddcms631 comparesig -12.1234 -12.0 -> -1
|
||||
ddcms632 comparesig -12.1234 -12.00 -> -1
|
||||
ddcms633 comparesig -12.1234 -12.000 -> -1
|
||||
ddcms634 comparesig -12.1234 -12.0000 -> -1
|
||||
ddcms635 comparesig -12.1234 -12.00000 -> -1
|
||||
ddcms636 comparesig -12.1234 -12.000000 -> -1
|
||||
ddcms637 comparesig -12.1234 -12.0000000 -> -1
|
||||
ddcms638 comparesig -12.1234 -12.00000000 -> -1
|
||||
ddcms639 comparesig -12.1234 -12.000000000 -> -1
|
||||
|
||||
-- extended zeros
|
||||
ddcms640 comparesig 0 0 -> 0
|
||||
ddcms641 comparesig 0 -0 -> 0
|
||||
ddcms642 comparesig 0 -0.0 -> 0
|
||||
ddcms643 comparesig 0 0.0 -> 0
|
||||
ddcms644 comparesig -0 0 -> 0
|
||||
ddcms645 comparesig -0 -0 -> 0
|
||||
ddcms646 comparesig -0 -0.0 -> 0
|
||||
ddcms647 comparesig -0 0.0 -> 0
|
||||
ddcms648 comparesig 0.0 0 -> 0
|
||||
ddcms649 comparesig 0.0 -0 -> 0
|
||||
ddcms650 comparesig 0.0 -0.0 -> 0
|
||||
ddcms651 comparesig 0.0 0.0 -> 0
|
||||
ddcms652 comparesig -0.0 0 -> 0
|
||||
ddcms653 comparesig -0.0 -0 -> 0
|
||||
ddcms654 comparesig -0.0 -0.0 -> 0
|
||||
ddcms655 comparesig -0.0 0.0 -> 0
|
||||
|
||||
ddcms656 comparesig -0E1 0.0 -> 0
|
||||
ddcms657 comparesig -0E2 0.0 -> 0
|
||||
ddcms658 comparesig 0E1 0.0 -> 0
|
||||
ddcms659 comparesig 0E2 0.0 -> 0
|
||||
ddcms660 comparesig -0E1 0 -> 0
|
||||
ddcms661 comparesig -0E2 0 -> 0
|
||||
ddcms662 comparesig 0E1 0 -> 0
|
||||
ddcms663 comparesig 0E2 0 -> 0
|
||||
ddcms664 comparesig -0E1 -0E1 -> 0
|
||||
ddcms665 comparesig -0E2 -0E1 -> 0
|
||||
ddcms666 comparesig 0E1 -0E1 -> 0
|
||||
ddcms667 comparesig 0E2 -0E1 -> 0
|
||||
ddcms668 comparesig -0E1 -0E2 -> 0
|
||||
ddcms669 comparesig -0E2 -0E2 -> 0
|
||||
ddcms670 comparesig 0E1 -0E2 -> 0
|
||||
ddcms671 comparesig 0E2 -0E2 -> 0
|
||||
ddcms672 comparesig -0E1 0E1 -> 0
|
||||
ddcms673 comparesig -0E2 0E1 -> 0
|
||||
ddcms674 comparesig 0E1 0E1 -> 0
|
||||
ddcms675 comparesig 0E2 0E1 -> 0
|
||||
ddcms676 comparesig -0E1 0E2 -> 0
|
||||
ddcms677 comparesig -0E2 0E2 -> 0
|
||||
ddcms678 comparesig 0E1 0E2 -> 0
|
||||
ddcms679 comparesig 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
ddcms680 comparesig 12 12 -> 0
|
||||
ddcms681 comparesig 12 12.0 -> 0
|
||||
ddcms682 comparesig 12 12.00 -> 0
|
||||
ddcms683 comparesig 12 12.000 -> 0
|
||||
ddcms684 comparesig 12 12.0000 -> 0
|
||||
ddcms685 comparesig 12 12.00000 -> 0
|
||||
ddcms686 comparesig 12 12.000000 -> 0
|
||||
ddcms687 comparesig 12 12.0000000 -> 0
|
||||
ddcms688 comparesig 12 12.00000000 -> 0
|
||||
ddcms689 comparesig 12 12.000000000 -> 0
|
||||
ddcms690 comparesig 12 12 -> 0
|
||||
ddcms691 comparesig 12.0 12 -> 0
|
||||
ddcms692 comparesig 12.00 12 -> 0
|
||||
ddcms693 comparesig 12.000 12 -> 0
|
||||
ddcms694 comparesig 12.0000 12 -> 0
|
||||
ddcms695 comparesig 12.00000 12 -> 0
|
||||
ddcms696 comparesig 12.000000 12 -> 0
|
||||
ddcms697 comparesig 12.0000000 12 -> 0
|
||||
ddcms698 comparesig 12.00000000 12 -> 0
|
||||
ddcms699 comparesig 12.000000000 12 -> 0
|
||||
|
||||
-- first, second, & last digit
|
||||
ddcms700 comparesig 1234567890123456 1234567890123455 -> 1
|
||||
ddcms701 comparesig 1234567890123456 1234567890123456 -> 0
|
||||
ddcms702 comparesig 1234567890123456 1234567890123457 -> -1
|
||||
ddcms703 comparesig 1234567890123456 0234567890123456 -> 1
|
||||
ddcms704 comparesig 1234567890123456 1234567890123456 -> 0
|
||||
ddcms705 comparesig 1234567890123456 2234567890123456 -> -1
|
||||
ddcms706 comparesig 1134567890123456 1034567890123456 -> 1
|
||||
ddcms707 comparesig 1134567890123456 1134567890123456 -> 0
|
||||
ddcms708 comparesig 1134567890123456 1234567890123456 -> -1
|
||||
|
||||
-- miscellaneous
|
||||
ddcms721 comparesig 12345678000 1 -> 1
|
||||
ddcms722 comparesig 1 12345678000 -> -1
|
||||
ddcms723 comparesig 1234567800 1 -> 1
|
||||
ddcms724 comparesig 1 1234567800 -> -1
|
||||
ddcms725 comparesig 1234567890 1 -> 1
|
||||
ddcms726 comparesig 1 1234567890 -> -1
|
||||
ddcms727 comparesig 1234567891 1 -> 1
|
||||
ddcms728 comparesig 1 1234567891 -> -1
|
||||
ddcms729 comparesig 12345678901 1 -> 1
|
||||
ddcms730 comparesig 1 12345678901 -> -1
|
||||
ddcms731 comparesig 1234567896 1 -> 1
|
||||
ddcms732 comparesig 1 1234567896 -> -1
|
||||
|
||||
-- residue cases at lower precision
|
||||
ddcms740 comparesig 1 0.9999999 -> 1
|
||||
ddcms741 comparesig 1 0.999999 -> 1
|
||||
ddcms742 comparesig 1 0.99999 -> 1
|
||||
ddcms743 comparesig 1 1.0000 -> 0
|
||||
ddcms744 comparesig 1 1.00001 -> -1
|
||||
ddcms745 comparesig 1 1.000001 -> -1
|
||||
ddcms746 comparesig 1 1.0000001 -> -1
|
||||
ddcms750 comparesig 0.9999999 1 -> -1
|
||||
ddcms751 comparesig 0.999999 1 -> -1
|
||||
ddcms752 comparesig 0.99999 1 -> -1
|
||||
ddcms753 comparesig 1.0000 1 -> 0
|
||||
ddcms754 comparesig 1.00001 1 -> 1
|
||||
ddcms755 comparesig 1.000001 1 -> 1
|
||||
ddcms756 comparesig 1.0000001 1 -> 1
|
||||
|
||||
-- Specials
|
||||
ddcms780 comparesig Inf -Inf -> 1
|
||||
ddcms781 comparesig Inf -1000 -> 1
|
||||
ddcms782 comparesig Inf -1 -> 1
|
||||
ddcms783 comparesig Inf -0 -> 1
|
||||
ddcms784 comparesig Inf 0 -> 1
|
||||
ddcms785 comparesig Inf 1 -> 1
|
||||
ddcms786 comparesig Inf 1000 -> 1
|
||||
ddcms787 comparesig Inf Inf -> 0
|
||||
ddcms788 comparesig -1000 Inf -> -1
|
||||
ddcms789 comparesig -Inf Inf -> -1
|
||||
ddcms790 comparesig -1 Inf -> -1
|
||||
ddcms791 comparesig -0 Inf -> -1
|
||||
ddcms792 comparesig 0 Inf -> -1
|
||||
ddcms793 comparesig 1 Inf -> -1
|
||||
ddcms794 comparesig 1000 Inf -> -1
|
||||
ddcms795 comparesig Inf Inf -> 0
|
||||
|
||||
ddcms800 comparesig -Inf -Inf -> 0
|
||||
ddcms801 comparesig -Inf -1000 -> -1
|
||||
ddcms802 comparesig -Inf -1 -> -1
|
||||
ddcms803 comparesig -Inf -0 -> -1
|
||||
ddcms804 comparesig -Inf 0 -> -1
|
||||
ddcms805 comparesig -Inf 1 -> -1
|
||||
ddcms806 comparesig -Inf 1000 -> -1
|
||||
ddcms807 comparesig -Inf Inf -> -1
|
||||
ddcms808 comparesig -Inf -Inf -> 0
|
||||
ddcms809 comparesig -1000 -Inf -> 1
|
||||
ddcms810 comparesig -1 -Inf -> 1
|
||||
ddcms811 comparesig -0 -Inf -> 1
|
||||
ddcms812 comparesig 0 -Inf -> 1
|
||||
ddcms813 comparesig 1 -Inf -> 1
|
||||
ddcms814 comparesig 1000 -Inf -> 1
|
||||
ddcms815 comparesig Inf -Inf -> 1
|
||||
|
||||
ddcms821 comparesig NaN -Inf -> NaN Invalid_operation
|
||||
ddcms822 comparesig NaN -1000 -> NaN Invalid_operation
|
||||
ddcms823 comparesig NaN -1 -> NaN Invalid_operation
|
||||
ddcms824 comparesig NaN -0 -> NaN Invalid_operation
|
||||
ddcms825 comparesig NaN 0 -> NaN Invalid_operation
|
||||
ddcms826 comparesig NaN 1 -> NaN Invalid_operation
|
||||
ddcms827 comparesig NaN 1000 -> NaN Invalid_operation
|
||||
ddcms828 comparesig NaN Inf -> NaN Invalid_operation
|
||||
ddcms829 comparesig NaN NaN -> NaN Invalid_operation
|
||||
ddcms830 comparesig -Inf NaN -> NaN Invalid_operation
|
||||
ddcms831 comparesig -1000 NaN -> NaN Invalid_operation
|
||||
ddcms832 comparesig -1 NaN -> NaN Invalid_operation
|
||||
ddcms833 comparesig -0 NaN -> NaN Invalid_operation
|
||||
ddcms834 comparesig 0 NaN -> NaN Invalid_operation
|
||||
ddcms835 comparesig 1 NaN -> NaN Invalid_operation
|
||||
ddcms836 comparesig 1000 NaN -> NaN Invalid_operation
|
||||
ddcms837 comparesig Inf NaN -> NaN Invalid_operation
|
||||
ddcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
|
||||
ddcms839 comparesig +NaN -NaN -> NaN Invalid_operation
|
||||
ddcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
|
||||
|
||||
ddcms841 comparesig sNaN -Inf -> NaN Invalid_operation
|
||||
ddcms842 comparesig sNaN -1000 -> NaN Invalid_operation
|
||||
ddcms843 comparesig sNaN -1 -> NaN Invalid_operation
|
||||
ddcms844 comparesig sNaN -0 -> NaN Invalid_operation
|
||||
ddcms845 comparesig sNaN 0 -> NaN Invalid_operation
|
||||
ddcms846 comparesig sNaN 1 -> NaN Invalid_operation
|
||||
ddcms847 comparesig sNaN 1000 -> NaN Invalid_operation
|
||||
ddcms848 comparesig sNaN NaN -> NaN Invalid_operation
|
||||
ddcms849 comparesig sNaN sNaN -> NaN Invalid_operation
|
||||
ddcms850 comparesig NaN sNaN -> NaN Invalid_operation
|
||||
ddcms851 comparesig -Inf sNaN -> NaN Invalid_operation
|
||||
ddcms852 comparesig -1000 sNaN -> NaN Invalid_operation
|
||||
ddcms853 comparesig -1 sNaN -> NaN Invalid_operation
|
||||
ddcms854 comparesig -0 sNaN -> NaN Invalid_operation
|
||||
ddcms855 comparesig 0 sNaN -> NaN Invalid_operation
|
||||
ddcms856 comparesig 1 sNaN -> NaN Invalid_operation
|
||||
ddcms857 comparesig 1000 sNaN -> NaN Invalid_operation
|
||||
ddcms858 comparesig Inf sNaN -> NaN Invalid_operation
|
||||
ddcms859 comparesig NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
|
||||
ddcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
|
||||
ddcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
|
||||
ddcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
|
||||
ddcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
|
||||
ddcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
|
||||
ddcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
|
||||
ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
|
||||
ddcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
|
||||
ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
|
||||
ddcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
|
||||
|
||||
ddcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
ddcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
|
||||
ddcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
|
||||
ddcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
|
||||
ddcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
|
||||
ddcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
|
||||
ddcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
|
||||
ddcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
|
||||
|
||||
-- wide range
|
||||
ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
|
||||
ddcms881 comparesig 9E+384 +1.23456789012345E-0 -> 1
|
||||
ddcms882 comparesig +0.100 9E-383 -> 1
|
||||
ddcms883 comparesig 9E-383 +0.100 -> -1
|
||||
ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
|
||||
ddcms886 comparesig 9E+384 -1.23456789012345E-0 -> 1
|
||||
ddcms887 comparesig -0.100 9E-383 -> -1
|
||||
ddcms888 comparesig 9E-383 -0.100 -> 1
|
||||
|
||||
-- signs
|
||||
ddcms901 comparesig 1e+77 1e+11 -> 1
|
||||
ddcms902 comparesig 1e+77 -1e+11 -> 1
|
||||
ddcms903 comparesig -1e+77 1e+11 -> -1
|
||||
ddcms904 comparesig -1e+77 -1e+11 -> -1
|
||||
ddcms905 comparesig 1e-77 1e-11 -> -1
|
||||
ddcms906 comparesig 1e-77 -1e-11 -> 1
|
||||
ddcms907 comparesig -1e-77 1e-11 -> -1
|
||||
ddcms908 comparesig -1e-77 -1e-11 -> 1
|
||||
|
||||
-- Null tests
|
||||
ddcms990 comparesig 10 # -> NaN Invalid_operation
|
||||
ddcms991 comparesig # 10 -> NaN Invalid_operation
|
@ -0,0 +1,706 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCompareTotal.decTest -- decDouble comparison using total ordering--
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
-- Similarly, comparetotal will have some radically different paths
|
||||
-- than compare.
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddcot001 comparetotal -2 -2 -> 0
|
||||
ddcot002 comparetotal -2 -1 -> -1
|
||||
ddcot003 comparetotal -2 0 -> -1
|
||||
ddcot004 comparetotal -2 1 -> -1
|
||||
ddcot005 comparetotal -2 2 -> -1
|
||||
ddcot006 comparetotal -1 -2 -> 1
|
||||
ddcot007 comparetotal -1 -1 -> 0
|
||||
ddcot008 comparetotal -1 0 -> -1
|
||||
ddcot009 comparetotal -1 1 -> -1
|
||||
ddcot010 comparetotal -1 2 -> -1
|
||||
ddcot011 comparetotal 0 -2 -> 1
|
||||
ddcot012 comparetotal 0 -1 -> 1
|
||||
ddcot013 comparetotal 0 0 -> 0
|
||||
ddcot014 comparetotal 0 1 -> -1
|
||||
ddcot015 comparetotal 0 2 -> -1
|
||||
ddcot016 comparetotal 1 -2 -> 1
|
||||
ddcot017 comparetotal 1 -1 -> 1
|
||||
ddcot018 comparetotal 1 0 -> 1
|
||||
ddcot019 comparetotal 1 1 -> 0
|
||||
ddcot020 comparetotal 1 2 -> -1
|
||||
ddcot021 comparetotal 2 -2 -> 1
|
||||
ddcot022 comparetotal 2 -1 -> 1
|
||||
ddcot023 comparetotal 2 0 -> 1
|
||||
ddcot025 comparetotal 2 1 -> 1
|
||||
ddcot026 comparetotal 2 2 -> 0
|
||||
|
||||
ddcot031 comparetotal -20 -20 -> 0
|
||||
ddcot032 comparetotal -20 -10 -> -1
|
||||
ddcot033 comparetotal -20 00 -> -1
|
||||
ddcot034 comparetotal -20 10 -> -1
|
||||
ddcot035 comparetotal -20 20 -> -1
|
||||
ddcot036 comparetotal -10 -20 -> 1
|
||||
ddcot037 comparetotal -10 -10 -> 0
|
||||
ddcot038 comparetotal -10 00 -> -1
|
||||
ddcot039 comparetotal -10 10 -> -1
|
||||
ddcot040 comparetotal -10 20 -> -1
|
||||
ddcot041 comparetotal 00 -20 -> 1
|
||||
ddcot042 comparetotal 00 -10 -> 1
|
||||
ddcot043 comparetotal 00 00 -> 0
|
||||
ddcot044 comparetotal 00 10 -> -1
|
||||
ddcot045 comparetotal 00 20 -> -1
|
||||
ddcot046 comparetotal 10 -20 -> 1
|
||||
ddcot047 comparetotal 10 -10 -> 1
|
||||
ddcot048 comparetotal 10 00 -> 1
|
||||
ddcot049 comparetotal 10 10 -> 0
|
||||
ddcot050 comparetotal 10 20 -> -1
|
||||
ddcot051 comparetotal 20 -20 -> 1
|
||||
ddcot052 comparetotal 20 -10 -> 1
|
||||
ddcot053 comparetotal 20 00 -> 1
|
||||
ddcot055 comparetotal 20 10 -> 1
|
||||
ddcot056 comparetotal 20 20 -> 0
|
||||
|
||||
ddcot061 comparetotal -2.0 -2.0 -> 0
|
||||
ddcot062 comparetotal -2.0 -1.0 -> -1
|
||||
ddcot063 comparetotal -2.0 0.0 -> -1
|
||||
ddcot064 comparetotal -2.0 1.0 -> -1
|
||||
ddcot065 comparetotal -2.0 2.0 -> -1
|
||||
ddcot066 comparetotal -1.0 -2.0 -> 1
|
||||
ddcot067 comparetotal -1.0 -1.0 -> 0
|
||||
ddcot068 comparetotal -1.0 0.0 -> -1
|
||||
ddcot069 comparetotal -1.0 1.0 -> -1
|
||||
ddcot070 comparetotal -1.0 2.0 -> -1
|
||||
ddcot071 comparetotal 0.0 -2.0 -> 1
|
||||
ddcot072 comparetotal 0.0 -1.0 -> 1
|
||||
ddcot073 comparetotal 0.0 0.0 -> 0
|
||||
ddcot074 comparetotal 0.0 1.0 -> -1
|
||||
ddcot075 comparetotal 0.0 2.0 -> -1
|
||||
ddcot076 comparetotal 1.0 -2.0 -> 1
|
||||
ddcot077 comparetotal 1.0 -1.0 -> 1
|
||||
ddcot078 comparetotal 1.0 0.0 -> 1
|
||||
ddcot079 comparetotal 1.0 1.0 -> 0
|
||||
ddcot080 comparetotal 1.0 2.0 -> -1
|
||||
ddcot081 comparetotal 2.0 -2.0 -> 1
|
||||
ddcot082 comparetotal 2.0 -1.0 -> 1
|
||||
ddcot083 comparetotal 2.0 0.0 -> 1
|
||||
ddcot085 comparetotal 2.0 1.0 -> 1
|
||||
ddcot086 comparetotal 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
ddcot090 comparetotal 9.99999999E+384 9.99999999E+384 -> 0
|
||||
ddcot091 comparetotal -9.99999999E+384 9.99999999E+384 -> -1
|
||||
ddcot092 comparetotal 9.99999999E+384 -9.99999999E+384 -> 1
|
||||
ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
-- in this first group, compare would compare all equal
|
||||
ddcot100 comparetotal 7.0 7.0 -> 0
|
||||
ddcot101 comparetotal 7.0 7 -> -1
|
||||
ddcot102 comparetotal 7 7.0 -> 1
|
||||
ddcot103 comparetotal 7E+0 7.0 -> 1
|
||||
ddcot104 comparetotal 70E-1 7.0 -> 0
|
||||
ddcot105 comparetotal 0.7E+1 7 -> 0
|
||||
ddcot106 comparetotal 70E-1 7 -> -1
|
||||
ddcot107 comparetotal 7.0 7E+0 -> -1
|
||||
ddcot108 comparetotal 7.0 70E-1 -> 0
|
||||
ddcot109 comparetotal 7 0.7E+1 -> 0
|
||||
ddcot110 comparetotal 7 70E-1 -> 1
|
||||
|
||||
ddcot120 comparetotal 8.0 7.0 -> 1
|
||||
ddcot121 comparetotal 8.0 7 -> 1
|
||||
ddcot122 comparetotal 8 7.0 -> 1
|
||||
ddcot123 comparetotal 8E+0 7.0 -> 1
|
||||
ddcot124 comparetotal 80E-1 7.0 -> 1
|
||||
ddcot125 comparetotal 0.8E+1 7 -> 1
|
||||
ddcot126 comparetotal 80E-1 7 -> 1
|
||||
ddcot127 comparetotal 8.0 7E+0 -> 1
|
||||
ddcot128 comparetotal 8.0 70E-1 -> 1
|
||||
ddcot129 comparetotal 8 0.7E+1 -> 1
|
||||
ddcot130 comparetotal 8 70E-1 -> 1
|
||||
|
||||
ddcot140 comparetotal 8.0 9.0 -> -1
|
||||
ddcot141 comparetotal 8.0 9 -> -1
|
||||
ddcot142 comparetotal 8 9.0 -> -1
|
||||
ddcot143 comparetotal 8E+0 9.0 -> -1
|
||||
ddcot144 comparetotal 80E-1 9.0 -> -1
|
||||
ddcot145 comparetotal 0.8E+1 9 -> -1
|
||||
ddcot146 comparetotal 80E-1 9 -> -1
|
||||
ddcot147 comparetotal 8.0 9E+0 -> -1
|
||||
ddcot148 comparetotal 8.0 90E-1 -> -1
|
||||
ddcot149 comparetotal 8 0.9E+1 -> -1
|
||||
ddcot150 comparetotal 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
ddcot200 comparetotal -7.0 7.0 -> -1
|
||||
ddcot201 comparetotal -7.0 7 -> -1
|
||||
ddcot202 comparetotal -7 7.0 -> -1
|
||||
ddcot203 comparetotal -7E+0 7.0 -> -1
|
||||
ddcot204 comparetotal -70E-1 7.0 -> -1
|
||||
ddcot205 comparetotal -0.7E+1 7 -> -1
|
||||
ddcot206 comparetotal -70E-1 7 -> -1
|
||||
ddcot207 comparetotal -7.0 7E+0 -> -1
|
||||
ddcot208 comparetotal -7.0 70E-1 -> -1
|
||||
ddcot209 comparetotal -7 0.7E+1 -> -1
|
||||
ddcot210 comparetotal -7 70E-1 -> -1
|
||||
|
||||
ddcot220 comparetotal -8.0 7.0 -> -1
|
||||
ddcot221 comparetotal -8.0 7 -> -1
|
||||
ddcot222 comparetotal -8 7.0 -> -1
|
||||
ddcot223 comparetotal -8E+0 7.0 -> -1
|
||||
ddcot224 comparetotal -80E-1 7.0 -> -1
|
||||
ddcot225 comparetotal -0.8E+1 7 -> -1
|
||||
ddcot226 comparetotal -80E-1 7 -> -1
|
||||
ddcot227 comparetotal -8.0 7E+0 -> -1
|
||||
ddcot228 comparetotal -8.0 70E-1 -> -1
|
||||
ddcot229 comparetotal -8 0.7E+1 -> -1
|
||||
ddcot230 comparetotal -8 70E-1 -> -1
|
||||
|
||||
ddcot240 comparetotal -8.0 9.0 -> -1
|
||||
ddcot241 comparetotal -8.0 9 -> -1
|
||||
ddcot242 comparetotal -8 9.0 -> -1
|
||||
ddcot243 comparetotal -8E+0 9.0 -> -1
|
||||
ddcot244 comparetotal -80E-1 9.0 -> -1
|
||||
ddcot245 comparetotal -0.8E+1 9 -> -1
|
||||
ddcot246 comparetotal -80E-1 9 -> -1
|
||||
ddcot247 comparetotal -8.0 9E+0 -> -1
|
||||
ddcot248 comparetotal -8.0 90E-1 -> -1
|
||||
ddcot249 comparetotal -8 0.9E+1 -> -1
|
||||
ddcot250 comparetotal -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
ddcot300 comparetotal 7.0 -7.0 -> 1
|
||||
ddcot301 comparetotal 7.0 -7 -> 1
|
||||
ddcot302 comparetotal 7 -7.0 -> 1
|
||||
ddcot303 comparetotal 7E+0 -7.0 -> 1
|
||||
ddcot304 comparetotal 70E-1 -7.0 -> 1
|
||||
ddcot305 comparetotal .7E+1 -7 -> 1
|
||||
ddcot306 comparetotal 70E-1 -7 -> 1
|
||||
ddcot307 comparetotal 7.0 -7E+0 -> 1
|
||||
ddcot308 comparetotal 7.0 -70E-1 -> 1
|
||||
ddcot309 comparetotal 7 -.7E+1 -> 1
|
||||
ddcot310 comparetotal 7 -70E-1 -> 1
|
||||
|
||||
ddcot320 comparetotal 8.0 -7.0 -> 1
|
||||
ddcot321 comparetotal 8.0 -7 -> 1
|
||||
ddcot322 comparetotal 8 -7.0 -> 1
|
||||
ddcot323 comparetotal 8E+0 -7.0 -> 1
|
||||
ddcot324 comparetotal 80E-1 -7.0 -> 1
|
||||
ddcot325 comparetotal .8E+1 -7 -> 1
|
||||
ddcot326 comparetotal 80E-1 -7 -> 1
|
||||
ddcot327 comparetotal 8.0 -7E+0 -> 1
|
||||
ddcot328 comparetotal 8.0 -70E-1 -> 1
|
||||
ddcot329 comparetotal 8 -.7E+1 -> 1
|
||||
ddcot330 comparetotal 8 -70E-1 -> 1
|
||||
|
||||
ddcot340 comparetotal 8.0 -9.0 -> 1
|
||||
ddcot341 comparetotal 8.0 -9 -> 1
|
||||
ddcot342 comparetotal 8 -9.0 -> 1
|
||||
ddcot343 comparetotal 8E+0 -9.0 -> 1
|
||||
ddcot344 comparetotal 80E-1 -9.0 -> 1
|
||||
ddcot345 comparetotal .8E+1 -9 -> 1
|
||||
ddcot346 comparetotal 80E-1 -9 -> 1
|
||||
ddcot347 comparetotal 8.0 -9E+0 -> 1
|
||||
ddcot348 comparetotal 8.0 -90E-1 -> 1
|
||||
ddcot349 comparetotal 8 -.9E+1 -> 1
|
||||
ddcot350 comparetotal 8 -90E-1 -> 1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
ddcot400 comparetotal -7.0 -7.0 -> 0
|
||||
ddcot401 comparetotal -7.0 -7 -> 1
|
||||
ddcot402 comparetotal -7 -7.0 -> -1
|
||||
ddcot403 comparetotal -7E+0 -7.0 -> -1
|
||||
ddcot404 comparetotal -70E-1 -7.0 -> 0
|
||||
ddcot405 comparetotal -.7E+1 -7 -> 0
|
||||
ddcot406 comparetotal -70E-1 -7 -> 1
|
||||
ddcot407 comparetotal -7.0 -7E+0 -> 1
|
||||
ddcot408 comparetotal -7.0 -70E-1 -> 0
|
||||
ddcot409 comparetotal -7 -.7E+1 -> 0
|
||||
ddcot410 comparetotal -7 -70E-1 -> -1
|
||||
|
||||
ddcot420 comparetotal -8.0 -7.0 -> -1
|
||||
ddcot421 comparetotal -8.0 -7 -> -1
|
||||
ddcot422 comparetotal -8 -7.0 -> -1
|
||||
ddcot423 comparetotal -8E+0 -7.0 -> -1
|
||||
ddcot424 comparetotal -80E-1 -7.0 -> -1
|
||||
ddcot425 comparetotal -.8E+1 -7 -> -1
|
||||
ddcot426 comparetotal -80E-1 -7 -> -1
|
||||
ddcot427 comparetotal -8.0 -7E+0 -> -1
|
||||
ddcot428 comparetotal -8.0 -70E-1 -> -1
|
||||
ddcot429 comparetotal -8 -.7E+1 -> -1
|
||||
ddcot430 comparetotal -8 -70E-1 -> -1
|
||||
|
||||
ddcot440 comparetotal -8.0 -9.0 -> 1
|
||||
ddcot441 comparetotal -8.0 -9 -> 1
|
||||
ddcot442 comparetotal -8 -9.0 -> 1
|
||||
ddcot443 comparetotal -8E+0 -9.0 -> 1
|
||||
ddcot444 comparetotal -80E-1 -9.0 -> 1
|
||||
ddcot445 comparetotal -.8E+1 -9 -> 1
|
||||
ddcot446 comparetotal -80E-1 -9 -> 1
|
||||
ddcot447 comparetotal -8.0 -9E+0 -> 1
|
||||
ddcot448 comparetotal -8.0 -90E-1 -> 1
|
||||
ddcot449 comparetotal -8 -.9E+1 -> 1
|
||||
ddcot450 comparetotal -8 -90E-1 -> 1
|
||||
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
|
||||
ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
|
||||
ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
|
||||
ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
|
||||
ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
|
||||
ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
|
||||
ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
|
||||
ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
|
||||
ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
|
||||
ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
|
||||
ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
|
||||
ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
|
||||
ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
|
||||
ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
|
||||
ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
|
||||
ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
|
||||
ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
|
||||
ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
|
||||
ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
|
||||
ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
|
||||
ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
|
||||
ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
ddcot498 comparetotal 1 1E-17 -> 1
|
||||
ddcot499 comparetotal 1 1E-16 -> 1
|
||||
ddcot500 comparetotal 1 1E-15 -> 1
|
||||
ddcot501 comparetotal 1 1E-14 -> 1
|
||||
ddcot502 comparetotal 1 1E-13 -> 1
|
||||
ddcot503 comparetotal 1 1E-12 -> 1
|
||||
ddcot504 comparetotal 1 1E-11 -> 1
|
||||
ddcot505 comparetotal 1 1E-10 -> 1
|
||||
ddcot506 comparetotal 1 1E-9 -> 1
|
||||
ddcot507 comparetotal 1 1E-8 -> 1
|
||||
ddcot508 comparetotal 1 1E-7 -> 1
|
||||
ddcot509 comparetotal 1 1E-6 -> 1
|
||||
ddcot510 comparetotal 1 1E-5 -> 1
|
||||
ddcot511 comparetotal 1 1E-4 -> 1
|
||||
ddcot512 comparetotal 1 1E-3 -> 1
|
||||
ddcot513 comparetotal 1 1E-2 -> 1
|
||||
ddcot514 comparetotal 1 1E-1 -> 1
|
||||
ddcot515 comparetotal 1 1E-0 -> 0
|
||||
ddcot516 comparetotal 1 1E+1 -> -1
|
||||
ddcot517 comparetotal 1 1E+2 -> -1
|
||||
ddcot518 comparetotal 1 1E+3 -> -1
|
||||
ddcot519 comparetotal 1 1E+4 -> -1
|
||||
ddcot521 comparetotal 1 1E+5 -> -1
|
||||
ddcot522 comparetotal 1 1E+6 -> -1
|
||||
ddcot523 comparetotal 1 1E+7 -> -1
|
||||
ddcot524 comparetotal 1 1E+8 -> -1
|
||||
ddcot525 comparetotal 1 1E+9 -> -1
|
||||
ddcot526 comparetotal 1 1E+10 -> -1
|
||||
ddcot527 comparetotal 1 1E+11 -> -1
|
||||
ddcot528 comparetotal 1 1E+12 -> -1
|
||||
ddcot529 comparetotal 1 1E+13 -> -1
|
||||
ddcot530 comparetotal 1 1E+14 -> -1
|
||||
ddcot531 comparetotal 1 1E+15 -> -1
|
||||
ddcot532 comparetotal 1 1E+16 -> -1
|
||||
ddcot533 comparetotal 1 1E+17 -> -1
|
||||
-- LR swap
|
||||
ddcot538 comparetotal 1E-17 1 -> -1
|
||||
ddcot539 comparetotal 1E-16 1 -> -1
|
||||
ddcot540 comparetotal 1E-15 1 -> -1
|
||||
ddcot541 comparetotal 1E-14 1 -> -1
|
||||
ddcot542 comparetotal 1E-13 1 -> -1
|
||||
ddcot543 comparetotal 1E-12 1 -> -1
|
||||
ddcot544 comparetotal 1E-11 1 -> -1
|
||||
ddcot545 comparetotal 1E-10 1 -> -1
|
||||
ddcot546 comparetotal 1E-9 1 -> -1
|
||||
ddcot547 comparetotal 1E-8 1 -> -1
|
||||
ddcot548 comparetotal 1E-7 1 -> -1
|
||||
ddcot549 comparetotal 1E-6 1 -> -1
|
||||
ddcot550 comparetotal 1E-5 1 -> -1
|
||||
ddcot551 comparetotal 1E-4 1 -> -1
|
||||
ddcot552 comparetotal 1E-3 1 -> -1
|
||||
ddcot553 comparetotal 1E-2 1 -> -1
|
||||
ddcot554 comparetotal 1E-1 1 -> -1
|
||||
ddcot555 comparetotal 1E-0 1 -> 0
|
||||
ddcot556 comparetotal 1E+1 1 -> 1
|
||||
ddcot557 comparetotal 1E+2 1 -> 1
|
||||
ddcot558 comparetotal 1E+3 1 -> 1
|
||||
ddcot559 comparetotal 1E+4 1 -> 1
|
||||
ddcot561 comparetotal 1E+5 1 -> 1
|
||||
ddcot562 comparetotal 1E+6 1 -> 1
|
||||
ddcot563 comparetotal 1E+7 1 -> 1
|
||||
ddcot564 comparetotal 1E+8 1 -> 1
|
||||
ddcot565 comparetotal 1E+9 1 -> 1
|
||||
ddcot566 comparetotal 1E+10 1 -> 1
|
||||
ddcot567 comparetotal 1E+11 1 -> 1
|
||||
ddcot568 comparetotal 1E+12 1 -> 1
|
||||
ddcot569 comparetotal 1E+13 1 -> 1
|
||||
ddcot570 comparetotal 1E+14 1 -> 1
|
||||
ddcot571 comparetotal 1E+15 1 -> 1
|
||||
ddcot572 comparetotal 1E+16 1 -> 1
|
||||
ddcot573 comparetotal 1E+17 1 -> 1
|
||||
-- similar with a useful coefficient, one side only
|
||||
ddcot578 comparetotal 0.000000987654321 1E-17 -> 1
|
||||
ddcot579 comparetotal 0.000000987654321 1E-16 -> 1
|
||||
ddcot580 comparetotal 0.000000987654321 1E-15 -> 1
|
||||
ddcot581 comparetotal 0.000000987654321 1E-14 -> 1
|
||||
ddcot582 comparetotal 0.000000987654321 1E-13 -> 1
|
||||
ddcot583 comparetotal 0.000000987654321 1E-12 -> 1
|
||||
ddcot584 comparetotal 0.000000987654321 1E-11 -> 1
|
||||
ddcot585 comparetotal 0.000000987654321 1E-10 -> 1
|
||||
ddcot586 comparetotal 0.000000987654321 1E-9 -> 1
|
||||
ddcot587 comparetotal 0.000000987654321 1E-8 -> 1
|
||||
ddcot588 comparetotal 0.000000987654321 1E-7 -> 1
|
||||
ddcot589 comparetotal 0.000000987654321 1E-6 -> -1
|
||||
ddcot590 comparetotal 0.000000987654321 1E-5 -> -1
|
||||
ddcot591 comparetotal 0.000000987654321 1E-4 -> -1
|
||||
ddcot592 comparetotal 0.000000987654321 1E-3 -> -1
|
||||
ddcot593 comparetotal 0.000000987654321 1E-2 -> -1
|
||||
ddcot594 comparetotal 0.000000987654321 1E-1 -> -1
|
||||
ddcot595 comparetotal 0.000000987654321 1E-0 -> -1
|
||||
ddcot596 comparetotal 0.000000987654321 1E+1 -> -1
|
||||
ddcot597 comparetotal 0.000000987654321 1E+2 -> -1
|
||||
ddcot598 comparetotal 0.000000987654321 1E+3 -> -1
|
||||
ddcot599 comparetotal 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
ddcot600 comparetotal 12 12.2345 -> -1
|
||||
ddcot601 comparetotal 12.0 12.2345 -> -1
|
||||
ddcot602 comparetotal 12.00 12.2345 -> -1
|
||||
ddcot603 comparetotal 12.000 12.2345 -> -1
|
||||
ddcot604 comparetotal 12.0000 12.2345 -> -1
|
||||
ddcot605 comparetotal 12.00000 12.2345 -> -1
|
||||
ddcot606 comparetotal 12.000000 12.2345 -> -1
|
||||
ddcot607 comparetotal 12.0000000 12.2345 -> -1
|
||||
ddcot608 comparetotal 12.00000000 12.2345 -> -1
|
||||
ddcot609 comparetotal 12.000000000 12.2345 -> -1
|
||||
ddcot610 comparetotal 12.1234 12 -> 1
|
||||
ddcot611 comparetotal 12.1234 12.0 -> 1
|
||||
ddcot612 comparetotal 12.1234 12.00 -> 1
|
||||
ddcot613 comparetotal 12.1234 12.000 -> 1
|
||||
ddcot614 comparetotal 12.1234 12.0000 -> 1
|
||||
ddcot615 comparetotal 12.1234 12.00000 -> 1
|
||||
ddcot616 comparetotal 12.1234 12.000000 -> 1
|
||||
ddcot617 comparetotal 12.1234 12.0000000 -> 1
|
||||
ddcot618 comparetotal 12.1234 12.00000000 -> 1
|
||||
ddcot619 comparetotal 12.1234 12.000000000 -> 1
|
||||
ddcot620 comparetotal -12 -12.2345 -> 1
|
||||
ddcot621 comparetotal -12.0 -12.2345 -> 1
|
||||
ddcot622 comparetotal -12.00 -12.2345 -> 1
|
||||
ddcot623 comparetotal -12.000 -12.2345 -> 1
|
||||
ddcot624 comparetotal -12.0000 -12.2345 -> 1
|
||||
ddcot625 comparetotal -12.00000 -12.2345 -> 1
|
||||
ddcot626 comparetotal -12.000000 -12.2345 -> 1
|
||||
ddcot627 comparetotal -12.0000000 -12.2345 -> 1
|
||||
ddcot628 comparetotal -12.00000000 -12.2345 -> 1
|
||||
ddcot629 comparetotal -12.000000000 -12.2345 -> 1
|
||||
ddcot630 comparetotal -12.1234 -12 -> -1
|
||||
ddcot631 comparetotal -12.1234 -12.0 -> -1
|
||||
ddcot632 comparetotal -12.1234 -12.00 -> -1
|
||||
ddcot633 comparetotal -12.1234 -12.000 -> -1
|
||||
ddcot634 comparetotal -12.1234 -12.0000 -> -1
|
||||
ddcot635 comparetotal -12.1234 -12.00000 -> -1
|
||||
ddcot636 comparetotal -12.1234 -12.000000 -> -1
|
||||
ddcot637 comparetotal -12.1234 -12.0000000 -> -1
|
||||
ddcot638 comparetotal -12.1234 -12.00000000 -> -1
|
||||
ddcot639 comparetotal -12.1234 -12.000000000 -> -1
|
||||
|
||||
-- extended zeros
|
||||
ddcot640 comparetotal 0 0 -> 0
|
||||
ddcot641 comparetotal 0 -0 -> 1
|
||||
ddcot642 comparetotal 0 -0.0 -> 1
|
||||
ddcot643 comparetotal 0 0.0 -> 1
|
||||
ddcot644 comparetotal -0 0 -> -1
|
||||
ddcot645 comparetotal -0 -0 -> 0
|
||||
ddcot646 comparetotal -0 -0.0 -> -1
|
||||
ddcot647 comparetotal -0 0.0 -> -1
|
||||
ddcot648 comparetotal 0.0 0 -> -1
|
||||
ddcot649 comparetotal 0.0 -0 -> 1
|
||||
ddcot650 comparetotal 0.0 -0.0 -> 1
|
||||
ddcot651 comparetotal 0.0 0.0 -> 0
|
||||
ddcot652 comparetotal -0.0 0 -> -1
|
||||
ddcot653 comparetotal -0.0 -0 -> 1
|
||||
ddcot654 comparetotal -0.0 -0.0 -> 0
|
||||
ddcot655 comparetotal -0.0 0.0 -> -1
|
||||
|
||||
ddcot656 comparetotal -0E1 0.0 -> -1
|
||||
ddcot657 comparetotal -0E2 0.0 -> -1
|
||||
ddcot658 comparetotal 0E1 0.0 -> 1
|
||||
ddcot659 comparetotal 0E2 0.0 -> 1
|
||||
ddcot660 comparetotal -0E1 0 -> -1
|
||||
ddcot661 comparetotal -0E2 0 -> -1
|
||||
ddcot662 comparetotal 0E1 0 -> 1
|
||||
ddcot663 comparetotal 0E2 0 -> 1
|
||||
ddcot664 comparetotal -0E1 -0E1 -> 0
|
||||
ddcot665 comparetotal -0E2 -0E1 -> -1
|
||||
ddcot666 comparetotal 0E1 -0E1 -> 1
|
||||
ddcot667 comparetotal 0E2 -0E1 -> 1
|
||||
ddcot668 comparetotal -0E1 -0E2 -> 1
|
||||
ddcot669 comparetotal -0E2 -0E2 -> 0
|
||||
ddcot670 comparetotal 0E1 -0E2 -> 1
|
||||
ddcot671 comparetotal 0E2 -0E2 -> 1
|
||||
ddcot672 comparetotal -0E1 0E1 -> -1
|
||||
ddcot673 comparetotal -0E2 0E1 -> -1
|
||||
ddcot674 comparetotal 0E1 0E1 -> 0
|
||||
ddcot675 comparetotal 0E2 0E1 -> 1
|
||||
ddcot676 comparetotal -0E1 0E2 -> -1
|
||||
ddcot677 comparetotal -0E2 0E2 -> -1
|
||||
ddcot678 comparetotal 0E1 0E2 -> -1
|
||||
ddcot679 comparetotal 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
ddcot680 comparetotal 12 12 -> 0
|
||||
ddcot681 comparetotal 12 12.0 -> 1
|
||||
ddcot682 comparetotal 12 12.00 -> 1
|
||||
ddcot683 comparetotal 12 12.000 -> 1
|
||||
ddcot684 comparetotal 12 12.0000 -> 1
|
||||
ddcot685 comparetotal 12 12.00000 -> 1
|
||||
ddcot686 comparetotal 12 12.000000 -> 1
|
||||
ddcot687 comparetotal 12 12.0000000 -> 1
|
||||
ddcot688 comparetotal 12 12.00000000 -> 1
|
||||
ddcot689 comparetotal 12 12.000000000 -> 1
|
||||
ddcot690 comparetotal 12 12 -> 0
|
||||
ddcot691 comparetotal 12.0 12 -> -1
|
||||
ddcot692 comparetotal 12.00 12 -> -1
|
||||
ddcot693 comparetotal 12.000 12 -> -1
|
||||
ddcot694 comparetotal 12.0000 12 -> -1
|
||||
ddcot695 comparetotal 12.00000 12 -> -1
|
||||
ddcot696 comparetotal 12.000000 12 -> -1
|
||||
ddcot697 comparetotal 12.0000000 12 -> -1
|
||||
ddcot698 comparetotal 12.00000000 12 -> -1
|
||||
ddcot699 comparetotal 12.000000000 12 -> -1
|
||||
|
||||
-- old long operand checks
|
||||
ddcot701 comparetotal 12345678000 1 -> 1
|
||||
ddcot702 comparetotal 1 12345678000 -> -1
|
||||
ddcot703 comparetotal 1234567800 1 -> 1
|
||||
ddcot704 comparetotal 1 1234567800 -> -1
|
||||
ddcot705 comparetotal 1234567890 1 -> 1
|
||||
ddcot706 comparetotal 1 1234567890 -> -1
|
||||
ddcot707 comparetotal 1234567891 1 -> 1
|
||||
ddcot708 comparetotal 1 1234567891 -> -1
|
||||
ddcot709 comparetotal 12345678901 1 -> 1
|
||||
ddcot710 comparetotal 1 12345678901 -> -1
|
||||
ddcot711 comparetotal 1234567896 1 -> 1
|
||||
ddcot712 comparetotal 1 1234567896 -> -1
|
||||
ddcot713 comparetotal -1234567891 1 -> -1
|
||||
ddcot714 comparetotal 1 -1234567891 -> 1
|
||||
ddcot715 comparetotal -12345678901 1 -> -1
|
||||
ddcot716 comparetotal 1 -12345678901 -> 1
|
||||
ddcot717 comparetotal -1234567896 1 -> -1
|
||||
ddcot718 comparetotal 1 -1234567896 -> 1
|
||||
|
||||
-- old residue cases
|
||||
ddcot740 comparetotal 1 0.9999999 -> 1
|
||||
ddcot741 comparetotal 1 0.999999 -> 1
|
||||
ddcot742 comparetotal 1 0.99999 -> 1
|
||||
ddcot743 comparetotal 1 1.0000 -> 1
|
||||
ddcot744 comparetotal 1 1.00001 -> -1
|
||||
ddcot745 comparetotal 1 1.000001 -> -1
|
||||
ddcot746 comparetotal 1 1.0000001 -> -1
|
||||
ddcot750 comparetotal 0.9999999 1 -> -1
|
||||
ddcot751 comparetotal 0.999999 1 -> -1
|
||||
ddcot752 comparetotal 0.99999 1 -> -1
|
||||
ddcot753 comparetotal 1.0000 1 -> -1
|
||||
ddcot754 comparetotal 1.00001 1 -> 1
|
||||
ddcot755 comparetotal 1.000001 1 -> 1
|
||||
ddcot756 comparetotal 1.0000001 1 -> 1
|
||||
|
||||
-- Specials
|
||||
ddcot780 comparetotal Inf -Inf -> 1
|
||||
ddcot781 comparetotal Inf -1000 -> 1
|
||||
ddcot782 comparetotal Inf -1 -> 1
|
||||
ddcot783 comparetotal Inf -0 -> 1
|
||||
ddcot784 comparetotal Inf 0 -> 1
|
||||
ddcot785 comparetotal Inf 1 -> 1
|
||||
ddcot786 comparetotal Inf 1000 -> 1
|
||||
ddcot787 comparetotal Inf Inf -> 0
|
||||
ddcot788 comparetotal -1000 Inf -> -1
|
||||
ddcot789 comparetotal -Inf Inf -> -1
|
||||
ddcot790 comparetotal -1 Inf -> -1
|
||||
ddcot791 comparetotal -0 Inf -> -1
|
||||
ddcot792 comparetotal 0 Inf -> -1
|
||||
ddcot793 comparetotal 1 Inf -> -1
|
||||
ddcot794 comparetotal 1000 Inf -> -1
|
||||
ddcot795 comparetotal Inf Inf -> 0
|
||||
|
||||
ddcot800 comparetotal -Inf -Inf -> 0
|
||||
ddcot801 comparetotal -Inf -1000 -> -1
|
||||
ddcot802 comparetotal -Inf -1 -> -1
|
||||
ddcot803 comparetotal -Inf -0 -> -1
|
||||
ddcot804 comparetotal -Inf 0 -> -1
|
||||
ddcot805 comparetotal -Inf 1 -> -1
|
||||
ddcot806 comparetotal -Inf 1000 -> -1
|
||||
ddcot807 comparetotal -Inf Inf -> -1
|
||||
ddcot808 comparetotal -Inf -Inf -> 0
|
||||
ddcot809 comparetotal -1000 -Inf -> 1
|
||||
ddcot810 comparetotal -1 -Inf -> 1
|
||||
ddcot811 comparetotal -0 -Inf -> 1
|
||||
ddcot812 comparetotal 0 -Inf -> 1
|
||||
ddcot813 comparetotal 1 -Inf -> 1
|
||||
ddcot814 comparetotal 1000 -Inf -> 1
|
||||
ddcot815 comparetotal Inf -Inf -> 1
|
||||
|
||||
ddcot821 comparetotal NaN -Inf -> 1
|
||||
ddcot822 comparetotal NaN -1000 -> 1
|
||||
ddcot823 comparetotal NaN -1 -> 1
|
||||
ddcot824 comparetotal NaN -0 -> 1
|
||||
ddcot825 comparetotal NaN 0 -> 1
|
||||
ddcot826 comparetotal NaN 1 -> 1
|
||||
ddcot827 comparetotal NaN 1000 -> 1
|
||||
ddcot828 comparetotal NaN Inf -> 1
|
||||
ddcot829 comparetotal NaN NaN -> 0
|
||||
ddcot830 comparetotal -Inf NaN -> -1
|
||||
ddcot831 comparetotal -1000 NaN -> -1
|
||||
ddcot832 comparetotal -1 NaN -> -1
|
||||
ddcot833 comparetotal -0 NaN -> -1
|
||||
ddcot834 comparetotal 0 NaN -> -1
|
||||
ddcot835 comparetotal 1 NaN -> -1
|
||||
ddcot836 comparetotal 1000 NaN -> -1
|
||||
ddcot837 comparetotal Inf NaN -> -1
|
||||
ddcot838 comparetotal -NaN -NaN -> 0
|
||||
ddcot839 comparetotal +NaN -NaN -> 1
|
||||
ddcot840 comparetotal -NaN +NaN -> -1
|
||||
|
||||
ddcot841 comparetotal sNaN -sNaN -> 1
|
||||
ddcot842 comparetotal sNaN -NaN -> 1
|
||||
ddcot843 comparetotal sNaN -Inf -> 1
|
||||
ddcot844 comparetotal sNaN -1000 -> 1
|
||||
ddcot845 comparetotal sNaN -1 -> 1
|
||||
ddcot846 comparetotal sNaN -0 -> 1
|
||||
ddcot847 comparetotal sNaN 0 -> 1
|
||||
ddcot848 comparetotal sNaN 1 -> 1
|
||||
ddcot849 comparetotal sNaN 1000 -> 1
|
||||
ddcot850 comparetotal sNaN NaN -> -1
|
||||
ddcot851 comparetotal sNaN sNaN -> 0
|
||||
|
||||
ddcot852 comparetotal -sNaN sNaN -> -1
|
||||
ddcot853 comparetotal -NaN sNaN -> -1
|
||||
ddcot854 comparetotal -Inf sNaN -> -1
|
||||
ddcot855 comparetotal -1000 sNaN -> -1
|
||||
ddcot856 comparetotal -1 sNaN -> -1
|
||||
ddcot857 comparetotal -0 sNaN -> -1
|
||||
ddcot858 comparetotal 0 sNaN -> -1
|
||||
ddcot859 comparetotal 1 sNaN -> -1
|
||||
ddcot860 comparetotal 1000 sNaN -> -1
|
||||
ddcot861 comparetotal Inf sNaN -> -1
|
||||
ddcot862 comparetotal NaN sNaN -> 1
|
||||
ddcot863 comparetotal sNaN sNaN -> 0
|
||||
|
||||
ddcot871 comparetotal -sNaN -sNaN -> 0
|
||||
ddcot872 comparetotal -sNaN -NaN -> 1
|
||||
ddcot873 comparetotal -sNaN -Inf -> -1
|
||||
ddcot874 comparetotal -sNaN -1000 -> -1
|
||||
ddcot875 comparetotal -sNaN -1 -> -1
|
||||
ddcot876 comparetotal -sNaN -0 -> -1
|
||||
ddcot877 comparetotal -sNaN 0 -> -1
|
||||
ddcot878 comparetotal -sNaN 1 -> -1
|
||||
ddcot879 comparetotal -sNaN 1000 -> -1
|
||||
ddcot880 comparetotal -sNaN NaN -> -1
|
||||
ddcot881 comparetotal -sNaN sNaN -> -1
|
||||
|
||||
ddcot882 comparetotal -sNaN -sNaN -> 0
|
||||
ddcot883 comparetotal -NaN -sNaN -> -1
|
||||
ddcot884 comparetotal -Inf -sNaN -> 1
|
||||
ddcot885 comparetotal -1000 -sNaN -> 1
|
||||
ddcot886 comparetotal -1 -sNaN -> 1
|
||||
ddcot887 comparetotal -0 -sNaN -> 1
|
||||
ddcot888 comparetotal 0 -sNaN -> 1
|
||||
ddcot889 comparetotal 1 -sNaN -> 1
|
||||
ddcot890 comparetotal 1000 -sNaN -> 1
|
||||
ddcot891 comparetotal Inf -sNaN -> 1
|
||||
ddcot892 comparetotal NaN -sNaN -> 1
|
||||
ddcot893 comparetotal sNaN -sNaN -> 1
|
||||
|
||||
-- NaNs with payload
|
||||
ddcot960 comparetotal NaN9 -Inf -> 1
|
||||
ddcot961 comparetotal NaN8 999 -> 1
|
||||
ddcot962 comparetotal NaN77 Inf -> 1
|
||||
ddcot963 comparetotal -NaN67 NaN5 -> -1
|
||||
ddcot964 comparetotal -Inf -NaN4 -> 1
|
||||
ddcot965 comparetotal -999 -NaN33 -> 1
|
||||
ddcot966 comparetotal Inf NaN2 -> -1
|
||||
|
||||
ddcot970 comparetotal -NaN41 -NaN42 -> 1
|
||||
ddcot971 comparetotal +NaN41 -NaN42 -> 1
|
||||
ddcot972 comparetotal -NaN41 +NaN42 -> -1
|
||||
ddcot973 comparetotal +NaN41 +NaN42 -> -1
|
||||
ddcot974 comparetotal -NaN42 -NaN01 -> -1
|
||||
ddcot975 comparetotal +NaN42 -NaN01 -> 1
|
||||
ddcot976 comparetotal -NaN42 +NaN01 -> -1
|
||||
ddcot977 comparetotal +NaN42 +NaN01 -> 1
|
||||
|
||||
ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
|
||||
ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
|
||||
ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
|
||||
ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
|
||||
ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
|
||||
ddcot985 comparetotal +sNaN772 -sNaN771 -> 1
|
||||
ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
|
||||
ddcot987 comparetotal +sNaN772 +sNaN771 -> 1
|
||||
|
||||
ddcot991 comparetotal -sNaN99 -Inf -> -1
|
||||
ddcot992 comparetotal sNaN98 -11 -> 1
|
||||
ddcot993 comparetotal sNaN97 NaN -> -1
|
||||
ddcot994 comparetotal sNaN16 sNaN94 -> -1
|
||||
ddcot995 comparetotal NaN85 sNaN83 -> 1
|
||||
ddcot996 comparetotal -Inf sNaN92 -> -1
|
||||
ddcot997 comparetotal 088 sNaN81 -> -1
|
||||
ddcot998 comparetotal Inf sNaN90 -> -1
|
||||
ddcot999 comparetotal NaN -sNaN89 -> 1
|
||||
|
||||
-- spread zeros
|
||||
ddcot1110 comparetotal 0E-383 0 -> -1
|
||||
ddcot1111 comparetotal 0E-383 -0 -> 1
|
||||
ddcot1112 comparetotal -0E-383 0 -> -1
|
||||
ddcot1113 comparetotal -0E-383 -0 -> 1
|
||||
ddcot1114 comparetotal 0E-383 0E+384 -> -1
|
||||
ddcot1115 comparetotal 0E-383 -0E+384 -> 1
|
||||
ddcot1116 comparetotal -0E-383 0E+384 -> -1
|
||||
ddcot1117 comparetotal -0E-383 -0E+384 -> 1
|
||||
ddcot1118 comparetotal 0 0E+384 -> -1
|
||||
ddcot1119 comparetotal 0 -0E+384 -> 1
|
||||
ddcot1120 comparetotal -0 0E+384 -> -1
|
||||
ddcot1121 comparetotal -0 -0E+384 -> 1
|
||||
|
||||
ddcot1130 comparetotal 0E+384 0 -> 1
|
||||
ddcot1131 comparetotal 0E+384 -0 -> 1
|
||||
ddcot1132 comparetotal -0E+384 0 -> -1
|
||||
ddcot1133 comparetotal -0E+384 -0 -> -1
|
||||
ddcot1134 comparetotal 0E+384 0E-383 -> 1
|
||||
ddcot1135 comparetotal 0E+384 -0E-383 -> 1
|
||||
ddcot1136 comparetotal -0E+384 0E-383 -> -1
|
||||
ddcot1137 comparetotal -0E+384 -0E-383 -> -1
|
||||
ddcot1138 comparetotal 0 0E-383 -> 1
|
||||
ddcot1139 comparetotal 0 -0E-383 -> 1
|
||||
ddcot1140 comparetotal -0 0E-383 -> -1
|
||||
ddcot1141 comparetotal -0 -0E-383 -> -1
|
||||
|
||||
-- Null tests
|
||||
ddcot9990 comparetotal 10 # -> NaN Invalid_operation
|
||||
ddcot9991 comparetotal # 10 -> NaN Invalid_operation
|
@ -0,0 +1,706 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- Note that we cannot assume add/subtract tests cover paths adequately,
|
||||
-- here, because the code might be quite different (comparison cannot
|
||||
-- overflow or underflow, so actual subtractions are not necessary).
|
||||
-- Similarly, comparetotal will have some radically different paths
|
||||
-- than compare.
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddctm001 comparetotmag -2 -2 -> 0
|
||||
ddctm002 comparetotmag -2 -1 -> 1
|
||||
ddctm003 comparetotmag -2 0 -> 1
|
||||
ddctm004 comparetotmag -2 1 -> 1
|
||||
ddctm005 comparetotmag -2 2 -> 0
|
||||
ddctm006 comparetotmag -1 -2 -> -1
|
||||
ddctm007 comparetotmag -1 -1 -> 0
|
||||
ddctm008 comparetotmag -1 0 -> 1
|
||||
ddctm009 comparetotmag -1 1 -> 0
|
||||
ddctm010 comparetotmag -1 2 -> -1
|
||||
ddctm011 comparetotmag 0 -2 -> -1
|
||||
ddctm012 comparetotmag 0 -1 -> -1
|
||||
ddctm013 comparetotmag 0 0 -> 0
|
||||
ddctm014 comparetotmag 0 1 -> -1
|
||||
ddctm015 comparetotmag 0 2 -> -1
|
||||
ddctm016 comparetotmag 1 -2 -> -1
|
||||
ddctm017 comparetotmag 1 -1 -> 0
|
||||
ddctm018 comparetotmag 1 0 -> 1
|
||||
ddctm019 comparetotmag 1 1 -> 0
|
||||
ddctm020 comparetotmag 1 2 -> -1
|
||||
ddctm021 comparetotmag 2 -2 -> 0
|
||||
ddctm022 comparetotmag 2 -1 -> 1
|
||||
ddctm023 comparetotmag 2 0 -> 1
|
||||
ddctm025 comparetotmag 2 1 -> 1
|
||||
ddctm026 comparetotmag 2 2 -> 0
|
||||
|
||||
ddctm031 comparetotmag -20 -20 -> 0
|
||||
ddctm032 comparetotmag -20 -10 -> 1
|
||||
ddctm033 comparetotmag -20 00 -> 1
|
||||
ddctm034 comparetotmag -20 10 -> 1
|
||||
ddctm035 comparetotmag -20 20 -> 0
|
||||
ddctm036 comparetotmag -10 -20 -> -1
|
||||
ddctm037 comparetotmag -10 -10 -> 0
|
||||
ddctm038 comparetotmag -10 00 -> 1
|
||||
ddctm039 comparetotmag -10 10 -> 0
|
||||
ddctm040 comparetotmag -10 20 -> -1
|
||||
ddctm041 comparetotmag 00 -20 -> -1
|
||||
ddctm042 comparetotmag 00 -10 -> -1
|
||||
ddctm043 comparetotmag 00 00 -> 0
|
||||
ddctm044 comparetotmag 00 10 -> -1
|
||||
ddctm045 comparetotmag 00 20 -> -1
|
||||
ddctm046 comparetotmag 10 -20 -> -1
|
||||
ddctm047 comparetotmag 10 -10 -> 0
|
||||
ddctm048 comparetotmag 10 00 -> 1
|
||||
ddctm049 comparetotmag 10 10 -> 0
|
||||
ddctm050 comparetotmag 10 20 -> -1
|
||||
ddctm051 comparetotmag 20 -20 -> 0
|
||||
ddctm052 comparetotmag 20 -10 -> 1
|
||||
ddctm053 comparetotmag 20 00 -> 1
|
||||
ddctm055 comparetotmag 20 10 -> 1
|
||||
ddctm056 comparetotmag 20 20 -> 0
|
||||
|
||||
ddctm061 comparetotmag -2.0 -2.0 -> 0
|
||||
ddctm062 comparetotmag -2.0 -1.0 -> 1
|
||||
ddctm063 comparetotmag -2.0 0.0 -> 1
|
||||
ddctm064 comparetotmag -2.0 1.0 -> 1
|
||||
ddctm065 comparetotmag -2.0 2.0 -> 0
|
||||
ddctm066 comparetotmag -1.0 -2.0 -> -1
|
||||
ddctm067 comparetotmag -1.0 -1.0 -> 0
|
||||
ddctm068 comparetotmag -1.0 0.0 -> 1
|
||||
ddctm069 comparetotmag -1.0 1.0 -> 0
|
||||
ddctm070 comparetotmag -1.0 2.0 -> -1
|
||||
ddctm071 comparetotmag 0.0 -2.0 -> -1
|
||||
ddctm072 comparetotmag 0.0 -1.0 -> -1
|
||||
ddctm073 comparetotmag 0.0 0.0 -> 0
|
||||
ddctm074 comparetotmag 0.0 1.0 -> -1
|
||||
ddctm075 comparetotmag 0.0 2.0 -> -1
|
||||
ddctm076 comparetotmag 1.0 -2.0 -> -1
|
||||
ddctm077 comparetotmag 1.0 -1.0 -> 0
|
||||
ddctm078 comparetotmag 1.0 0.0 -> 1
|
||||
ddctm079 comparetotmag 1.0 1.0 -> 0
|
||||
ddctm080 comparetotmag 1.0 2.0 -> -1
|
||||
ddctm081 comparetotmag 2.0 -2.0 -> 0
|
||||
ddctm082 comparetotmag 2.0 -1.0 -> 1
|
||||
ddctm083 comparetotmag 2.0 0.0 -> 1
|
||||
ddctm085 comparetotmag 2.0 1.0 -> 1
|
||||
ddctm086 comparetotmag 2.0 2.0 -> 0
|
||||
|
||||
-- now some cases which might overflow if subtract were used
|
||||
ddctm090 comparetotmag 9.99999999E+384 9.99999999E+384 -> 0
|
||||
ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384 -> 0
|
||||
ddctm092 comparetotmag 9.99999999E+384 -9.99999999E+384 -> 0
|
||||
ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384 -> 0
|
||||
|
||||
-- some differing length/exponent cases
|
||||
-- in this first group, compare would compare all equal
|
||||
ddctm100 comparetotmag 7.0 7.0 -> 0
|
||||
ddctm101 comparetotmag 7.0 7 -> -1
|
||||
ddctm102 comparetotmag 7 7.0 -> 1
|
||||
ddctm103 comparetotmag 7E+0 7.0 -> 1
|
||||
ddctm104 comparetotmag 70E-1 7.0 -> 0
|
||||
ddctm105 comparetotmag 0.7E+1 7 -> 0
|
||||
ddctm106 comparetotmag 70E-1 7 -> -1
|
||||
ddctm107 comparetotmag 7.0 7E+0 -> -1
|
||||
ddctm108 comparetotmag 7.0 70E-1 -> 0
|
||||
ddctm109 comparetotmag 7 0.7E+1 -> 0
|
||||
ddctm110 comparetotmag 7 70E-1 -> 1
|
||||
|
||||
ddctm120 comparetotmag 8.0 7.0 -> 1
|
||||
ddctm121 comparetotmag 8.0 7 -> 1
|
||||
ddctm122 comparetotmag 8 7.0 -> 1
|
||||
ddctm123 comparetotmag 8E+0 7.0 -> 1
|
||||
ddctm124 comparetotmag 80E-1 7.0 -> 1
|
||||
ddctm125 comparetotmag 0.8E+1 7 -> 1
|
||||
ddctm126 comparetotmag 80E-1 7 -> 1
|
||||
ddctm127 comparetotmag 8.0 7E+0 -> 1
|
||||
ddctm128 comparetotmag 8.0 70E-1 -> 1
|
||||
ddctm129 comparetotmag 8 0.7E+1 -> 1
|
||||
ddctm130 comparetotmag 8 70E-1 -> 1
|
||||
|
||||
ddctm140 comparetotmag 8.0 9.0 -> -1
|
||||
ddctm141 comparetotmag 8.0 9 -> -1
|
||||
ddctm142 comparetotmag 8 9.0 -> -1
|
||||
ddctm143 comparetotmag 8E+0 9.0 -> -1
|
||||
ddctm144 comparetotmag 80E-1 9.0 -> -1
|
||||
ddctm145 comparetotmag 0.8E+1 9 -> -1
|
||||
ddctm146 comparetotmag 80E-1 9 -> -1
|
||||
ddctm147 comparetotmag 8.0 9E+0 -> -1
|
||||
ddctm148 comparetotmag 8.0 90E-1 -> -1
|
||||
ddctm149 comparetotmag 8 0.9E+1 -> -1
|
||||
ddctm150 comparetotmag 8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -+ ..
|
||||
ddctm200 comparetotmag -7.0 7.0 -> 0
|
||||
ddctm201 comparetotmag -7.0 7 -> -1
|
||||
ddctm202 comparetotmag -7 7.0 -> 1
|
||||
ddctm203 comparetotmag -7E+0 7.0 -> 1
|
||||
ddctm204 comparetotmag -70E-1 7.0 -> 0
|
||||
ddctm205 comparetotmag -0.7E+1 7 -> 0
|
||||
ddctm206 comparetotmag -70E-1 7 -> -1
|
||||
ddctm207 comparetotmag -7.0 7E+0 -> -1
|
||||
ddctm208 comparetotmag -7.0 70E-1 -> 0
|
||||
ddctm209 comparetotmag -7 0.7E+1 -> 0
|
||||
ddctm210 comparetotmag -7 70E-1 -> 1
|
||||
|
||||
ddctm220 comparetotmag -8.0 7.0 -> 1
|
||||
ddctm221 comparetotmag -8.0 7 -> 1
|
||||
ddctm222 comparetotmag -8 7.0 -> 1
|
||||
ddctm223 comparetotmag -8E+0 7.0 -> 1
|
||||
ddctm224 comparetotmag -80E-1 7.0 -> 1
|
||||
ddctm225 comparetotmag -0.8E+1 7 -> 1
|
||||
ddctm226 comparetotmag -80E-1 7 -> 1
|
||||
ddctm227 comparetotmag -8.0 7E+0 -> 1
|
||||
ddctm228 comparetotmag -8.0 70E-1 -> 1
|
||||
ddctm229 comparetotmag -8 0.7E+1 -> 1
|
||||
ddctm230 comparetotmag -8 70E-1 -> 1
|
||||
|
||||
ddctm240 comparetotmag -8.0 9.0 -> -1
|
||||
ddctm241 comparetotmag -8.0 9 -> -1
|
||||
ddctm242 comparetotmag -8 9.0 -> -1
|
||||
ddctm243 comparetotmag -8E+0 9.0 -> -1
|
||||
ddctm244 comparetotmag -80E-1 9.0 -> -1
|
||||
ddctm245 comparetotmag -0.8E+1 9 -> -1
|
||||
ddctm246 comparetotmag -80E-1 9 -> -1
|
||||
ddctm247 comparetotmag -8.0 9E+0 -> -1
|
||||
ddctm248 comparetotmag -8.0 90E-1 -> -1
|
||||
ddctm249 comparetotmag -8 0.9E+1 -> -1
|
||||
ddctm250 comparetotmag -8 90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes +- ..
|
||||
ddctm300 comparetotmag 7.0 -7.0 -> 0
|
||||
ddctm301 comparetotmag 7.0 -7 -> -1
|
||||
ddctm302 comparetotmag 7 -7.0 -> 1
|
||||
ddctm303 comparetotmag 7E+0 -7.0 -> 1
|
||||
ddctm304 comparetotmag 70E-1 -7.0 -> 0
|
||||
ddctm305 comparetotmag .7E+1 -7 -> 0
|
||||
ddctm306 comparetotmag 70E-1 -7 -> -1
|
||||
ddctm307 comparetotmag 7.0 -7E+0 -> -1
|
||||
ddctm308 comparetotmag 7.0 -70E-1 -> 0
|
||||
ddctm309 comparetotmag 7 -.7E+1 -> 0
|
||||
ddctm310 comparetotmag 7 -70E-1 -> 1
|
||||
|
||||
ddctm320 comparetotmag 8.0 -7.0 -> 1
|
||||
ddctm321 comparetotmag 8.0 -7 -> 1
|
||||
ddctm322 comparetotmag 8 -7.0 -> 1
|
||||
ddctm323 comparetotmag 8E+0 -7.0 -> 1
|
||||
ddctm324 comparetotmag 80E-1 -7.0 -> 1
|
||||
ddctm325 comparetotmag .8E+1 -7 -> 1
|
||||
ddctm326 comparetotmag 80E-1 -7 -> 1
|
||||
ddctm327 comparetotmag 8.0 -7E+0 -> 1
|
||||
ddctm328 comparetotmag 8.0 -70E-1 -> 1
|
||||
ddctm329 comparetotmag 8 -.7E+1 -> 1
|
||||
ddctm330 comparetotmag 8 -70E-1 -> 1
|
||||
|
||||
ddctm340 comparetotmag 8.0 -9.0 -> -1
|
||||
ddctm341 comparetotmag 8.0 -9 -> -1
|
||||
ddctm342 comparetotmag 8 -9.0 -> -1
|
||||
ddctm343 comparetotmag 8E+0 -9.0 -> -1
|
||||
ddctm344 comparetotmag 80E-1 -9.0 -> -1
|
||||
ddctm345 comparetotmag .8E+1 -9 -> -1
|
||||
ddctm346 comparetotmag 80E-1 -9 -> -1
|
||||
ddctm347 comparetotmag 8.0 -9E+0 -> -1
|
||||
ddctm348 comparetotmag 8.0 -90E-1 -> -1
|
||||
ddctm349 comparetotmag 8 -.9E+1 -> -1
|
||||
ddctm350 comparetotmag 8 -90E-1 -> -1
|
||||
|
||||
-- and again, with sign changes -- ..
|
||||
ddctm400 comparetotmag -7.0 -7.0 -> 0
|
||||
ddctm401 comparetotmag -7.0 -7 -> -1
|
||||
ddctm402 comparetotmag -7 -7.0 -> 1
|
||||
ddctm403 comparetotmag -7E+0 -7.0 -> 1
|
||||
ddctm404 comparetotmag -70E-1 -7.0 -> 0
|
||||
ddctm405 comparetotmag -.7E+1 -7 -> 0
|
||||
ddctm406 comparetotmag -70E-1 -7 -> -1
|
||||
ddctm407 comparetotmag -7.0 -7E+0 -> -1
|
||||
ddctm408 comparetotmag -7.0 -70E-1 -> 0
|
||||
ddctm409 comparetotmag -7 -.7E+1 -> 0
|
||||
ddctm410 comparetotmag -7 -70E-1 -> 1
|
||||
|
||||
ddctm420 comparetotmag -8.0 -7.0 -> 1
|
||||
ddctm421 comparetotmag -8.0 -7 -> 1
|
||||
ddctm422 comparetotmag -8 -7.0 -> 1
|
||||
ddctm423 comparetotmag -8E+0 -7.0 -> 1
|
||||
ddctm424 comparetotmag -80E-1 -7.0 -> 1
|
||||
ddctm425 comparetotmag -.8E+1 -7 -> 1
|
||||
ddctm426 comparetotmag -80E-1 -7 -> 1
|
||||
ddctm427 comparetotmag -8.0 -7E+0 -> 1
|
||||
ddctm428 comparetotmag -8.0 -70E-1 -> 1
|
||||
ddctm429 comparetotmag -8 -.7E+1 -> 1
|
||||
ddctm430 comparetotmag -8 -70E-1 -> 1
|
||||
|
||||
ddctm440 comparetotmag -8.0 -9.0 -> -1
|
||||
ddctm441 comparetotmag -8.0 -9 -> -1
|
||||
ddctm442 comparetotmag -8 -9.0 -> -1
|
||||
ddctm443 comparetotmag -8E+0 -9.0 -> -1
|
||||
ddctm444 comparetotmag -80E-1 -9.0 -> -1
|
||||
ddctm445 comparetotmag -.8E+1 -9 -> -1
|
||||
ddctm446 comparetotmag -80E-1 -9 -> -1
|
||||
ddctm447 comparetotmag -8.0 -9E+0 -> -1
|
||||
ddctm448 comparetotmag -8.0 -90E-1 -> -1
|
||||
ddctm449 comparetotmag -8 -.9E+1 -> -1
|
||||
ddctm450 comparetotmag -8 -90E-1 -> -1
|
||||
|
||||
|
||||
-- testcases that subtract to lots of zeros at boundaries [pgr]
|
||||
ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
|
||||
ddctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
|
||||
ddctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
|
||||
ddctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
|
||||
ddctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
|
||||
ddctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
|
||||
ddctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
|
||||
ddctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
|
||||
ddctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
|
||||
ddctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
|
||||
ddctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
|
||||
ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
|
||||
ddctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
|
||||
ddctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
|
||||
ddctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
|
||||
ddctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
|
||||
ddctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
|
||||
ddctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
|
||||
ddctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
|
||||
ddctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
|
||||
ddctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
|
||||
ddctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
|
||||
|
||||
-- wide-ranging, around precision; signs equal
|
||||
ddctm498 comparetotmag 1 1E-17 -> 1
|
||||
ddctm499 comparetotmag 1 1E-16 -> 1
|
||||
ddctm500 comparetotmag 1 1E-15 -> 1
|
||||
ddctm501 comparetotmag 1 1E-14 -> 1
|
||||
ddctm502 comparetotmag 1 1E-13 -> 1
|
||||
ddctm503 comparetotmag 1 1E-12 -> 1
|
||||
ddctm504 comparetotmag 1 1E-11 -> 1
|
||||
ddctm505 comparetotmag 1 1E-10 -> 1
|
||||
ddctm506 comparetotmag 1 1E-9 -> 1
|
||||
ddctm507 comparetotmag 1 1E-8 -> 1
|
||||
ddctm508 comparetotmag 1 1E-7 -> 1
|
||||
ddctm509 comparetotmag 1 1E-6 -> 1
|
||||
ddctm510 comparetotmag 1 1E-5 -> 1
|
||||
ddctm511 comparetotmag 1 1E-4 -> 1
|
||||
ddctm512 comparetotmag 1 1E-3 -> 1
|
||||
ddctm513 comparetotmag 1 1E-2 -> 1
|
||||
ddctm514 comparetotmag 1 1E-1 -> 1
|
||||
ddctm515 comparetotmag 1 1E-0 -> 0
|
||||
ddctm516 comparetotmag 1 1E+1 -> -1
|
||||
ddctm517 comparetotmag 1 1E+2 -> -1
|
||||
ddctm518 comparetotmag 1 1E+3 -> -1
|
||||
ddctm519 comparetotmag 1 1E+4 -> -1
|
||||
ddctm521 comparetotmag 1 1E+5 -> -1
|
||||
ddctm522 comparetotmag 1 1E+6 -> -1
|
||||
ddctm523 comparetotmag 1 1E+7 -> -1
|
||||
ddctm524 comparetotmag 1 1E+8 -> -1
|
||||
ddctm525 comparetotmag 1 1E+9 -> -1
|
||||
ddctm526 comparetotmag 1 1E+10 -> -1
|
||||
ddctm527 comparetotmag 1 1E+11 -> -1
|
||||
ddctm528 comparetotmag 1 1E+12 -> -1
|
||||
ddctm529 comparetotmag 1 1E+13 -> -1
|
||||
ddctm530 comparetotmag 1 1E+14 -> -1
|
||||
ddctm531 comparetotmag 1 1E+15 -> -1
|
||||
ddctm532 comparetotmag 1 1E+16 -> -1
|
||||
ddctm533 comparetotmag 1 1E+17 -> -1
|
||||
-- LR swap
|
||||
ddctm538 comparetotmag 1E-17 1 -> -1
|
||||
ddctm539 comparetotmag 1E-16 1 -> -1
|
||||
ddctm540 comparetotmag 1E-15 1 -> -1
|
||||
ddctm541 comparetotmag 1E-14 1 -> -1
|
||||
ddctm542 comparetotmag 1E-13 1 -> -1
|
||||
ddctm543 comparetotmag 1E-12 1 -> -1
|
||||
ddctm544 comparetotmag 1E-11 1 -> -1
|
||||
ddctm545 comparetotmag 1E-10 1 -> -1
|
||||
ddctm546 comparetotmag 1E-9 1 -> -1
|
||||
ddctm547 comparetotmag 1E-8 1 -> -1
|
||||
ddctm548 comparetotmag 1E-7 1 -> -1
|
||||
ddctm549 comparetotmag 1E-6 1 -> -1
|
||||
ddctm550 comparetotmag 1E-5 1 -> -1
|
||||
ddctm551 comparetotmag 1E-4 1 -> -1
|
||||
ddctm552 comparetotmag 1E-3 1 -> -1
|
||||
ddctm553 comparetotmag 1E-2 1 -> -1
|
||||
ddctm554 comparetotmag 1E-1 1 -> -1
|
||||
ddctm555 comparetotmag 1E-0 1 -> 0
|
||||
ddctm556 comparetotmag 1E+1 1 -> 1
|
||||
ddctm557 comparetotmag 1E+2 1 -> 1
|
||||
ddctm558 comparetotmag 1E+3 1 -> 1
|
||||
ddctm559 comparetotmag 1E+4 1 -> 1
|
||||
ddctm561 comparetotmag 1E+5 1 -> 1
|
||||
ddctm562 comparetotmag 1E+6 1 -> 1
|
||||
ddctm563 comparetotmag 1E+7 1 -> 1
|
||||
ddctm564 comparetotmag 1E+8 1 -> 1
|
||||
ddctm565 comparetotmag 1E+9 1 -> 1
|
||||
ddctm566 comparetotmag 1E+10 1 -> 1
|
||||
ddctm567 comparetotmag 1E+11 1 -> 1
|
||||
ddctm568 comparetotmag 1E+12 1 -> 1
|
||||
ddctm569 comparetotmag 1E+13 1 -> 1
|
||||
ddctm570 comparetotmag 1E+14 1 -> 1
|
||||
ddctm571 comparetotmag 1E+15 1 -> 1
|
||||
ddctm572 comparetotmag 1E+16 1 -> 1
|
||||
ddctm573 comparetotmag 1E+17 1 -> 1
|
||||
-- similar with a useful coefficient, one side only
|
||||
ddctm578 comparetotmag 0.000000987654321 1E-17 -> 1
|
||||
ddctm579 comparetotmag 0.000000987654321 1E-16 -> 1
|
||||
ddctm580 comparetotmag 0.000000987654321 1E-15 -> 1
|
||||
ddctm581 comparetotmag 0.000000987654321 1E-14 -> 1
|
||||
ddctm582 comparetotmag 0.000000987654321 1E-13 -> 1
|
||||
ddctm583 comparetotmag 0.000000987654321 1E-12 -> 1
|
||||
ddctm584 comparetotmag 0.000000987654321 1E-11 -> 1
|
||||
ddctm585 comparetotmag 0.000000987654321 1E-10 -> 1
|
||||
ddctm586 comparetotmag 0.000000987654321 1E-9 -> 1
|
||||
ddctm587 comparetotmag 0.000000987654321 1E-8 -> 1
|
||||
ddctm588 comparetotmag 0.000000987654321 1E-7 -> 1
|
||||
ddctm589 comparetotmag 0.000000987654321 1E-6 -> -1
|
||||
ddctm590 comparetotmag 0.000000987654321 1E-5 -> -1
|
||||
ddctm591 comparetotmag 0.000000987654321 1E-4 -> -1
|
||||
ddctm592 comparetotmag 0.000000987654321 1E-3 -> -1
|
||||
ddctm593 comparetotmag 0.000000987654321 1E-2 -> -1
|
||||
ddctm594 comparetotmag 0.000000987654321 1E-1 -> -1
|
||||
ddctm595 comparetotmag 0.000000987654321 1E-0 -> -1
|
||||
ddctm596 comparetotmag 0.000000987654321 1E+1 -> -1
|
||||
ddctm597 comparetotmag 0.000000987654321 1E+2 -> -1
|
||||
ddctm598 comparetotmag 0.000000987654321 1E+3 -> -1
|
||||
ddctm599 comparetotmag 0.000000987654321 1E+4 -> -1
|
||||
|
||||
-- check some unit-y traps
|
||||
ddctm600 comparetotmag 12 12.2345 -> -1
|
||||
ddctm601 comparetotmag 12.0 12.2345 -> -1
|
||||
ddctm602 comparetotmag 12.00 12.2345 -> -1
|
||||
ddctm603 comparetotmag 12.000 12.2345 -> -1
|
||||
ddctm604 comparetotmag 12.0000 12.2345 -> -1
|
||||
ddctm605 comparetotmag 12.00000 12.2345 -> -1
|
||||
ddctm606 comparetotmag 12.000000 12.2345 -> -1
|
||||
ddctm607 comparetotmag 12.0000000 12.2345 -> -1
|
||||
ddctm608 comparetotmag 12.00000000 12.2345 -> -1
|
||||
ddctm609 comparetotmag 12.000000000 12.2345 -> -1
|
||||
ddctm610 comparetotmag 12.1234 12 -> 1
|
||||
ddctm611 comparetotmag 12.1234 12.0 -> 1
|
||||
ddctm612 comparetotmag 12.1234 12.00 -> 1
|
||||
ddctm613 comparetotmag 12.1234 12.000 -> 1
|
||||
ddctm614 comparetotmag 12.1234 12.0000 -> 1
|
||||
ddctm615 comparetotmag 12.1234 12.00000 -> 1
|
||||
ddctm616 comparetotmag 12.1234 12.000000 -> 1
|
||||
ddctm617 comparetotmag 12.1234 12.0000000 -> 1
|
||||
ddctm618 comparetotmag 12.1234 12.00000000 -> 1
|
||||
ddctm619 comparetotmag 12.1234 12.000000000 -> 1
|
||||
ddctm620 comparetotmag -12 -12.2345 -> -1
|
||||
ddctm621 comparetotmag -12.0 -12.2345 -> -1
|
||||
ddctm622 comparetotmag -12.00 -12.2345 -> -1
|
||||
ddctm623 comparetotmag -12.000 -12.2345 -> -1
|
||||
ddctm624 comparetotmag -12.0000 -12.2345 -> -1
|
||||
ddctm625 comparetotmag -12.00000 -12.2345 -> -1
|
||||
ddctm626 comparetotmag -12.000000 -12.2345 -> -1
|
||||
ddctm627 comparetotmag -12.0000000 -12.2345 -> -1
|
||||
ddctm628 comparetotmag -12.00000000 -12.2345 -> -1
|
||||
ddctm629 comparetotmag -12.000000000 -12.2345 -> -1
|
||||
ddctm630 comparetotmag -12.1234 -12 -> 1
|
||||
ddctm631 comparetotmag -12.1234 -12.0 -> 1
|
||||
ddctm632 comparetotmag -12.1234 -12.00 -> 1
|
||||
ddctm633 comparetotmag -12.1234 -12.000 -> 1
|
||||
ddctm634 comparetotmag -12.1234 -12.0000 -> 1
|
||||
ddctm635 comparetotmag -12.1234 -12.00000 -> 1
|
||||
ddctm636 comparetotmag -12.1234 -12.000000 -> 1
|
||||
ddctm637 comparetotmag -12.1234 -12.0000000 -> 1
|
||||
ddctm638 comparetotmag -12.1234 -12.00000000 -> 1
|
||||
ddctm639 comparetotmag -12.1234 -12.000000000 -> 1
|
||||
|
||||
-- extended zeros
|
||||
ddctm640 comparetotmag 0 0 -> 0
|
||||
ddctm641 comparetotmag 0 -0 -> 0
|
||||
ddctm642 comparetotmag 0 -0.0 -> 1
|
||||
ddctm643 comparetotmag 0 0.0 -> 1
|
||||
ddctm644 comparetotmag -0 0 -> 0
|
||||
ddctm645 comparetotmag -0 -0 -> 0
|
||||
ddctm646 comparetotmag -0 -0.0 -> 1
|
||||
ddctm647 comparetotmag -0 0.0 -> 1
|
||||
ddctm648 comparetotmag 0.0 0 -> -1
|
||||
ddctm649 comparetotmag 0.0 -0 -> -1
|
||||
ddctm650 comparetotmag 0.0 -0.0 -> 0
|
||||
ddctm651 comparetotmag 0.0 0.0 -> 0
|
||||
ddctm652 comparetotmag -0.0 0 -> -1
|
||||
ddctm653 comparetotmag -0.0 -0 -> -1
|
||||
ddctm654 comparetotmag -0.0 -0.0 -> 0
|
||||
ddctm655 comparetotmag -0.0 0.0 -> 0
|
||||
|
||||
ddctm656 comparetotmag -0E1 0.0 -> 1
|
||||
ddctm657 comparetotmag -0E2 0.0 -> 1
|
||||
ddctm658 comparetotmag 0E1 0.0 -> 1
|
||||
ddctm659 comparetotmag 0E2 0.0 -> 1
|
||||
ddctm660 comparetotmag -0E1 0 -> 1
|
||||
ddctm661 comparetotmag -0E2 0 -> 1
|
||||
ddctm662 comparetotmag 0E1 0 -> 1
|
||||
ddctm663 comparetotmag 0E2 0 -> 1
|
||||
ddctm664 comparetotmag -0E1 -0E1 -> 0
|
||||
ddctm665 comparetotmag -0E2 -0E1 -> 1
|
||||
ddctm666 comparetotmag 0E1 -0E1 -> 0
|
||||
ddctm667 comparetotmag 0E2 -0E1 -> 1
|
||||
ddctm668 comparetotmag -0E1 -0E2 -> -1
|
||||
ddctm669 comparetotmag -0E2 -0E2 -> 0
|
||||
ddctm670 comparetotmag 0E1 -0E2 -> -1
|
||||
ddctm671 comparetotmag 0E2 -0E2 -> 0
|
||||
ddctm672 comparetotmag -0E1 0E1 -> 0
|
||||
ddctm673 comparetotmag -0E2 0E1 -> 1
|
||||
ddctm674 comparetotmag 0E1 0E1 -> 0
|
||||
ddctm675 comparetotmag 0E2 0E1 -> 1
|
||||
ddctm676 comparetotmag -0E1 0E2 -> -1
|
||||
ddctm677 comparetotmag -0E2 0E2 -> 0
|
||||
ddctm678 comparetotmag 0E1 0E2 -> -1
|
||||
ddctm679 comparetotmag 0E2 0E2 -> 0
|
||||
|
||||
-- trailing zeros; unit-y
|
||||
ddctm680 comparetotmag 12 12 -> 0
|
||||
ddctm681 comparetotmag 12 12.0 -> 1
|
||||
ddctm682 comparetotmag 12 12.00 -> 1
|
||||
ddctm683 comparetotmag 12 12.000 -> 1
|
||||
ddctm684 comparetotmag 12 12.0000 -> 1
|
||||
ddctm685 comparetotmag 12 12.00000 -> 1
|
||||
ddctm686 comparetotmag 12 12.000000 -> 1
|
||||
ddctm687 comparetotmag 12 12.0000000 -> 1
|
||||
ddctm688 comparetotmag 12 12.00000000 -> 1
|
||||
ddctm689 comparetotmag 12 12.000000000 -> 1
|
||||
ddctm690 comparetotmag 12 12 -> 0
|
||||
ddctm691 comparetotmag 12.0 12 -> -1
|
||||
ddctm692 comparetotmag 12.00 12 -> -1
|
||||
ddctm693 comparetotmag 12.000 12 -> -1
|
||||
ddctm694 comparetotmag 12.0000 12 -> -1
|
||||
ddctm695 comparetotmag 12.00000 12 -> -1
|
||||
ddctm696 comparetotmag 12.000000 12 -> -1
|
||||
ddctm697 comparetotmag 12.0000000 12 -> -1
|
||||
ddctm698 comparetotmag 12.00000000 12 -> -1
|
||||
ddctm699 comparetotmag 12.000000000 12 -> -1
|
||||
|
||||
-- old long operand checks
|
||||
ddctm701 comparetotmag 12345678000 1 -> 1
|
||||
ddctm702 comparetotmag 1 12345678000 -> -1
|
||||
ddctm703 comparetotmag 1234567800 1 -> 1
|
||||
ddctm704 comparetotmag 1 1234567800 -> -1
|
||||
ddctm705 comparetotmag 1234567890 1 -> 1
|
||||
ddctm706 comparetotmag 1 1234567890 -> -1
|
||||
ddctm707 comparetotmag 1234567891 1 -> 1
|
||||
ddctm708 comparetotmag 1 1234567891 -> -1
|
||||
ddctm709 comparetotmag 12345678901 1 -> 1
|
||||
ddctm710 comparetotmag 1 12345678901 -> -1
|
||||
ddctm711 comparetotmag 1234567896 1 -> 1
|
||||
ddctm712 comparetotmag 1 1234567896 -> -1
|
||||
ddctm713 comparetotmag -1234567891 1 -> 1
|
||||
ddctm714 comparetotmag 1 -1234567891 -> -1
|
||||
ddctm715 comparetotmag -12345678901 1 -> 1
|
||||
ddctm716 comparetotmag 1 -12345678901 -> -1
|
||||
ddctm717 comparetotmag -1234567896 1 -> 1
|
||||
ddctm718 comparetotmag 1 -1234567896 -> -1
|
||||
|
||||
-- old residue cases
|
||||
ddctm740 comparetotmag 1 0.9999999 -> 1
|
||||
ddctm741 comparetotmag 1 0.999999 -> 1
|
||||
ddctm742 comparetotmag 1 0.99999 -> 1
|
||||
ddctm743 comparetotmag 1 1.0000 -> 1
|
||||
ddctm744 comparetotmag 1 1.00001 -> -1
|
||||
ddctm745 comparetotmag 1 1.000001 -> -1
|
||||
ddctm746 comparetotmag 1 1.0000001 -> -1
|
||||
ddctm750 comparetotmag 0.9999999 1 -> -1
|
||||
ddctm751 comparetotmag 0.999999 1 -> -1
|
||||
ddctm752 comparetotmag 0.99999 1 -> -1
|
||||
ddctm753 comparetotmag 1.0000 1 -> -1
|
||||
ddctm754 comparetotmag 1.00001 1 -> 1
|
||||
ddctm755 comparetotmag 1.000001 1 -> 1
|
||||
ddctm756 comparetotmag 1.0000001 1 -> 1
|
||||
|
||||
-- Specials
|
||||
ddctm780 comparetotmag Inf -Inf -> 0
|
||||
ddctm781 comparetotmag Inf -1000 -> 1
|
||||
ddctm782 comparetotmag Inf -1 -> 1
|
||||
ddctm783 comparetotmag Inf -0 -> 1
|
||||
ddctm784 comparetotmag Inf 0 -> 1
|
||||
ddctm785 comparetotmag Inf 1 -> 1
|
||||
ddctm786 comparetotmag Inf 1000 -> 1
|
||||
ddctm787 comparetotmag Inf Inf -> 0
|
||||
ddctm788 comparetotmag -1000 Inf -> -1
|
||||
ddctm789 comparetotmag -Inf Inf -> 0
|
||||
ddctm790 comparetotmag -1 Inf -> -1
|
||||
ddctm791 comparetotmag -0 Inf -> -1
|
||||
ddctm792 comparetotmag 0 Inf -> -1
|
||||
ddctm793 comparetotmag 1 Inf -> -1
|
||||
ddctm794 comparetotmag 1000 Inf -> -1
|
||||
ddctm795 comparetotmag Inf Inf -> 0
|
||||
|
||||
ddctm800 comparetotmag -Inf -Inf -> 0
|
||||
ddctm801 comparetotmag -Inf -1000 -> 1
|
||||
ddctm802 comparetotmag -Inf -1 -> 1
|
||||
ddctm803 comparetotmag -Inf -0 -> 1
|
||||
ddctm804 comparetotmag -Inf 0 -> 1
|
||||
ddctm805 comparetotmag -Inf 1 -> 1
|
||||
ddctm806 comparetotmag -Inf 1000 -> 1
|
||||
ddctm807 comparetotmag -Inf Inf -> 0
|
||||
ddctm808 comparetotmag -Inf -Inf -> 0
|
||||
ddctm809 comparetotmag -1000 -Inf -> -1
|
||||
ddctm810 comparetotmag -1 -Inf -> -1
|
||||
ddctm811 comparetotmag -0 -Inf -> -1
|
||||
ddctm812 comparetotmag 0 -Inf -> -1
|
||||
ddctm813 comparetotmag 1 -Inf -> -1
|
||||
ddctm814 comparetotmag 1000 -Inf -> -1
|
||||
ddctm815 comparetotmag Inf -Inf -> 0
|
||||
|
||||
ddctm821 comparetotmag NaN -Inf -> 1
|
||||
ddctm822 comparetotmag NaN -1000 -> 1
|
||||
ddctm823 comparetotmag NaN -1 -> 1
|
||||
ddctm824 comparetotmag NaN -0 -> 1
|
||||
ddctm825 comparetotmag NaN 0 -> 1
|
||||
ddctm826 comparetotmag NaN 1 -> 1
|
||||
ddctm827 comparetotmag NaN 1000 -> 1
|
||||
ddctm828 comparetotmag NaN Inf -> 1
|
||||
ddctm829 comparetotmag NaN NaN -> 0
|
||||
ddctm830 comparetotmag -Inf NaN -> -1
|
||||
ddctm831 comparetotmag -1000 NaN -> -1
|
||||
ddctm832 comparetotmag -1 NaN -> -1
|
||||
ddctm833 comparetotmag -0 NaN -> -1
|
||||
ddctm834 comparetotmag 0 NaN -> -1
|
||||
ddctm835 comparetotmag 1 NaN -> -1
|
||||
ddctm836 comparetotmag 1000 NaN -> -1
|
||||
ddctm837 comparetotmag Inf NaN -> -1
|
||||
ddctm838 comparetotmag -NaN -NaN -> 0
|
||||
ddctm839 comparetotmag +NaN -NaN -> 0
|
||||
ddctm840 comparetotmag -NaN +NaN -> 0
|
||||
|
||||
ddctm841 comparetotmag sNaN -sNaN -> 0
|
||||
ddctm842 comparetotmag sNaN -NaN -> -1
|
||||
ddctm843 comparetotmag sNaN -Inf -> 1
|
||||
ddctm844 comparetotmag sNaN -1000 -> 1
|
||||
ddctm845 comparetotmag sNaN -1 -> 1
|
||||
ddctm846 comparetotmag sNaN -0 -> 1
|
||||
ddctm847 comparetotmag sNaN 0 -> 1
|
||||
ddctm848 comparetotmag sNaN 1 -> 1
|
||||
ddctm849 comparetotmag sNaN 1000 -> 1
|
||||
ddctm850 comparetotmag sNaN NaN -> -1
|
||||
ddctm851 comparetotmag sNaN sNaN -> 0
|
||||
|
||||
ddctm852 comparetotmag -sNaN sNaN -> 0
|
||||
ddctm853 comparetotmag -NaN sNaN -> 1
|
||||
ddctm854 comparetotmag -Inf sNaN -> -1
|
||||
ddctm855 comparetotmag -1000 sNaN -> -1
|
||||
ddctm856 comparetotmag -1 sNaN -> -1
|
||||
ddctm857 comparetotmag -0 sNaN -> -1
|
||||
ddctm858 comparetotmag 0 sNaN -> -1
|
||||
ddctm859 comparetotmag 1 sNaN -> -1
|
||||
ddctm860 comparetotmag 1000 sNaN -> -1
|
||||
ddctm861 comparetotmag Inf sNaN -> -1
|
||||
ddctm862 comparetotmag NaN sNaN -> 1
|
||||
ddctm863 comparetotmag sNaN sNaN -> 0
|
||||
|
||||
ddctm871 comparetotmag -sNaN -sNaN -> 0
|
||||
ddctm872 comparetotmag -sNaN -NaN -> -1
|
||||
ddctm873 comparetotmag -sNaN -Inf -> 1
|
||||
ddctm874 comparetotmag -sNaN -1000 -> 1
|
||||
ddctm875 comparetotmag -sNaN -1 -> 1
|
||||
ddctm876 comparetotmag -sNaN -0 -> 1
|
||||
ddctm877 comparetotmag -sNaN 0 -> 1
|
||||
ddctm878 comparetotmag -sNaN 1 -> 1
|
||||
ddctm879 comparetotmag -sNaN 1000 -> 1
|
||||
ddctm880 comparetotmag -sNaN NaN -> -1
|
||||
ddctm881 comparetotmag -sNaN sNaN -> 0
|
||||
|
||||
ddctm882 comparetotmag -sNaN -sNaN -> 0
|
||||
ddctm883 comparetotmag -NaN -sNaN -> 1
|
||||
ddctm884 comparetotmag -Inf -sNaN -> -1
|
||||
ddctm885 comparetotmag -1000 -sNaN -> -1
|
||||
ddctm886 comparetotmag -1 -sNaN -> -1
|
||||
ddctm887 comparetotmag -0 -sNaN -> -1
|
||||
ddctm888 comparetotmag 0 -sNaN -> -1
|
||||
ddctm889 comparetotmag 1 -sNaN -> -1
|
||||
ddctm890 comparetotmag 1000 -sNaN -> -1
|
||||
ddctm891 comparetotmag Inf -sNaN -> -1
|
||||
ddctm892 comparetotmag NaN -sNaN -> 1
|
||||
ddctm893 comparetotmag sNaN -sNaN -> 0
|
||||
|
||||
-- NaNs with payload
|
||||
ddctm960 comparetotmag NaN9 -Inf -> 1
|
||||
ddctm961 comparetotmag NaN8 999 -> 1
|
||||
ddctm962 comparetotmag NaN77 Inf -> 1
|
||||
ddctm963 comparetotmag -NaN67 NaN5 -> 1
|
||||
ddctm964 comparetotmag -Inf -NaN4 -> -1
|
||||
ddctm965 comparetotmag -999 -NaN33 -> -1
|
||||
ddctm966 comparetotmag Inf NaN2 -> -1
|
||||
|
||||
ddctm970 comparetotmag -NaN41 -NaN42 -> -1
|
||||
ddctm971 comparetotmag +NaN41 -NaN42 -> -1
|
||||
ddctm972 comparetotmag -NaN41 +NaN42 -> -1
|
||||
ddctm973 comparetotmag +NaN41 +NaN42 -> -1
|
||||
ddctm974 comparetotmag -NaN42 -NaN01 -> 1
|
||||
ddctm975 comparetotmag +NaN42 -NaN01 -> 1
|
||||
ddctm976 comparetotmag -NaN42 +NaN01 -> 1
|
||||
ddctm977 comparetotmag +NaN42 +NaN01 -> 1
|
||||
|
||||
ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
|
||||
ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
|
||||
ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
|
||||
ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
|
||||
ddctm984 comparetotmag -sNaN772 -sNaN771 -> 1
|
||||
ddctm985 comparetotmag +sNaN772 -sNaN771 -> 1
|
||||
ddctm986 comparetotmag -sNaN772 +sNaN771 -> 1
|
||||
ddctm987 comparetotmag +sNaN772 +sNaN771 -> 1
|
||||
|
||||
ddctm991 comparetotmag -sNaN99 -Inf -> 1
|
||||
ddctm992 comparetotmag sNaN98 -11 -> 1
|
||||
ddctm993 comparetotmag sNaN97 NaN -> -1
|
||||
ddctm994 comparetotmag sNaN16 sNaN94 -> -1
|
||||
ddctm995 comparetotmag NaN85 sNaN83 -> 1
|
||||
ddctm996 comparetotmag -Inf sNaN92 -> -1
|
||||
ddctm997 comparetotmag 088 sNaN81 -> -1
|
||||
ddctm998 comparetotmag Inf sNaN90 -> -1
|
||||
ddctm999 comparetotmag NaN -sNaN89 -> 1
|
||||
|
||||
-- spread zeros
|
||||
ddctm1110 comparetotmag 0E-383 0 -> -1
|
||||
ddctm1111 comparetotmag 0E-383 -0 -> -1
|
||||
ddctm1112 comparetotmag -0E-383 0 -> -1
|
||||
ddctm1113 comparetotmag -0E-383 -0 -> -1
|
||||
ddctm1114 comparetotmag 0E-383 0E+384 -> -1
|
||||
ddctm1115 comparetotmag 0E-383 -0E+384 -> -1
|
||||
ddctm1116 comparetotmag -0E-383 0E+384 -> -1
|
||||
ddctm1117 comparetotmag -0E-383 -0E+384 -> -1
|
||||
ddctm1118 comparetotmag 0 0E+384 -> -1
|
||||
ddctm1119 comparetotmag 0 -0E+384 -> -1
|
||||
ddctm1120 comparetotmag -0 0E+384 -> -1
|
||||
ddctm1121 comparetotmag -0 -0E+384 -> -1
|
||||
|
||||
ddctm1130 comparetotmag 0E+384 0 -> 1
|
||||
ddctm1131 comparetotmag 0E+384 -0 -> 1
|
||||
ddctm1132 comparetotmag -0E+384 0 -> 1
|
||||
ddctm1133 comparetotmag -0E+384 -0 -> 1
|
||||
ddctm1134 comparetotmag 0E+384 0E-383 -> 1
|
||||
ddctm1135 comparetotmag 0E+384 -0E-383 -> 1
|
||||
ddctm1136 comparetotmag -0E+384 0E-383 -> 1
|
||||
ddctm1137 comparetotmag -0E+384 -0E-383 -> 1
|
||||
ddctm1138 comparetotmag 0 0E-383 -> 1
|
||||
ddctm1139 comparetotmag 0 -0E-383 -> 1
|
||||
ddctm1140 comparetotmag -0 0E-383 -> 1
|
||||
ddctm1141 comparetotmag -0 -0E-383 -> 1
|
||||
|
||||
-- Null tests
|
||||
ddctm9990 comparetotmag 10 # -> NaN Invalid_operation
|
||||
ddctm9991 comparetotmag # 10 -> NaN Invalid_operation
|
@ -0,0 +1,88 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCopy.decTest -- quiet decDouble copy --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check
|
||||
ddcpy001 copy +7.50 -> 7.50
|
||||
|
||||
-- Infinities
|
||||
ddcpy011 copy Infinity -> Infinity
|
||||
ddcpy012 copy -Infinity -> -Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddcpy021 copy NaN -> NaN
|
||||
ddcpy022 copy -NaN -> -NaN
|
||||
ddcpy023 copy sNaN -> sNaN
|
||||
ddcpy024 copy -sNaN -> -sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddcpy031 copy NaN10 -> NaN10
|
||||
ddcpy032 copy -NaN10 -> -NaN10
|
||||
ddcpy033 copy sNaN10 -> sNaN10
|
||||
ddcpy034 copy -sNaN10 -> -sNaN10
|
||||
ddcpy035 copy NaN7 -> NaN7
|
||||
ddcpy036 copy -NaN7 -> -NaN7
|
||||
ddcpy037 copy sNaN101 -> sNaN101
|
||||
ddcpy038 copy -sNaN101 -> -sNaN101
|
||||
|
||||
-- finites
|
||||
ddcpy101 copy 7 -> 7
|
||||
ddcpy102 copy -7 -> -7
|
||||
ddcpy103 copy 75 -> 75
|
||||
ddcpy104 copy -75 -> -75
|
||||
ddcpy105 copy 7.50 -> 7.50
|
||||
ddcpy106 copy -7.50 -> -7.50
|
||||
ddcpy107 copy 7.500 -> 7.500
|
||||
ddcpy108 copy -7.500 -> -7.500
|
||||
|
||||
-- zeros
|
||||
ddcpy111 copy 0 -> 0
|
||||
ddcpy112 copy -0 -> -0
|
||||
ddcpy113 copy 0E+4 -> 0E+4
|
||||
ddcpy114 copy -0E+4 -> -0E+4
|
||||
ddcpy115 copy 0.0000 -> 0.0000
|
||||
ddcpy116 copy -0.0000 -> -0.0000
|
||||
ddcpy117 copy 0E-141 -> 0E-141
|
||||
ddcpy118 copy -0E-141 -> -0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddcpy121 copy 2682682682682682 -> 2682682682682682
|
||||
ddcpy122 copy -2682682682682682 -> -2682682682682682
|
||||
ddcpy123 copy 1341341341341341 -> 1341341341341341
|
||||
ddcpy124 copy -1341341341341341 -> -1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddcpy131 copy 9.999999999999999E+384 -> 9.999999999999999E+384
|
||||
ddcpy132 copy 1E-383 -> 1E-383
|
||||
ddcpy133 copy 1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddcpy134 copy 1E-398 -> 1E-398
|
||||
|
||||
ddcpy135 copy -1E-398 -> -1E-398
|
||||
ddcpy136 copy -1.000000000000000E-383 -> -1.000000000000000E-383
|
||||
ddcpy137 copy -1E-383 -> -1E-383
|
||||
ddcpy138 copy -9.999999999999999E+384 -> -9.999999999999999E+384
|
@ -0,0 +1,88 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check
|
||||
ddcpa001 copyabs +7.50 -> 7.50
|
||||
|
||||
-- Infinities
|
||||
ddcpa011 copyabs Infinity -> Infinity
|
||||
ddcpa012 copyabs -Infinity -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddcpa021 copyabs NaN -> NaN
|
||||
ddcpa022 copyabs -NaN -> NaN
|
||||
ddcpa023 copyabs sNaN -> sNaN
|
||||
ddcpa024 copyabs -sNaN -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddcpa031 copyabs NaN10 -> NaN10
|
||||
ddcpa032 copyabs -NaN15 -> NaN15
|
||||
ddcpa033 copyabs sNaN15 -> sNaN15
|
||||
ddcpa034 copyabs -sNaN10 -> sNaN10
|
||||
ddcpa035 copyabs NaN7 -> NaN7
|
||||
ddcpa036 copyabs -NaN7 -> NaN7
|
||||
ddcpa037 copyabs sNaN101 -> sNaN101
|
||||
ddcpa038 copyabs -sNaN101 -> sNaN101
|
||||
|
||||
-- finites
|
||||
ddcpa101 copyabs 7 -> 7
|
||||
ddcpa102 copyabs -7 -> 7
|
||||
ddcpa103 copyabs 75 -> 75
|
||||
ddcpa104 copyabs -75 -> 75
|
||||
ddcpa105 copyabs 7.10 -> 7.10
|
||||
ddcpa106 copyabs -7.10 -> 7.10
|
||||
ddcpa107 copyabs 7.500 -> 7.500
|
||||
ddcpa108 copyabs -7.500 -> 7.500
|
||||
|
||||
-- zeros
|
||||
ddcpa111 copyabs 0 -> 0
|
||||
ddcpa112 copyabs -0 -> 0
|
||||
ddcpa113 copyabs 0E+6 -> 0E+6
|
||||
ddcpa114 copyabs -0E+6 -> 0E+6
|
||||
ddcpa115 copyabs 0.0000 -> 0.0000
|
||||
ddcpa116 copyabs -0.0000 -> 0.0000
|
||||
ddcpa117 copyabs 0E-141 -> 0E-141
|
||||
ddcpa118 copyabs -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddcpa121 copyabs 2682682682682682 -> 2682682682682682
|
||||
ddcpa122 copyabs -2682682682682682 -> 2682682682682682
|
||||
ddcpa123 copyabs 1341341341341341 -> 1341341341341341
|
||||
ddcpa124 copyabs -1341341341341341 -> 1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddcpa131 copyabs 9.999999999999999E+384 -> 9.999999999999999E+384
|
||||
ddcpa132 copyabs 1E-383 -> 1E-383
|
||||
ddcpa133 copyabs 1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddcpa134 copyabs 1E-398 -> 1E-398
|
||||
|
||||
ddcpa135 copyabs -1E-398 -> 1E-398
|
||||
ddcpa136 copyabs -1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddcpa137 copyabs -1E-383 -> 1E-383
|
||||
ddcpa138 copyabs -9.999999999999999E+384 -> 9.999999999999999E+384
|
@ -0,0 +1,88 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCopyNegate.decTest -- quiet decDouble copy and negate --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check
|
||||
ddcpn001 copynegate +7.50 -> -7.50
|
||||
|
||||
-- Infinities
|
||||
ddcpn011 copynegate Infinity -> -Infinity
|
||||
ddcpn012 copynegate -Infinity -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddcpn021 copynegate NaN -> -NaN
|
||||
ddcpn022 copynegate -NaN -> NaN
|
||||
ddcpn023 copynegate sNaN -> -sNaN
|
||||
ddcpn024 copynegate -sNaN -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddcpn031 copynegate NaN13 -> -NaN13
|
||||
ddcpn032 copynegate -NaN13 -> NaN13
|
||||
ddcpn033 copynegate sNaN13 -> -sNaN13
|
||||
ddcpn034 copynegate -sNaN13 -> sNaN13
|
||||
ddcpn035 copynegate NaN70 -> -NaN70
|
||||
ddcpn036 copynegate -NaN70 -> NaN70
|
||||
ddcpn037 copynegate sNaN101 -> -sNaN101
|
||||
ddcpn038 copynegate -sNaN101 -> sNaN101
|
||||
|
||||
-- finites
|
||||
ddcpn101 copynegate 7 -> -7
|
||||
ddcpn102 copynegate -7 -> 7
|
||||
ddcpn103 copynegate 75 -> -75
|
||||
ddcpn104 copynegate -75 -> 75
|
||||
ddcpn105 copynegate 7.50 -> -7.50
|
||||
ddcpn106 copynegate -7.50 -> 7.50
|
||||
ddcpn107 copynegate 7.500 -> -7.500
|
||||
ddcpn108 copynegate -7.500 -> 7.500
|
||||
|
||||
-- zeros
|
||||
ddcpn111 copynegate 0 -> -0
|
||||
ddcpn112 copynegate -0 -> 0
|
||||
ddcpn113 copynegate 0E+4 -> -0E+4
|
||||
ddcpn114 copynegate -0E+4 -> 0E+4
|
||||
ddcpn115 copynegate 0.0000 -> -0.0000
|
||||
ddcpn116 copynegate -0.0000 -> 0.0000
|
||||
ddcpn117 copynegate 0E-141 -> -0E-141
|
||||
ddcpn118 copynegate -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddcpn121 copynegate 2682682682682682 -> -2682682682682682
|
||||
ddcpn122 copynegate -2682682682682682 -> 2682682682682682
|
||||
ddcpn123 copynegate 1341341341341341 -> -1341341341341341
|
||||
ddcpn124 copynegate -1341341341341341 -> 1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddcpn131 copynegate 9.999999999999999E+384 -> -9.999999999999999E+384
|
||||
ddcpn132 copynegate 1E-383 -> -1E-383
|
||||
ddcpn133 copynegate 1.000000000000000E-383 -> -1.000000000000000E-383
|
||||
ddcpn134 copynegate 1E-398 -> -1E-398
|
||||
|
||||
ddcpn135 copynegate -1E-398 -> 1E-398
|
||||
ddcpn136 copynegate -1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddcpn137 copynegate -1E-383 -> 1E-383
|
||||
ddcpn138 copynegate -9.999999999999999E+384 -> 9.999999999999999E+384
|
@ -0,0 +1,175 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddCopySign.decTest -- quiet decDouble copy with sign from rhs --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check
|
||||
ddcps001 copysign +7.50 11 -> 7.50
|
||||
|
||||
-- Infinities
|
||||
ddcps011 copysign Infinity 11 -> Infinity
|
||||
ddcps012 copysign -Infinity 11 -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddcps021 copysign NaN 11 -> NaN
|
||||
ddcps022 copysign -NaN 11 -> NaN
|
||||
ddcps023 copysign sNaN 11 -> sNaN
|
||||
ddcps024 copysign -sNaN 11 -> sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddcps031 copysign NaN10 11 -> NaN10
|
||||
ddcps032 copysign -NaN10 11 -> NaN10
|
||||
ddcps033 copysign sNaN10 11 -> sNaN10
|
||||
ddcps034 copysign -sNaN10 11 -> sNaN10
|
||||
ddcps035 copysign NaN7 11 -> NaN7
|
||||
ddcps036 copysign -NaN7 11 -> NaN7
|
||||
ddcps037 copysign sNaN101 11 -> sNaN101
|
||||
ddcps038 copysign -sNaN101 11 -> sNaN101
|
||||
|
||||
-- finites
|
||||
ddcps101 copysign 7 11 -> 7
|
||||
ddcps102 copysign -7 11 -> 7
|
||||
ddcps103 copysign 75 11 -> 75
|
||||
ddcps104 copysign -75 11 -> 75
|
||||
ddcps105 copysign 7.50 11 -> 7.50
|
||||
ddcps106 copysign -7.50 11 -> 7.50
|
||||
ddcps107 copysign 7.500 11 -> 7.500
|
||||
ddcps108 copysign -7.500 11 -> 7.500
|
||||
|
||||
-- zeros
|
||||
ddcps111 copysign 0 11 -> 0
|
||||
ddcps112 copysign -0 11 -> 0
|
||||
ddcps113 copysign 0E+4 11 -> 0E+4
|
||||
ddcps114 copysign -0E+4 11 -> 0E+4
|
||||
ddcps115 copysign 0.0000 11 -> 0.0000
|
||||
ddcps116 copysign -0.0000 11 -> 0.0000
|
||||
ddcps117 copysign 0E-141 11 -> 0E-141
|
||||
ddcps118 copysign -0E-141 11 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddcps121 copysign 2682682682682682 11 -> 2682682682682682
|
||||
ddcps122 copysign -2682682682682682 11 -> 2682682682682682
|
||||
ddcps123 copysign 1341341341341341 11 -> 1341341341341341
|
||||
ddcps124 copysign -1341341341341341 11 -> 1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddcps131 copysign 9.999999999999999E+384 11 -> 9.999999999999999E+384
|
||||
ddcps132 copysign 1E-383 11 -> 1E-383
|
||||
ddcps133 copysign 1.000000000000000E-383 11 -> 1.000000000000000E-383
|
||||
ddcps134 copysign 1E-398 11 -> 1E-398
|
||||
|
||||
ddcps135 copysign -1E-398 11 -> 1E-398
|
||||
ddcps136 copysign -1.000000000000000E-383 11 -> 1.000000000000000E-383
|
||||
ddcps137 copysign -1E-383 11 -> 1E-383
|
||||
ddcps138 copysign -9.999999999999999E+384 11 -> 9.999999999999999E+384
|
||||
|
||||
-- repeat with negative RHS
|
||||
|
||||
-- Infinities
|
||||
ddcps211 copysign Infinity -34 -> -Infinity
|
||||
ddcps212 copysign -Infinity -34 -> -Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddcps221 copysign NaN -34 -> -NaN
|
||||
ddcps222 copysign -NaN -34 -> -NaN
|
||||
ddcps223 copysign sNaN -34 -> -sNaN
|
||||
ddcps224 copysign -sNaN -34 -> -sNaN
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddcps231 copysign NaN10 -34 -> -NaN10
|
||||
ddcps232 copysign -NaN10 -34 -> -NaN10
|
||||
ddcps233 copysign sNaN10 -34 -> -sNaN10
|
||||
ddcps234 copysign -sNaN10 -34 -> -sNaN10
|
||||
ddcps235 copysign NaN7 -34 -> -NaN7
|
||||
ddcps236 copysign -NaN7 -34 -> -NaN7
|
||||
ddcps237 copysign sNaN101 -34 -> -sNaN101
|
||||
ddcps238 copysign -sNaN101 -34 -> -sNaN101
|
||||
|
||||
-- finites
|
||||
ddcps301 copysign 7 -34 -> -7
|
||||
ddcps302 copysign -7 -34 -> -7
|
||||
ddcps303 copysign 75 -34 -> -75
|
||||
ddcps304 copysign -75 -34 -> -75
|
||||
ddcps305 copysign 7.50 -34 -> -7.50
|
||||
ddcps306 copysign -7.50 -34 -> -7.50
|
||||
ddcps307 copysign 7.500 -34 -> -7.500
|
||||
ddcps308 copysign -7.500 -34 -> -7.500
|
||||
|
||||
-- zeros
|
||||
ddcps311 copysign 0 -34 -> -0
|
||||
ddcps312 copysign -0 -34 -> -0
|
||||
ddcps313 copysign 0E+4 -34 -> -0E+4
|
||||
ddcps314 copysign -0E+4 -34 -> -0E+4
|
||||
ddcps315 copysign 0.0000 -34 -> -0.0000
|
||||
ddcps316 copysign -0.0000 -34 -> -0.0000
|
||||
ddcps317 copysign 0E-141 -34 -> -0E-141
|
||||
ddcps318 copysign -0E-141 -34 -> -0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddcps321 copysign 2682682682682682 -34 -> -2682682682682682
|
||||
ddcps322 copysign -2682682682682682 -34 -> -2682682682682682
|
||||
ddcps323 copysign 1341341341341341 -34 -> -1341341341341341
|
||||
ddcps324 copysign -1341341341341341 -34 -> -1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddcps331 copysign 9.999999999999999E+384 -34 -> -9.999999999999999E+384
|
||||
ddcps332 copysign 1E-383 -34 -> -1E-383
|
||||
ddcps333 copysign 1.000000000000000E-383 -34 -> -1.000000000000000E-383
|
||||
ddcps334 copysign 1E-398 -34 -> -1E-398
|
||||
|
||||
ddcps335 copysign -1E-398 -34 -> -1E-398
|
||||
ddcps336 copysign -1.000000000000000E-383 -34 -> -1.000000000000000E-383
|
||||
ddcps337 copysign -1E-383 -34 -> -1E-383
|
||||
ddcps338 copysign -9.999999999999999E+384 -34 -> -9.999999999999999E+384
|
||||
|
||||
-- Other kinds of RHS
|
||||
ddcps401 copysign 701 -34 -> -701
|
||||
ddcps402 copysign -720 -34 -> -720
|
||||
ddcps403 copysign 701 -0 -> -701
|
||||
ddcps404 copysign -720 -0 -> -720
|
||||
ddcps405 copysign 701 +0 -> 701
|
||||
ddcps406 copysign -720 +0 -> 720
|
||||
ddcps407 copysign 701 +34 -> 701
|
||||
ddcps408 copysign -720 +34 -> 720
|
||||
|
||||
ddcps413 copysign 701 -Inf -> -701
|
||||
ddcps414 copysign -720 -Inf -> -720
|
||||
ddcps415 copysign 701 +Inf -> 701
|
||||
ddcps416 copysign -720 +Inf -> 720
|
||||
|
||||
ddcps420 copysign 701 -NaN -> -701
|
||||
ddcps421 copysign -720 -NaN -> -720
|
||||
ddcps422 copysign 701 +NaN -> 701
|
||||
ddcps423 copysign -720 +NaN -> 720
|
||||
ddcps425 copysign -720 +NaN8 -> 720
|
||||
|
||||
ddcps426 copysign 701 -sNaN -> -701
|
||||
ddcps427 copysign -720 -sNaN -> -720
|
||||
ddcps428 copysign 701 +sNaN -> 701
|
||||
ddcps429 copysign -720 +sNaN -> 720
|
||||
ddcps430 copysign -720 +sNaN3 -> 720
|
||||
|
@ -0,0 +1,854 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddDivide.decTest -- decDouble division --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
dddiv001 divide 1 1 -> 1
|
||||
dddiv002 divide 2 1 -> 2
|
||||
dddiv003 divide 1 2 -> 0.5
|
||||
dddiv004 divide 2 2 -> 1
|
||||
dddiv005 divide 0 1 -> 0
|
||||
dddiv006 divide 0 2 -> 0
|
||||
dddiv007 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv008 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv009 divide 3 3 -> 1
|
||||
|
||||
dddiv010 divide 2.4 1 -> 2.4
|
||||
dddiv011 divide 2.4 -1 -> -2.4
|
||||
dddiv012 divide -2.4 1 -> -2.4
|
||||
dddiv013 divide -2.4 -1 -> 2.4
|
||||
dddiv014 divide 2.40 1 -> 2.40
|
||||
dddiv015 divide 2.400 1 -> 2.400
|
||||
dddiv016 divide 2.4 2 -> 1.2
|
||||
dddiv017 divide 2.400 2 -> 1.200
|
||||
dddiv018 divide 2. 2 -> 1
|
||||
dddiv019 divide 20 20 -> 1
|
||||
|
||||
dddiv020 divide 187 187 -> 1
|
||||
dddiv021 divide 5 2 -> 2.5
|
||||
dddiv022 divide 50 20 -> 2.5
|
||||
dddiv023 divide 500 200 -> 2.5
|
||||
dddiv024 divide 50.0 20.0 -> 2.5
|
||||
dddiv025 divide 5.00 2.00 -> 2.5
|
||||
dddiv026 divide 5 2.0 -> 2.5
|
||||
dddiv027 divide 5 2.000 -> 2.5
|
||||
dddiv028 divide 5 0.20 -> 25
|
||||
dddiv029 divide 5 0.200 -> 25
|
||||
dddiv030 divide 10 1 -> 10
|
||||
dddiv031 divide 100 1 -> 100
|
||||
dddiv032 divide 1000 1 -> 1000
|
||||
dddiv033 divide 1000 100 -> 10
|
||||
|
||||
dddiv035 divide 1 2 -> 0.5
|
||||
dddiv036 divide 1 4 -> 0.25
|
||||
dddiv037 divide 1 8 -> 0.125
|
||||
dddiv038 divide 1 16 -> 0.0625
|
||||
dddiv039 divide 1 32 -> 0.03125
|
||||
dddiv040 divide 1 64 -> 0.015625
|
||||
dddiv041 divide 1 -2 -> -0.5
|
||||
dddiv042 divide 1 -4 -> -0.25
|
||||
dddiv043 divide 1 -8 -> -0.125
|
||||
dddiv044 divide 1 -16 -> -0.0625
|
||||
dddiv045 divide 1 -32 -> -0.03125
|
||||
dddiv046 divide 1 -64 -> -0.015625
|
||||
dddiv047 divide -1 2 -> -0.5
|
||||
dddiv048 divide -1 4 -> -0.25
|
||||
dddiv049 divide -1 8 -> -0.125
|
||||
dddiv050 divide -1 16 -> -0.0625
|
||||
dddiv051 divide -1 32 -> -0.03125
|
||||
dddiv052 divide -1 64 -> -0.015625
|
||||
dddiv053 divide -1 -2 -> 0.5
|
||||
dddiv054 divide -1 -4 -> 0.25
|
||||
dddiv055 divide -1 -8 -> 0.125
|
||||
dddiv056 divide -1 -16 -> 0.0625
|
||||
dddiv057 divide -1 -32 -> 0.03125
|
||||
dddiv058 divide -1 -64 -> 0.015625
|
||||
|
||||
-- bcdTime
|
||||
dddiv060 divide 1 7 -> 0.1428571428571429 Inexact Rounded
|
||||
dddiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717 Inexact Rounded
|
||||
|
||||
-- 1234567890123456
|
||||
dddiv071 divide 9999999999999999 1 -> 9999999999999999
|
||||
dddiv072 divide 999999999999999 1 -> 999999999999999
|
||||
dddiv073 divide 99999999999999 1 -> 99999999999999
|
||||
dddiv074 divide 9999999999999 1 -> 9999999999999
|
||||
dddiv075 divide 999999999999 1 -> 999999999999
|
||||
dddiv076 divide 99999999999 1 -> 99999999999
|
||||
dddiv077 divide 9999999999 1 -> 9999999999
|
||||
dddiv078 divide 999999999 1 -> 999999999
|
||||
dddiv079 divide 99999999 1 -> 99999999
|
||||
dddiv080 divide 9999999 1 -> 9999999
|
||||
dddiv081 divide 999999 1 -> 999999
|
||||
dddiv082 divide 99999 1 -> 99999
|
||||
dddiv083 divide 9999 1 -> 9999
|
||||
dddiv084 divide 999 1 -> 999
|
||||
dddiv085 divide 99 1 -> 99
|
||||
dddiv086 divide 9 1 -> 9
|
||||
|
||||
dddiv090 divide 0. 1 -> 0
|
||||
dddiv091 divide .0 1 -> 0.0
|
||||
dddiv092 divide 0.00 1 -> 0.00
|
||||
dddiv093 divide 0.00E+9 1 -> 0E+7
|
||||
dddiv094 divide 0.0000E-50 1 -> 0E-54
|
||||
|
||||
dddiv095 divide 1 1E-8 -> 1E+8
|
||||
dddiv096 divide 1 1E-9 -> 1E+9
|
||||
dddiv097 divide 1 1E-10 -> 1E+10
|
||||
dddiv098 divide 1 1E-11 -> 1E+11
|
||||
dddiv099 divide 1 1E-12 -> 1E+12
|
||||
|
||||
dddiv100 divide 1 1 -> 1
|
||||
dddiv101 divide 1 2 -> 0.5
|
||||
dddiv102 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv103 divide 1 4 -> 0.25
|
||||
dddiv104 divide 1 5 -> 0.2
|
||||
dddiv105 divide 1 6 -> 0.1666666666666667 Inexact Rounded
|
||||
dddiv106 divide 1 7 -> 0.1428571428571429 Inexact Rounded
|
||||
dddiv107 divide 1 8 -> 0.125
|
||||
dddiv108 divide 1 9 -> 0.1111111111111111 Inexact Rounded
|
||||
dddiv109 divide 1 10 -> 0.1
|
||||
dddiv110 divide 1 1 -> 1
|
||||
dddiv111 divide 2 1 -> 2
|
||||
dddiv112 divide 3 1 -> 3
|
||||
dddiv113 divide 4 1 -> 4
|
||||
dddiv114 divide 5 1 -> 5
|
||||
dddiv115 divide 6 1 -> 6
|
||||
dddiv116 divide 7 1 -> 7
|
||||
dddiv117 divide 8 1 -> 8
|
||||
dddiv118 divide 9 1 -> 9
|
||||
dddiv119 divide 10 1 -> 10
|
||||
|
||||
dddiv120 divide 3E+1 0.001 -> 3E+4
|
||||
dddiv121 divide 2.200 2 -> 1.100
|
||||
|
||||
dddiv130 divide 12345 4.999 -> 2469.493898779756 Inexact Rounded
|
||||
dddiv131 divide 12345 4.99 -> 2473.947895791583 Inexact Rounded
|
||||
dddiv132 divide 12345 4.9 -> 2519.387755102041 Inexact Rounded
|
||||
dddiv133 divide 12345 5 -> 2469
|
||||
dddiv134 divide 12345 5.1 -> 2420.588235294118 Inexact Rounded
|
||||
dddiv135 divide 12345 5.01 -> 2464.071856287425 Inexact Rounded
|
||||
dddiv136 divide 12345 5.001 -> 2468.506298740252 Inexact Rounded
|
||||
|
||||
-- test possibly imprecise results
|
||||
dddiv220 divide 391 597 -> 0.6549413735343384 Inexact Rounded
|
||||
dddiv221 divide 391 -597 -> -0.6549413735343384 Inexact Rounded
|
||||
dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded
|
||||
dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded
|
||||
|
||||
-- test some cases that are close to exponent overflow
|
||||
dddiv270 divide 1 1e384 -> 1E-384 Subnormal
|
||||
dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow
|
||||
dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow
|
||||
dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384 Rounded Inexact Subnormal Underflow
|
||||
dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped
|
||||
dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped
|
||||
dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped
|
||||
dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384
|
||||
|
||||
-- Divide into 0 tests
|
||||
dddiv301 divide 0 7 -> 0
|
||||
dddiv302 divide 0 7E-5 -> 0E+5
|
||||
dddiv303 divide 0 7E-1 -> 0E+1
|
||||
dddiv304 divide 0 7E+1 -> 0.0
|
||||
dddiv305 divide 0 7E+5 -> 0.00000
|
||||
dddiv306 divide 0 7E+6 -> 0.000000
|
||||
dddiv307 divide 0 7E+7 -> 0E-7
|
||||
dddiv308 divide 0 70E-5 -> 0E+5
|
||||
dddiv309 divide 0 70E-1 -> 0E+1
|
||||
dddiv310 divide 0 70E+0 -> 0
|
||||
dddiv311 divide 0 70E+1 -> 0.0
|
||||
dddiv312 divide 0 70E+5 -> 0.00000
|
||||
dddiv313 divide 0 70E+6 -> 0.000000
|
||||
dddiv314 divide 0 70E+7 -> 0E-7
|
||||
dddiv315 divide 0 700E-5 -> 0E+5
|
||||
dddiv316 divide 0 700E-1 -> 0E+1
|
||||
dddiv317 divide 0 700E+0 -> 0
|
||||
dddiv318 divide 0 700E+1 -> 0.0
|
||||
dddiv319 divide 0 700E+5 -> 0.00000
|
||||
dddiv320 divide 0 700E+6 -> 0.000000
|
||||
dddiv321 divide 0 700E+7 -> 0E-7
|
||||
dddiv322 divide 0 700E+77 -> 0E-77
|
||||
|
||||
dddiv331 divide 0E-3 7E-5 -> 0E+2
|
||||
dddiv332 divide 0E-3 7E-1 -> 0.00
|
||||
dddiv333 divide 0E-3 7E+1 -> 0.0000
|
||||
dddiv334 divide 0E-3 7E+5 -> 0E-8
|
||||
dddiv335 divide 0E-1 7E-5 -> 0E+4
|
||||
dddiv336 divide 0E-1 7E-1 -> 0
|
||||
dddiv337 divide 0E-1 7E+1 -> 0.00
|
||||
dddiv338 divide 0E-1 7E+5 -> 0.000000
|
||||
dddiv339 divide 0E+1 7E-5 -> 0E+6
|
||||
dddiv340 divide 0E+1 7E-1 -> 0E+2
|
||||
dddiv341 divide 0E+1 7E+1 -> 0
|
||||
dddiv342 divide 0E+1 7E+5 -> 0.0000
|
||||
dddiv343 divide 0E+3 7E-5 -> 0E+8
|
||||
dddiv344 divide 0E+3 7E-1 -> 0E+4
|
||||
dddiv345 divide 0E+3 7E+1 -> 0E+2
|
||||
dddiv346 divide 0E+3 7E+5 -> 0.00
|
||||
|
||||
-- These were 'input rounding'
|
||||
dddiv441 divide 12345678000 1 -> 12345678000
|
||||
dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
|
||||
dddiv443 divide 1234567800 1 -> 1234567800
|
||||
dddiv444 divide 1 1234567800 -> 8.100000664200054E-10 Inexact Rounded
|
||||
dddiv445 divide 1234567890 1 -> 1234567890
|
||||
dddiv446 divide 1 1234567890 -> 8.100000073710001E-10 Inexact Rounded
|
||||
dddiv447 divide 1234567891 1 -> 1234567891
|
||||
dddiv448 divide 1 1234567891 -> 8.100000067149001E-10 Inexact Rounded
|
||||
dddiv449 divide 12345678901 1 -> 12345678901
|
||||
dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
|
||||
dddiv451 divide 1234567896 1 -> 1234567896
|
||||
dddiv452 divide 1 1234567896 -> 8.100000034344000E-10 Inexact Rounded
|
||||
|
||||
-- high-lows
|
||||
dddiv453 divide 1e+1 1 -> 1E+1
|
||||
dddiv454 divide 1e+1 1.0 -> 1E+1
|
||||
dddiv455 divide 1e+1 1.00 -> 1E+1
|
||||
dddiv456 divide 1e+2 2 -> 5E+1
|
||||
dddiv457 divide 1e+2 2.0 -> 5E+1
|
||||
dddiv458 divide 1e+2 2.00 -> 5E+1
|
||||
|
||||
-- some from IEEE discussions
|
||||
dddiv460 divide 3e0 2e0 -> 1.5
|
||||
dddiv461 divide 30e-1 2e0 -> 1.5
|
||||
dddiv462 divide 300e-2 2e0 -> 1.50
|
||||
dddiv464 divide 3000e-3 2e0 -> 1.500
|
||||
dddiv465 divide 3e0 20e-1 -> 1.5
|
||||
dddiv466 divide 30e-1 20e-1 -> 1.5
|
||||
dddiv467 divide 300e-2 20e-1 -> 1.5
|
||||
dddiv468 divide 3000e-3 20e-1 -> 1.50
|
||||
dddiv469 divide 3e0 200e-2 -> 1.5
|
||||
dddiv470 divide 30e-1 200e-2 -> 1.5
|
||||
dddiv471 divide 300e-2 200e-2 -> 1.5
|
||||
dddiv472 divide 3000e-3 200e-2 -> 1.5
|
||||
dddiv473 divide 3e0 2000e-3 -> 1.5
|
||||
dddiv474 divide 30e-1 2000e-3 -> 1.5
|
||||
dddiv475 divide 300e-2 2000e-3 -> 1.5
|
||||
dddiv476 divide 3000e-3 2000e-3 -> 1.5
|
||||
|
||||
-- some reciprocals
|
||||
dddiv480 divide 1 1.0E+33 -> 1E-33
|
||||
dddiv481 divide 1 10E+33 -> 1E-34
|
||||
dddiv482 divide 1 1.0E-33 -> 1E+33
|
||||
dddiv483 divide 1 10E-33 -> 1E+32
|
||||
|
||||
-- RMS discussion table
|
||||
dddiv484 divide 0e5 1e3 -> 0E+2
|
||||
dddiv485 divide 0e5 2e3 -> 0E+2
|
||||
dddiv486 divide 0e5 10e2 -> 0E+3
|
||||
dddiv487 divide 0e5 20e2 -> 0E+3
|
||||
dddiv488 divide 0e5 100e1 -> 0E+4
|
||||
dddiv489 divide 0e5 200e1 -> 0E+4
|
||||
|
||||
dddiv491 divide 1e5 1e3 -> 1E+2
|
||||
dddiv492 divide 1e5 2e3 -> 5E+1
|
||||
dddiv493 divide 1e5 10e2 -> 1E+2
|
||||
dddiv494 divide 1e5 20e2 -> 5E+1
|
||||
dddiv495 divide 1e5 100e1 -> 1E+2
|
||||
dddiv496 divide 1e5 200e1 -> 5E+1
|
||||
|
||||
-- tryzeros cases
|
||||
rounding: half_up
|
||||
dddiv497 divide 0E+380 1000E-13 -> 0E+369 Clamped
|
||||
dddiv498 divide 0E-390 1000E+13 -> 0E-398 Clamped
|
||||
|
||||
rounding: half_up
|
||||
|
||||
-- focus on trailing zeros issues
|
||||
dddiv500 divide 1 9.9 -> 0.1010101010101010 Inexact Rounded
|
||||
dddiv501 divide 1 9.09 -> 0.1100110011001100 Inexact Rounded
|
||||
dddiv502 divide 1 9.009 -> 0.1110001110001110 Inexact Rounded
|
||||
|
||||
dddiv511 divide 1 2 -> 0.5
|
||||
dddiv512 divide 1.0 2 -> 0.5
|
||||
dddiv513 divide 1.00 2 -> 0.50
|
||||
dddiv514 divide 1.000 2 -> 0.500
|
||||
dddiv515 divide 1.0000 2 -> 0.5000
|
||||
dddiv516 divide 1.00000 2 -> 0.50000
|
||||
dddiv517 divide 1.000000 2 -> 0.500000
|
||||
dddiv518 divide 1.0000000 2 -> 0.5000000
|
||||
dddiv519 divide 1.00 2.00 -> 0.5
|
||||
|
||||
dddiv521 divide 2 1 -> 2
|
||||
dddiv522 divide 2 1.0 -> 2
|
||||
dddiv523 divide 2 1.00 -> 2
|
||||
dddiv524 divide 2 1.000 -> 2
|
||||
dddiv525 divide 2 1.0000 -> 2
|
||||
dddiv526 divide 2 1.00000 -> 2
|
||||
dddiv527 divide 2 1.000000 -> 2
|
||||
dddiv528 divide 2 1.0000000 -> 2
|
||||
dddiv529 divide 2.00 1.00 -> 2
|
||||
|
||||
dddiv530 divide 2.40 2 -> 1.20
|
||||
dddiv531 divide 2.40 4 -> 0.60
|
||||
dddiv532 divide 2.40 10 -> 0.24
|
||||
dddiv533 divide 2.40 2.0 -> 1.2
|
||||
dddiv534 divide 2.40 4.0 -> 0.6
|
||||
dddiv535 divide 2.40 10.0 -> 0.24
|
||||
dddiv536 divide 2.40 2.00 -> 1.2
|
||||
dddiv537 divide 2.40 4.00 -> 0.6
|
||||
dddiv538 divide 2.40 10.00 -> 0.24
|
||||
dddiv539 divide 0.9 0.1 -> 9
|
||||
dddiv540 divide 0.9 0.01 -> 9E+1
|
||||
dddiv541 divide 0.9 0.001 -> 9E+2
|
||||
dddiv542 divide 5 2 -> 2.5
|
||||
dddiv543 divide 5 2.0 -> 2.5
|
||||
dddiv544 divide 5 2.00 -> 2.5
|
||||
dddiv545 divide 5 20 -> 0.25
|
||||
dddiv546 divide 5 20.0 -> 0.25
|
||||
dddiv547 divide 2.400 2 -> 1.200
|
||||
dddiv548 divide 2.400 2.0 -> 1.20
|
||||
dddiv549 divide 2.400 2.400 -> 1
|
||||
|
||||
dddiv550 divide 240 1 -> 240
|
||||
dddiv551 divide 240 10 -> 24
|
||||
dddiv552 divide 240 100 -> 2.4
|
||||
dddiv553 divide 240 1000 -> 0.24
|
||||
dddiv554 divide 2400 1 -> 2400
|
||||
dddiv555 divide 2400 10 -> 240
|
||||
dddiv556 divide 2400 100 -> 24
|
||||
dddiv557 divide 2400 1000 -> 2.4
|
||||
|
||||
-- +ve exponent
|
||||
dddiv600 divide 2.4E+9 2 -> 1.2E+9
|
||||
dddiv601 divide 2.40E+9 2 -> 1.20E+9
|
||||
dddiv602 divide 2.400E+9 2 -> 1.200E+9
|
||||
dddiv603 divide 2.4000E+9 2 -> 1.2000E+9
|
||||
dddiv604 divide 24E+8 2 -> 1.2E+9
|
||||
dddiv605 divide 240E+7 2 -> 1.20E+9
|
||||
dddiv606 divide 2400E+6 2 -> 1.200E+9
|
||||
dddiv607 divide 24000E+5 2 -> 1.2000E+9
|
||||
|
||||
-- more zeros, etc.
|
||||
dddiv731 divide 5.00 1E-3 -> 5.00E+3
|
||||
dddiv732 divide 00.00 0.000 -> NaN Division_undefined
|
||||
dddiv733 divide 00.00 0E-3 -> NaN Division_undefined
|
||||
dddiv734 divide 0 -0 -> NaN Division_undefined
|
||||
dddiv735 divide -0 0 -> NaN Division_undefined
|
||||
dddiv736 divide -0 -0 -> NaN Division_undefined
|
||||
|
||||
dddiv741 divide 0 -1 -> -0
|
||||
dddiv742 divide -0 -1 -> 0
|
||||
dddiv743 divide 0 1 -> 0
|
||||
dddiv744 divide -0 1 -> -0
|
||||
dddiv745 divide -1 0 -> -Infinity Division_by_zero
|
||||
dddiv746 divide -1 -0 -> Infinity Division_by_zero
|
||||
dddiv747 divide 1 0 -> Infinity Division_by_zero
|
||||
dddiv748 divide 1 -0 -> -Infinity Division_by_zero
|
||||
|
||||
dddiv751 divide 0.0 -1 -> -0.0
|
||||
dddiv752 divide -0.0 -1 -> 0.0
|
||||
dddiv753 divide 0.0 1 -> 0.0
|
||||
dddiv754 divide -0.0 1 -> -0.0
|
||||
dddiv755 divide -1.0 0 -> -Infinity Division_by_zero
|
||||
dddiv756 divide -1.0 -0 -> Infinity Division_by_zero
|
||||
dddiv757 divide 1.0 0 -> Infinity Division_by_zero
|
||||
dddiv758 divide 1.0 -0 -> -Infinity Division_by_zero
|
||||
|
||||
dddiv761 divide 0 -1.0 -> -0E+1
|
||||
dddiv762 divide -0 -1.0 -> 0E+1
|
||||
dddiv763 divide 0 1.0 -> 0E+1
|
||||
dddiv764 divide -0 1.0 -> -0E+1
|
||||
dddiv765 divide -1 0.0 -> -Infinity Division_by_zero
|
||||
dddiv766 divide -1 -0.0 -> Infinity Division_by_zero
|
||||
dddiv767 divide 1 0.0 -> Infinity Division_by_zero
|
||||
dddiv768 divide 1 -0.0 -> -Infinity Division_by_zero
|
||||
|
||||
dddiv771 divide 0.0 -1.0 -> -0
|
||||
dddiv772 divide -0.0 -1.0 -> 0
|
||||
dddiv773 divide 0.0 1.0 -> 0
|
||||
dddiv774 divide -0.0 1.0 -> -0
|
||||
dddiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
|
||||
dddiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
|
||||
dddiv777 divide 1.0 0.0 -> Infinity Division_by_zero
|
||||
dddiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
|
||||
|
||||
-- Specials
|
||||
dddiv780 divide Inf -Inf -> NaN Invalid_operation
|
||||
dddiv781 divide Inf -1000 -> -Infinity
|
||||
dddiv782 divide Inf -1 -> -Infinity
|
||||
dddiv783 divide Inf -0 -> -Infinity
|
||||
dddiv784 divide Inf 0 -> Infinity
|
||||
dddiv785 divide Inf 1 -> Infinity
|
||||
dddiv786 divide Inf 1000 -> Infinity
|
||||
dddiv787 divide Inf Inf -> NaN Invalid_operation
|
||||
dddiv788 divide -1000 Inf -> -0E-398 Clamped
|
||||
dddiv789 divide -Inf Inf -> NaN Invalid_operation
|
||||
dddiv790 divide -1 Inf -> -0E-398 Clamped
|
||||
dddiv791 divide -0 Inf -> -0E-398 Clamped
|
||||
dddiv792 divide 0 Inf -> 0E-398 Clamped
|
||||
dddiv793 divide 1 Inf -> 0E-398 Clamped
|
||||
dddiv794 divide 1000 Inf -> 0E-398 Clamped
|
||||
dddiv795 divide Inf Inf -> NaN Invalid_operation
|
||||
|
||||
dddiv800 divide -Inf -Inf -> NaN Invalid_operation
|
||||
dddiv801 divide -Inf -1000 -> Infinity
|
||||
dddiv802 divide -Inf -1 -> Infinity
|
||||
dddiv803 divide -Inf -0 -> Infinity
|
||||
dddiv804 divide -Inf 0 -> -Infinity
|
||||
dddiv805 divide -Inf 1 -> -Infinity
|
||||
dddiv806 divide -Inf 1000 -> -Infinity
|
||||
dddiv807 divide -Inf Inf -> NaN Invalid_operation
|
||||
dddiv808 divide -1000 Inf -> -0E-398 Clamped
|
||||
dddiv809 divide -Inf -Inf -> NaN Invalid_operation
|
||||
dddiv810 divide -1 -Inf -> 0E-398 Clamped
|
||||
dddiv811 divide -0 -Inf -> 0E-398 Clamped
|
||||
dddiv812 divide 0 -Inf -> -0E-398 Clamped
|
||||
dddiv813 divide 1 -Inf -> -0E-398 Clamped
|
||||
dddiv814 divide 1000 -Inf -> -0E-398 Clamped
|
||||
dddiv815 divide Inf -Inf -> NaN Invalid_operation
|
||||
|
||||
dddiv821 divide NaN -Inf -> NaN
|
||||
dddiv822 divide NaN -1000 -> NaN
|
||||
dddiv823 divide NaN -1 -> NaN
|
||||
dddiv824 divide NaN -0 -> NaN
|
||||
dddiv825 divide NaN 0 -> NaN
|
||||
dddiv826 divide NaN 1 -> NaN
|
||||
dddiv827 divide NaN 1000 -> NaN
|
||||
dddiv828 divide NaN Inf -> NaN
|
||||
dddiv829 divide NaN NaN -> NaN
|
||||
dddiv830 divide -Inf NaN -> NaN
|
||||
dddiv831 divide -1000 NaN -> NaN
|
||||
dddiv832 divide -1 NaN -> NaN
|
||||
dddiv833 divide -0 NaN -> NaN
|
||||
dddiv834 divide 0 NaN -> NaN
|
||||
dddiv835 divide 1 NaN -> NaN
|
||||
dddiv836 divide 1000 NaN -> NaN
|
||||
dddiv837 divide Inf NaN -> NaN
|
||||
|
||||
dddiv841 divide sNaN -Inf -> NaN Invalid_operation
|
||||
dddiv842 divide sNaN -1000 -> NaN Invalid_operation
|
||||
dddiv843 divide sNaN -1 -> NaN Invalid_operation
|
||||
dddiv844 divide sNaN -0 -> NaN Invalid_operation
|
||||
dddiv845 divide sNaN 0 -> NaN Invalid_operation
|
||||
dddiv846 divide sNaN 1 -> NaN Invalid_operation
|
||||
dddiv847 divide sNaN 1000 -> NaN Invalid_operation
|
||||
dddiv848 divide sNaN NaN -> NaN Invalid_operation
|
||||
dddiv849 divide sNaN sNaN -> NaN Invalid_operation
|
||||
dddiv850 divide NaN sNaN -> NaN Invalid_operation
|
||||
dddiv851 divide -Inf sNaN -> NaN Invalid_operation
|
||||
dddiv852 divide -1000 sNaN -> NaN Invalid_operation
|
||||
dddiv853 divide -1 sNaN -> NaN Invalid_operation
|
||||
dddiv854 divide -0 sNaN -> NaN Invalid_operation
|
||||
dddiv855 divide 0 sNaN -> NaN Invalid_operation
|
||||
dddiv856 divide 1 sNaN -> NaN Invalid_operation
|
||||
dddiv857 divide 1000 sNaN -> NaN Invalid_operation
|
||||
dddiv858 divide Inf sNaN -> NaN Invalid_operation
|
||||
dddiv859 divide NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
dddiv861 divide NaN9 -Inf -> NaN9
|
||||
dddiv862 divide NaN8 1000 -> NaN8
|
||||
dddiv863 divide NaN7 Inf -> NaN7
|
||||
dddiv864 divide NaN6 NaN5 -> NaN6
|
||||
dddiv865 divide -Inf NaN4 -> NaN4
|
||||
dddiv866 divide -1000 NaN3 -> NaN3
|
||||
dddiv867 divide Inf NaN2 -> NaN2
|
||||
|
||||
dddiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
dddiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
|
||||
dddiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
|
||||
dddiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
|
||||
dddiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
dddiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
dddiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
|
||||
dddiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
|
||||
dddiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
|
||||
|
||||
dddiv881 divide -NaN9 -Inf -> -NaN9
|
||||
dddiv882 divide -NaN8 1000 -> -NaN8
|
||||
dddiv883 divide -NaN7 Inf -> -NaN7
|
||||
dddiv884 divide -NaN6 -NaN5 -> -NaN6
|
||||
dddiv885 divide -Inf -NaN4 -> -NaN4
|
||||
dddiv886 divide -1000 -NaN3 -> -NaN3
|
||||
dddiv887 divide Inf -NaN2 -> -NaN2
|
||||
|
||||
dddiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
dddiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
|
||||
dddiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
|
||||
dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
|
||||
dddiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
|
||||
dddiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
|
||||
dddiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
|
||||
dddiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
dddiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
|
||||
|
||||
-- Various flavours of divide by 0
|
||||
dddiv901 divide 0 0 -> NaN Division_undefined
|
||||
dddiv902 divide 0.0E5 0 -> NaN Division_undefined
|
||||
dddiv903 divide 0.000 0 -> NaN Division_undefined
|
||||
dddiv904 divide 0.0001 0 -> Infinity Division_by_zero
|
||||
dddiv905 divide 0.01 0 -> Infinity Division_by_zero
|
||||
dddiv906 divide 0.1 0 -> Infinity Division_by_zero
|
||||
dddiv907 divide 1 0 -> Infinity Division_by_zero
|
||||
dddiv908 divide 1 0.0 -> Infinity Division_by_zero
|
||||
dddiv909 divide 10 0.0 -> Infinity Division_by_zero
|
||||
dddiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
|
||||
dddiv911 divide 1E+100 0 -> Infinity Division_by_zero
|
||||
|
||||
dddiv921 divide -0.0001 0 -> -Infinity Division_by_zero
|
||||
dddiv922 divide -0.01 0 -> -Infinity Division_by_zero
|
||||
dddiv923 divide -0.1 0 -> -Infinity Division_by_zero
|
||||
dddiv924 divide -1 0 -> -Infinity Division_by_zero
|
||||
dddiv925 divide -1 0.0 -> -Infinity Division_by_zero
|
||||
dddiv926 divide -10 0.0 -> -Infinity Division_by_zero
|
||||
dddiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
|
||||
dddiv928 divide -1E+100 0 -> -Infinity Division_by_zero
|
||||
|
||||
dddiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
|
||||
dddiv932 divide 0.01 -0 -> -Infinity Division_by_zero
|
||||
dddiv933 divide 0.1 -0 -> -Infinity Division_by_zero
|
||||
dddiv934 divide 1 -0 -> -Infinity Division_by_zero
|
||||
dddiv935 divide 1 -0.0 -> -Infinity Division_by_zero
|
||||
dddiv936 divide 10 -0.0 -> -Infinity Division_by_zero
|
||||
dddiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
|
||||
dddiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
|
||||
|
||||
dddiv941 divide -0.0001 -0 -> Infinity Division_by_zero
|
||||
dddiv942 divide -0.01 -0 -> Infinity Division_by_zero
|
||||
dddiv943 divide -0.1 -0 -> Infinity Division_by_zero
|
||||
dddiv944 divide -1 -0 -> Infinity Division_by_zero
|
||||
dddiv945 divide -1 -0.0 -> Infinity Division_by_zero
|
||||
dddiv946 divide -10 -0.0 -> Infinity Division_by_zero
|
||||
dddiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
|
||||
dddiv948 divide -1E+100 -0 -> Infinity Division_by_zero
|
||||
|
||||
-- Examples from SQL proposal (Krishna Kulkarni)
|
||||
dddiv1021 divide 1E0 1E0 -> 1
|
||||
dddiv1022 divide 1E0 2E0 -> 0.5
|
||||
dddiv1023 divide 1E0 3E0 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv1024 divide 100E-2 1000E-3 -> 1
|
||||
dddiv1025 divide 24E-1 2E0 -> 1.2
|
||||
dddiv1026 divide 2400E-3 2E0 -> 1.200
|
||||
dddiv1027 divide 5E0 2E0 -> 2.5
|
||||
dddiv1028 divide 5E0 20E-1 -> 2.5
|
||||
dddiv1029 divide 5E0 2000E-3 -> 2.5
|
||||
dddiv1030 divide 5E0 2E-1 -> 25
|
||||
dddiv1031 divide 5E0 20E-2 -> 25
|
||||
dddiv1032 divide 480E-2 3E0 -> 1.60
|
||||
dddiv1033 divide 47E-1 2E0 -> 2.35
|
||||
|
||||
-- ECMAScript bad examples
|
||||
rounding: half_down
|
||||
dddiv1040 divide 5 9 -> 0.5555555555555556 Inexact Rounded
|
||||
rounding: half_even
|
||||
dddiv1041 divide 6 11 -> 0.5454545454545455 Inexact Rounded
|
||||
|
||||
-- overflow and underflow tests .. note subnormal results
|
||||
-- signs
|
||||
dddiv1051 divide 1e+277 1e-311 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1052 divide 1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
|
||||
dddiv1053 divide -1e+277 1e-311 -> -Infinity Overflow Inexact Rounded
|
||||
dddiv1054 divide -1e+277 -1e-311 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1055 divide 1e-277 1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1056 divide 1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1057 divide -1e-277 1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1058 divide -1e-277 -1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
|
||||
-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
|
||||
dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
|
||||
dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
|
||||
dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
|
||||
dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
|
||||
dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
|
||||
dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
|
||||
dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
|
||||
dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
-- [no equivalent of 'subnormal' for overflow]
|
||||
dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381 Clamped
|
||||
dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382 Clamped
|
||||
dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383 Clamped
|
||||
dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384 Clamped
|
||||
dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
|
||||
dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded
|
||||
|
||||
dddiv1101 divide 1.0000E-394 1 -> 1.0000E-394 Subnormal
|
||||
dddiv1102 divide 1.000E-394 1e+1 -> 1.000E-395 Subnormal
|
||||
dddiv1103 divide 1.00E-394 1e+2 -> 1.00E-396 Subnormal
|
||||
dddiv1104 divide 1.0E-394 1e+3 -> 1.0E-397 Subnormal
|
||||
dddiv1105 divide 1.0E-394 1e+4 -> 1E-398 Subnormal Rounded
|
||||
dddiv1106 divide 1.3E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1107 divide 1.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1108 divide 1.7E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1109 divide 2.3E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1110 divide 2.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1111 divide 2.7E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1112 divide 1.49E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1113 divide 1.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1114 divide 1.51E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1115 divide 2.49E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1116 divide 2.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1117 divide 2.51E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
|
||||
|
||||
dddiv1118 divide 1E-394 1e+4 -> 1E-398 Subnormal
|
||||
dddiv1119 divide 3E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1120 divide 5E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1121 divide 7E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1122 divide 9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1123 divide 9.9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
|
||||
dddiv1124 divide 1E-394 -1e+4 -> -1E-398 Subnormal
|
||||
dddiv1125 divide 3E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1126 divide -5E-394 1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1127 divide 7E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1128 divide -9E-394 1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1129 divide 9.9E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
dddiv1130 divide 3.0E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
|
||||
dddiv1131 divide 1.0E-199 1e+200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
dddiv1132 divide 1.0E-199 1e+199 -> 1E-398 Subnormal Rounded
|
||||
dddiv1133 divide 1.0E-199 1e+198 -> 1.0E-397 Subnormal
|
||||
dddiv1134 divide 2.0E-199 2e+198 -> 1.0E-397 Subnormal
|
||||
dddiv1135 divide 4.0E-199 4e+198 -> 1.0E-397 Subnormal
|
||||
dddiv1136 divide 10.0E-199 10e+198 -> 1.0E-397 Subnormal
|
||||
dddiv1137 divide 30.0E-199 30e+198 -> 1.0E-397 Subnormal
|
||||
|
||||
-- randoms
|
||||
dddiv2010 divide -3.303226714900711E-35 8.796578842713183E+73 -> -3.755126594058783E-109 Inexact Rounded
|
||||
dddiv2011 divide 933153327821073.6 68782181090246.25 -> 13.56678885475763 Inexact Rounded
|
||||
dddiv2012 divide 5.04752436057906E-72 -8.179481771238642E+64 -> -6.170958627632835E-137 Inexact Rounded
|
||||
dddiv2013 divide -3707613309582318 3394911196503.048 -> -1092.109070010836 Inexact Rounded
|
||||
dddiv2014 divide 99689.0555190461 -4.735208553891464 -> -21052.72753765411 Inexact Rounded
|
||||
dddiv2015 divide -1447915775613329 269750797.8184875 -> -5367605.164925653 Inexact Rounded
|
||||
dddiv2016 divide -9.394881304225258E-19 -830585.0252671636 -> 1.131116143251358E-24 Inexact Rounded
|
||||
dddiv2017 divide -1.056283432738934 88.58754555124013 -> -0.01192361100159352 Inexact Rounded
|
||||
dddiv2018 divide 5763220933343.081 689089567025052.1 -> 0.008363529516524456 Inexact Rounded
|
||||
dddiv2019 divide 873819.122103216 9.740612494523300E-49 -> 8.970884763093948E+53 Inexact Rounded
|
||||
dddiv2020 divide 8022914.838533576 6178.566801742713 -> 1298.507420243583 Inexact Rounded
|
||||
dddiv2021 divide 203982.7605650363 -2158.283639053435 -> -94.51156320422168 Inexact Rounded
|
||||
dddiv2022 divide 803.6310547013030 7101143795399.238 -> 1.131692411611166E-10 Inexact Rounded
|
||||
dddiv2023 divide 9.251697842123399E-82 -1.342350220606119E-7 -> -6.892163982321936E-75 Inexact Rounded
|
||||
dddiv2024 divide -1.980600645637992E-53 -5.474262753214457E+77 -> 3.618022617703168E-131 Inexact Rounded
|
||||
dddiv2025 divide -210.0322996351690 -8.580951835872843E+80 -> 2.447657365434971E-79 Inexact Rounded
|
||||
dddiv2026 divide -1.821980314020370E+85 -3.018915267138165 -> 6.035215144503042E+84 Inexact Rounded
|
||||
dddiv2027 divide -772264503601.1047 5.158258271408988E-86 -> -1.497141986630614E+97 Inexact Rounded
|
||||
dddiv2028 divide -767.0532415847106 2.700027228028939E-59 -> -2.840909282772941E+61 Inexact Rounded
|
||||
dddiv2029 divide 496724.8548250093 7.32700588163100E+66 -> 6.779370220929013E-62 Inexact Rounded
|
||||
dddiv2030 divide -304232651447703.9 -108.9730808657440 -> 2791814721862.565 Inexact Rounded
|
||||
dddiv2031 divide -7.233817192699405E+42 -5711302004.149411 -> 1.266579352211430E+33 Inexact Rounded
|
||||
dddiv2032 divide -9.999221444912745E+96 4010569406446197 -> -2.493217404202250E+81 Inexact Rounded
|
||||
dddiv2033 divide -1837272.061937622 8.356322838066762 -> -219866.0939196882 Inexact Rounded
|
||||
dddiv2034 divide 2168.517555606529 209.1910258615061 -> 10.36620737756784 Inexact Rounded
|
||||
dddiv2035 divide -1.884389790576371E+88 2.95181953870583E+20 -> -6.383824505079828E+67 Inexact Rounded
|
||||
dddiv2036 divide 732263.6037438196 961222.3634446889 -> 0.7618045850698269 Inexact Rounded
|
||||
dddiv2037 divide -813461419.0348336 5.376293753809143E+84 -> -1.513052404285927E-76 Inexact Rounded
|
||||
dddiv2038 divide -45562133508108.50 -9.776843494690107E+51 -> 4.660208945029519E-39 Inexact Rounded
|
||||
dddiv2039 divide -6.489393172441016E+80 -9101965.097852113 -> 7.129661674897421E+73 Inexact Rounded
|
||||
dddiv2040 divide 3.694576237117349E+93 6683512.012622003 -> 5.527896456443912E+86 Inexact Rounded
|
||||
dddiv2041 divide -2.252877726403272E+19 -7451913256.181367 -> 3023220546.125531 Inexact Rounded
|
||||
dddiv2042 divide 518303.1989111842 50.01587020474133 -> 10362.77479107123 Inexact Rounded
|
||||
dddiv2043 divide 2.902087881880103E+24 33.32400992305702 -> 8.708699488989578E+22 Inexact Rounded
|
||||
dddiv2044 divide 549619.4559510557 1660824845196338 -> 3.309316196351104E-10 Inexact Rounded
|
||||
dddiv2045 divide -6775670774684043 8292152023.077262 -> -817118.4941891062 Inexact Rounded
|
||||
dddiv2046 divide -77.50923921524079 -5.636882655425815E+74 -> 1.375037302588405E-73 Inexact Rounded
|
||||
dddiv2047 divide -2.984889459605149E-10 -88106156784122.99 -> 3.387833005721384E-24 Inexact Rounded
|
||||
dddiv2048 divide 0.949517293997085 44767115.96450998 -> 2.121015110175589E-8 Inexact Rounded
|
||||
dddiv2049 divide -2760937211.084521 -1087015876975408 -> 0.000002539923537057024 Inexact Rounded
|
||||
dddiv2050 divide 28438351.85030536 -4.209397904088624E-47 -> -6.755919135770688E+53 Inexact Rounded
|
||||
dddiv2051 divide -85562731.6820956 -7.166045442530185E+45 -> 1.194002080621542E-38 Inexact Rounded
|
||||
dddiv2052 divide 2533802852165.25 7154.119606235955 -> 354173957.3317501 Inexact Rounded
|
||||
dddiv2053 divide -8858831346851.474 97.59734208801716 -> -90769186509.83577 Inexact Rounded
|
||||
dddiv2054 divide 176783629801387.5 840073263.3109817 -> 210438.3480848206 Inexact Rounded
|
||||
dddiv2055 divide -493506471796175.6 79733894790822.03 -> -6.189418854940746 Inexact Rounded
|
||||
dddiv2056 divide 790.1682542103445 829.9449370367435 -> 0.9520731062371214 Inexact Rounded
|
||||
dddiv2057 divide -8920459838.583164 -4767.889187899214 -> 1870945.294035581 Inexact Rounded
|
||||
dddiv2058 divide 53536687164422.1 53137.5007032689 -> 1007512330.385698 Inexact Rounded
|
||||
dddiv2059 divide 4.051532311146561E-74 -2.343089768972261E+94 -> -1.729140882606332E-168 Inexact Rounded
|
||||
dddiv2060 divide -14847758778636.88 3.062543516383807E-43 -> -4.848178874587497E+55 Inexact Rounded
|
||||
|
||||
-- Division probably has pre-rounding, so need to test rounding
|
||||
-- explicitly rather than assume included through other tests;
|
||||
-- tests include simple rounding and also the tricky cases of sticky
|
||||
-- bits following two zeros
|
||||
--
|
||||
-- 1/99999 gives 0.0000100001000010000100001000010000100001
|
||||
-- 1234567890123456
|
||||
--
|
||||
-- 1/999999 gives 0.000001000001000001000001000001000001000001
|
||||
-- 1234567890123456
|
||||
|
||||
rounding: ceiling
|
||||
dddiv3001 divide 1 3 -> 0.3333333333333334 Inexact Rounded
|
||||
dddiv3002 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv3003 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
|
||||
dddiv3004 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
|
||||
|
||||
rounding: floor
|
||||
dddiv3011 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3012 divide 2 3 -> 0.6666666666666666 Inexact Rounded
|
||||
dddiv3013 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3014 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
|
||||
|
||||
rounding: up
|
||||
dddiv3021 divide 1 3 -> 0.3333333333333334 Inexact Rounded
|
||||
dddiv3022 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv3023 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
|
||||
dddiv3024 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
|
||||
|
||||
rounding: down
|
||||
dddiv3031 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3032 divide 2 3 -> 0.6666666666666666 Inexact Rounded
|
||||
dddiv3033 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3034 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
|
||||
|
||||
rounding: half_up
|
||||
dddiv3041 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3042 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv3043 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3044 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
|
||||
|
||||
rounding: half_down
|
||||
dddiv3051 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3052 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv3053 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3054 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
|
||||
|
||||
rounding: half_even
|
||||
dddiv3061 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3062 divide 2 3 -> 0.6666666666666667 Inexact Rounded
|
||||
dddiv3063 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3064 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
|
||||
|
||||
rounding: 05up
|
||||
dddiv3071 divide 1 3 -> 0.3333333333333333 Inexact Rounded
|
||||
dddiv3072 divide 2 3 -> 0.6666666666666666 Inexact Rounded
|
||||
dddiv3073 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
|
||||
dddiv3074 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
|
||||
|
||||
-- random divide tests with result near 1
|
||||
rounding: half_even
|
||||
dddiv4001 divide 3195385192916917 3195385192946695 -> 0.9999999999906809 Inexact Rounded
|
||||
dddiv4002 divide 1393723067526993 1393723067519475 -> 1.000000000005394 Inexact Rounded
|
||||
dddiv4003 divide 759985543702302 759985543674015 -> 1.000000000037220 Inexact Rounded
|
||||
dddiv4004 divide 9579158456027302 9579158456036864 -> 0.9999999999990018 Inexact Rounded
|
||||
dddiv4005 divide 7079398299143569 7079398299156904 -> 0.9999999999981164 Inexact Rounded
|
||||
dddiv4006 divide 6636169255366598 6636169255336386 -> 1.000000000004553 Inexact Rounded
|
||||
dddiv4007 divide 6964813971340090 6964813971321554 -> 1.000000000002661 Inexact Rounded
|
||||
dddiv4008 divide 4182275225480784 4182275225454009 -> 1.000000000006402 Inexact Rounded
|
||||
dddiv4009 divide 9228325124938029 9228325124918730 -> 1.000000000002091 Inexact Rounded
|
||||
dddiv4010 divide 3428346338630192 3428346338609843 -> 1.000000000005936 Inexact Rounded
|
||||
dddiv4011 divide 2143511550722893 2143511550751754 -> 0.9999999999865356 Inexact Rounded
|
||||
dddiv4012 divide 1672732924396785 1672732924401811 -> 0.9999999999969953 Inexact Rounded
|
||||
dddiv4013 divide 4190714611948216 4190714611948664 -> 0.9999999999998931 Inexact Rounded
|
||||
dddiv4014 divide 3942254800848877 3942254800814556 -> 1.000000000008706 Inexact Rounded
|
||||
dddiv4015 divide 2854459826952334 2854459826960762 -> 0.9999999999970474 Inexact Rounded
|
||||
dddiv4016 divide 2853258953664731 2853258953684471 -> 0.9999999999930816 Inexact Rounded
|
||||
dddiv4017 divide 9453512638125978 9453512638146425 -> 0.9999999999978371 Inexact Rounded
|
||||
dddiv4018 divide 339476633940369 339476633912887 -> 1.000000000080954 Inexact Rounded
|
||||
dddiv4019 divide 4542181492688467 4542181492697735 -> 0.9999999999979596 Inexact Rounded
|
||||
dddiv4020 divide 7312600192399197 7312600192395424 -> 1.000000000000516 Inexact Rounded
|
||||
dddiv4021 divide 1811674985570111 1811674985603935 -> 0.9999999999813300 Inexact Rounded
|
||||
dddiv4022 divide 1706462639003481 1706462639017740 -> 0.9999999999916441 Inexact Rounded
|
||||
dddiv4023 divide 6697052654940368 6697052654934110 -> 1.000000000000934 Inexact Rounded
|
||||
dddiv4024 divide 5015283664277539 5015283664310719 -> 0.9999999999933842 Inexact Rounded
|
||||
dddiv4025 divide 2359501561537464 2359501561502464 -> 1.000000000014834 Inexact Rounded
|
||||
dddiv4026 divide 2669850227909157 2669850227901548 -> 1.000000000002850 Inexact Rounded
|
||||
dddiv4027 divide 9329725546974648 9329725547002445 -> 0.9999999999970206 Inexact Rounded
|
||||
dddiv4028 divide 3228562867071248 3228562867106206 -> 0.9999999999891723 Inexact Rounded
|
||||
dddiv4029 divide 4862226644921175 4862226644909380 -> 1.000000000002426 Inexact Rounded
|
||||
dddiv4030 divide 1022267997054529 1022267997071329 -> 0.9999999999835660 Inexact Rounded
|
||||
dddiv4031 divide 1048777482023719 1048777482000948 -> 1.000000000021712 Inexact Rounded
|
||||
dddiv4032 divide 9980113777337098 9980113777330539 -> 1.000000000000657 Inexact Rounded
|
||||
dddiv4033 divide 7506839167963908 7506839167942901 -> 1.000000000002798 Inexact Rounded
|
||||
dddiv4034 divide 231119751977860 231119751962453 -> 1.000000000066662 Inexact Rounded
|
||||
dddiv4035 divide 4034903664762962 4034903664795526 -> 0.9999999999919294 Inexact Rounded
|
||||
dddiv4036 divide 5700122152274696 5700122152251386 -> 1.000000000004089 Inexact Rounded
|
||||
dddiv4037 divide 6869599590293110 6869599590293495 -> 0.9999999999999440 Inexact Rounded
|
||||
dddiv4038 divide 5576281960092797 5576281960105579 -> 0.9999999999977078 Inexact Rounded
|
||||
dddiv4039 divide 2304844888381318 2304844888353073 -> 1.000000000012255 Inexact Rounded
|
||||
dddiv4040 divide 3265933651656452 3265933651682779 -> 0.9999999999919389 Inexact Rounded
|
||||
dddiv4041 divide 5235714985079914 5235714985066131 -> 1.000000000002632 Inexact Rounded
|
||||
dddiv4042 divide 5578481572827551 5578481572822945 -> 1.000000000000826 Inexact Rounded
|
||||
dddiv4043 divide 4909616081396134 4909616081373076 -> 1.000000000004696 Inexact Rounded
|
||||
dddiv4044 divide 636447224349537 636447224338757 -> 1.000000000016938 Inexact Rounded
|
||||
dddiv4045 divide 1539373428396640 1539373428364727 -> 1.000000000020731 Inexact Rounded
|
||||
dddiv4046 divide 2028786707377893 2028786707378866 -> 0.9999999999995204 Inexact Rounded
|
||||
dddiv4047 divide 137643260486222 137643260487419 -> 0.9999999999913036 Inexact Rounded
|
||||
dddiv4048 divide 247451519746765 247451519752267 -> 0.9999999999777653 Inexact Rounded
|
||||
dddiv4049 divide 7877858475022054 7877858474999794 -> 1.000000000002826 Inexact Rounded
|
||||
dddiv4050 divide 7333242694766258 7333242694744628 -> 1.000000000002950 Inexact Rounded
|
||||
dddiv4051 divide 124051503698592 124051503699397 -> 0.9999999999935108 Inexact Rounded
|
||||
dddiv4052 divide 8944737432385188 8944737432406860 -> 0.9999999999975771 Inexact Rounded
|
||||
dddiv4053 divide 9883948923406874 9883948923424843 -> 0.9999999999981820 Inexact Rounded
|
||||
dddiv4054 divide 6829178741654284 6829178741671973 -> 0.9999999999974098 Inexact Rounded
|
||||
dddiv4055 divide 7342752479768122 7342752479793385 -> 0.9999999999965595 Inexact Rounded
|
||||
dddiv4056 divide 8066426579008783 8066426578977563 -> 1.000000000003870 Inexact Rounded
|
||||
dddiv4057 divide 8992775071383295 8992775071352712 -> 1.000000000003401 Inexact Rounded
|
||||
dddiv4058 divide 5485011755545641 5485011755543611 -> 1.000000000000370 Inexact Rounded
|
||||
dddiv4059 divide 5779983054353918 5779983054365300 -> 0.9999999999980308 Inexact Rounded
|
||||
dddiv4060 divide 9502265102713774 9502265102735208 -> 0.9999999999977443 Inexact Rounded
|
||||
dddiv4061 divide 2109558399130981 2109558399116281 -> 1.000000000006968 Inexact Rounded
|
||||
dddiv4062 divide 5296182636350471 5296182636351521 -> 0.9999999999998017 Inexact Rounded
|
||||
dddiv4063 divide 1440019225591883 1440019225601844 -> 0.9999999999930827 Inexact Rounded
|
||||
dddiv4064 divide 8182110791881341 8182110791847174 -> 1.000000000004176 Inexact Rounded
|
||||
dddiv4065 divide 489098235512060 489098235534516 -> 0.9999999999540869 Inexact Rounded
|
||||
dddiv4066 divide 6475687084782038 6475687084756089 -> 1.000000000004007 Inexact Rounded
|
||||
dddiv4067 divide 8094348555736948 8094348555759236 -> 0.9999999999972465 Inexact Rounded
|
||||
dddiv4068 divide 1982766816291543 1982766816309463 -> 0.9999999999909621 Inexact Rounded
|
||||
dddiv4069 divide 9277314300113251 9277314300084467 -> 1.000000000003103 Inexact Rounded
|
||||
dddiv4070 divide 4335532959318934 4335532959293167 -> 1.000000000005943 Inexact Rounded
|
||||
dddiv4071 divide 7767113032981348 7767113032968132 -> 1.000000000001702 Inexact Rounded
|
||||
dddiv4072 divide 1578548053342868 1578548053370448 -> 0.9999999999825282 Inexact Rounded
|
||||
dddiv4073 divide 3790420686666898 3790420686636315 -> 1.000000000008068 Inexact Rounded
|
||||
dddiv4074 divide 871682421955147 871682421976441 -> 0.9999999999755714 Inexact Rounded
|
||||
dddiv4075 divide 744141054479940 744141054512329 -> 0.9999999999564746 Inexact Rounded
|
||||
dddiv4076 divide 8956824183670735 8956824183641741 -> 1.000000000003237 Inexact Rounded
|
||||
dddiv4077 divide 8337291694485682 8337291694451193 -> 1.000000000004137 Inexact Rounded
|
||||
dddiv4078 divide 4107775944683669 4107775944657097 -> 1.000000000006469 Inexact Rounded
|
||||
dddiv4079 divide 8691900057964648 8691900057997555 -> 0.9999999999962141 Inexact Rounded
|
||||
dddiv4080 divide 2229528520536462 2229528520502337 -> 1.000000000015306 Inexact Rounded
|
||||
dddiv4081 divide 398442083774322 398442083746273 -> 1.000000000070397 Inexact Rounded
|
||||
dddiv4082 divide 5319819776808759 5319819776838313 -> 0.9999999999944445 Inexact Rounded
|
||||
dddiv4083 divide 7710491299066855 7710491299041858 -> 1.000000000003242 Inexact Rounded
|
||||
dddiv4084 divide 9083231296087266 9083231296058160 -> 1.000000000003204 Inexact Rounded
|
||||
dddiv4085 divide 3566873574904559 3566873574890328 -> 1.000000000003990 Inexact Rounded
|
||||
dddiv4086 divide 596343290550525 596343290555614 -> 0.9999999999914663 Inexact Rounded
|
||||
dddiv4087 divide 278227925093192 278227925068104 -> 1.000000000090171 Inexact Rounded
|
||||
dddiv4088 divide 3292902958490649 3292902958519881 -> 0.9999999999911227 Inexact Rounded
|
||||
dddiv4089 divide 5521871364245881 5521871364229536 -> 1.000000000002960 Inexact Rounded
|
||||
dddiv4090 divide 2406505602883617 2406505602857997 -> 1.000000000010646 Inexact Rounded
|
||||
dddiv4091 divide 7741146984869208 7741146984867255 -> 1.000000000000252 Inexact Rounded
|
||||
dddiv4092 divide 4576041832414909 4576041832405102 -> 1.000000000002143 Inexact Rounded
|
||||
dddiv4093 divide 9183756982878057 9183756982901934 -> 0.9999999999974001 Inexact Rounded
|
||||
dddiv4094 divide 6215736513855159 6215736513870342 -> 0.9999999999975573 Inexact Rounded
|
||||
dddiv4095 divide 248554968534533 248554968551417 -> 0.9999999999320714 Inexact Rounded
|
||||
dddiv4096 divide 376314165668645 376314165659755 -> 1.000000000023624 Inexact Rounded
|
||||
dddiv4097 divide 5513569249809718 5513569249808906 -> 1.000000000000147 Inexact Rounded
|
||||
dddiv4098 divide 3367992242167904 3367992242156228 -> 1.000000000003467 Inexact Rounded
|
||||
dddiv4099 divide 6134869538966967 6134869538985986 -> 0.9999999999968999 Inexact Rounded
|
||||
|
||||
-- Null tests
|
||||
dddiv9998 divide 10 # -> NaN Invalid_operation
|
||||
dddiv9999 divide # 10 -> NaN Invalid_operation
|
||||
|
@ -0,0 +1,449 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddDivideInt.decTest -- decDouble integer division --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
dddvi001 divideint 1 1 -> 1
|
||||
dddvi002 divideint 2 1 -> 2
|
||||
dddvi003 divideint 1 2 -> 0
|
||||
dddvi004 divideint 2 2 -> 1
|
||||
dddvi005 divideint 0 1 -> 0
|
||||
dddvi006 divideint 0 2 -> 0
|
||||
dddvi007 divideint 1 3 -> 0
|
||||
dddvi008 divideint 2 3 -> 0
|
||||
dddvi009 divideint 3 3 -> 1
|
||||
|
||||
dddvi010 divideint 2.4 1 -> 2
|
||||
dddvi011 divideint 2.4 -1 -> -2
|
||||
dddvi012 divideint -2.4 1 -> -2
|
||||
dddvi013 divideint -2.4 -1 -> 2
|
||||
dddvi014 divideint 2.40 1 -> 2
|
||||
dddvi015 divideint 2.400 1 -> 2
|
||||
dddvi016 divideint 2.4 2 -> 1
|
||||
dddvi017 divideint 2.400 2 -> 1
|
||||
dddvi018 divideint 2. 2 -> 1
|
||||
dddvi019 divideint 20 20 -> 1
|
||||
|
||||
dddvi020 divideint 187 187 -> 1
|
||||
dddvi021 divideint 5 2 -> 2
|
||||
dddvi022 divideint 5 2.0 -> 2
|
||||
dddvi023 divideint 5 2.000 -> 2
|
||||
dddvi024 divideint 5 0.200 -> 25
|
||||
dddvi025 divideint 5 0.200 -> 25
|
||||
|
||||
dddvi030 divideint 1 2 -> 0
|
||||
dddvi031 divideint 1 4 -> 0
|
||||
dddvi032 divideint 1 8 -> 0
|
||||
dddvi033 divideint 1 16 -> 0
|
||||
dddvi034 divideint 1 32 -> 0
|
||||
dddvi035 divideint 1 64 -> 0
|
||||
dddvi040 divideint 1 -2 -> -0
|
||||
dddvi041 divideint 1 -4 -> -0
|
||||
dddvi042 divideint 1 -8 -> -0
|
||||
dddvi043 divideint 1 -16 -> -0
|
||||
dddvi044 divideint 1 -32 -> -0
|
||||
dddvi045 divideint 1 -64 -> -0
|
||||
dddvi050 divideint -1 2 -> -0
|
||||
dddvi051 divideint -1 4 -> -0
|
||||
dddvi052 divideint -1 8 -> -0
|
||||
dddvi053 divideint -1 16 -> -0
|
||||
dddvi054 divideint -1 32 -> -0
|
||||
dddvi055 divideint -1 64 -> -0
|
||||
dddvi060 divideint -1 -2 -> 0
|
||||
dddvi061 divideint -1 -4 -> 0
|
||||
dddvi062 divideint -1 -8 -> 0
|
||||
dddvi063 divideint -1 -16 -> 0
|
||||
dddvi064 divideint -1 -32 -> 0
|
||||
dddvi065 divideint -1 -64 -> 0
|
||||
|
||||
-- similar with powers of ten
|
||||
dddvi160 divideint 1 1 -> 1
|
||||
dddvi161 divideint 1 10 -> 0
|
||||
dddvi162 divideint 1 100 -> 0
|
||||
dddvi163 divideint 1 1000 -> 0
|
||||
dddvi164 divideint 1 10000 -> 0
|
||||
dddvi165 divideint 1 100000 -> 0
|
||||
dddvi166 divideint 1 1000000 -> 0
|
||||
dddvi167 divideint 1 10000000 -> 0
|
||||
dddvi168 divideint 1 100000000 -> 0
|
||||
dddvi170 divideint 1 -1 -> -1
|
||||
dddvi171 divideint 1 -10 -> -0
|
||||
dddvi172 divideint 1 -100 -> -0
|
||||
dddvi173 divideint 1 -1000 -> -0
|
||||
dddvi174 divideint 1 -10000 -> -0
|
||||
dddvi175 divideint 1 -100000 -> -0
|
||||
dddvi176 divideint 1 -1000000 -> -0
|
||||
dddvi177 divideint 1 -10000000 -> -0
|
||||
dddvi178 divideint 1 -100000000 -> -0
|
||||
dddvi180 divideint -1 1 -> -1
|
||||
dddvi181 divideint -1 10 -> -0
|
||||
dddvi182 divideint -1 100 -> -0
|
||||
dddvi183 divideint -1 1000 -> -0
|
||||
dddvi184 divideint -1 10000 -> -0
|
||||
dddvi185 divideint -1 100000 -> -0
|
||||
dddvi186 divideint -1 1000000 -> -0
|
||||
dddvi187 divideint -1 10000000 -> -0
|
||||
dddvi188 divideint -1 100000000 -> -0
|
||||
dddvi190 divideint -1 -1 -> 1
|
||||
dddvi191 divideint -1 -10 -> 0
|
||||
dddvi192 divideint -1 -100 -> 0
|
||||
dddvi193 divideint -1 -1000 -> 0
|
||||
dddvi194 divideint -1 -10000 -> 0
|
||||
dddvi195 divideint -1 -100000 -> 0
|
||||
dddvi196 divideint -1 -1000000 -> 0
|
||||
dddvi197 divideint -1 -10000000 -> 0
|
||||
dddvi198 divideint -1 -100000000 -> 0
|
||||
|
||||
-- some long operand (at p=9) cases
|
||||
dddvi070 divideint 999999999 1 -> 999999999
|
||||
dddvi071 divideint 999999999.4 1 -> 999999999
|
||||
dddvi072 divideint 999999999.5 1 -> 999999999
|
||||
dddvi073 divideint 999999999.9 1 -> 999999999
|
||||
dddvi074 divideint 999999999.999 1 -> 999999999
|
||||
|
||||
dddvi090 divideint 0. 1 -> 0
|
||||
dddvi091 divideint .0 1 -> 0
|
||||
dddvi092 divideint 0.00 1 -> 0
|
||||
dddvi093 divideint 0.00E+9 1 -> 0
|
||||
dddvi094 divideint 0.0000E-50 1 -> 0
|
||||
|
||||
dddvi100 divideint 1 1 -> 1
|
||||
dddvi101 divideint 1 2 -> 0
|
||||
dddvi102 divideint 1 3 -> 0
|
||||
dddvi103 divideint 1 4 -> 0
|
||||
dddvi104 divideint 1 5 -> 0
|
||||
dddvi105 divideint 1 6 -> 0
|
||||
dddvi106 divideint 1 7 -> 0
|
||||
dddvi107 divideint 1 8 -> 0
|
||||
dddvi108 divideint 1 9 -> 0
|
||||
dddvi109 divideint 1 10 -> 0
|
||||
dddvi110 divideint 1 1 -> 1
|
||||
dddvi111 divideint 2 1 -> 2
|
||||
dddvi112 divideint 3 1 -> 3
|
||||
dddvi113 divideint 4 1 -> 4
|
||||
dddvi114 divideint 5 1 -> 5
|
||||
dddvi115 divideint 6 1 -> 6
|
||||
dddvi116 divideint 7 1 -> 7
|
||||
dddvi117 divideint 8 1 -> 8
|
||||
dddvi118 divideint 9 1 -> 9
|
||||
dddvi119 divideint 10 1 -> 10
|
||||
|
||||
-- from DiagBigDecimal
|
||||
dddvi131 divideint 101.3 1 -> 101
|
||||
dddvi132 divideint 101.0 1 -> 101
|
||||
dddvi133 divideint 101.3 3 -> 33
|
||||
dddvi134 divideint 101.0 3 -> 33
|
||||
dddvi135 divideint 2.4 1 -> 2
|
||||
dddvi136 divideint 2.400 1 -> 2
|
||||
dddvi137 divideint 18 18 -> 1
|
||||
dddvi138 divideint 1120 1000 -> 1
|
||||
dddvi139 divideint 2.4 2 -> 1
|
||||
dddvi140 divideint 2.400 2 -> 1
|
||||
dddvi141 divideint 0.5 2.000 -> 0
|
||||
dddvi142 divideint 8.005 7 -> 1
|
||||
dddvi143 divideint 5 2 -> 2
|
||||
dddvi144 divideint 0 2 -> 0
|
||||
dddvi145 divideint 0.00 2 -> 0
|
||||
|
||||
-- Others
|
||||
dddvi150 divideint 12345 4.999 -> 2469
|
||||
dddvi151 divideint 12345 4.99 -> 2473
|
||||
dddvi152 divideint 12345 4.9 -> 2519
|
||||
dddvi153 divideint 12345 5 -> 2469
|
||||
dddvi154 divideint 12345 5.1 -> 2420
|
||||
dddvi155 divideint 12345 5.01 -> 2464
|
||||
dddvi156 divideint 12345 5.001 -> 2468
|
||||
dddvi157 divideint 101 7.6 -> 13
|
||||
|
||||
-- Various flavours of divideint by 0
|
||||
dddvi201 divideint 0 0 -> NaN Division_undefined
|
||||
dddvi202 divideint 0.0E5 0 -> NaN Division_undefined
|
||||
dddvi203 divideint 0.000 0 -> NaN Division_undefined
|
||||
dddvi204 divideint 0.0001 0 -> Infinity Division_by_zero
|
||||
dddvi205 divideint 0.01 0 -> Infinity Division_by_zero
|
||||
dddvi206 divideint 0.1 0 -> Infinity Division_by_zero
|
||||
dddvi207 divideint 1 0 -> Infinity Division_by_zero
|
||||
dddvi208 divideint 1 0.0 -> Infinity Division_by_zero
|
||||
dddvi209 divideint 10 0.0 -> Infinity Division_by_zero
|
||||
dddvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
|
||||
dddvi211 divideint 1E+380 0 -> Infinity Division_by_zero
|
||||
dddvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
|
||||
dddvi215 divideint -0.01 0 -> -Infinity Division_by_zero
|
||||
dddvi216 divideint -0.1 0 -> -Infinity Division_by_zero
|
||||
dddvi217 divideint -1 0 -> -Infinity Division_by_zero
|
||||
dddvi218 divideint -1 0.0 -> -Infinity Division_by_zero
|
||||
dddvi219 divideint -10 0.0 -> -Infinity Division_by_zero
|
||||
dddvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
|
||||
dddvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
|
||||
|
||||
-- test some cases that are close to exponent overflow
|
||||
dddvi270 divideint 1 1e384 -> 0
|
||||
dddvi271 divideint 1 0.9e384 -> 0
|
||||
dddvi272 divideint 1 0.99e384 -> 0
|
||||
dddvi273 divideint 1 0.9999999999999999e384 -> 0
|
||||
dddvi274 divideint 9e384 1 -> NaN Division_impossible
|
||||
dddvi275 divideint 9.9e384 1 -> NaN Division_impossible
|
||||
dddvi276 divideint 9.99e384 1 -> NaN Division_impossible
|
||||
dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
|
||||
|
||||
dddvi280 divideint 0.1 9e-383 -> NaN Division_impossible
|
||||
dddvi281 divideint 0.1 99e-383 -> NaN Division_impossible
|
||||
dddvi282 divideint 0.1 999e-383 -> NaN Division_impossible
|
||||
dddvi283 divideint 0.1 9e-382 -> NaN Division_impossible
|
||||
dddvi284 divideint 0.1 99e-382 -> NaN Division_impossible
|
||||
|
||||
-- GD edge cases: lhs smaller than rhs but more digits
|
||||
dddvi301 divideint 0.9 2 -> 0
|
||||
dddvi302 divideint 0.9 2.0 -> 0
|
||||
dddvi303 divideint 0.9 2.1 -> 0
|
||||
dddvi304 divideint 0.9 2.00 -> 0
|
||||
dddvi305 divideint 0.9 2.01 -> 0
|
||||
dddvi306 divideint 0.12 1 -> 0
|
||||
dddvi307 divideint 0.12 1.0 -> 0
|
||||
dddvi308 divideint 0.12 1.00 -> 0
|
||||
dddvi309 divideint 0.12 1.0 -> 0
|
||||
dddvi310 divideint 0.12 1.00 -> 0
|
||||
dddvi311 divideint 0.12 2 -> 0
|
||||
dddvi312 divideint 0.12 2.0 -> 0
|
||||
dddvi313 divideint 0.12 2.1 -> 0
|
||||
dddvi314 divideint 0.12 2.00 -> 0
|
||||
dddvi315 divideint 0.12 2.01 -> 0
|
||||
|
||||
-- edge cases of impossible
|
||||
dddvi330 divideint 1234567890123456 10 -> 123456789012345
|
||||
dddvi331 divideint 1234567890123456 1 -> 1234567890123456
|
||||
dddvi332 divideint 1234567890123456 0.1 -> NaN Division_impossible
|
||||
dddvi333 divideint 1234567890123456 0.01 -> NaN Division_impossible
|
||||
|
||||
-- overflow and underflow tests [from divide]
|
||||
dddvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
|
||||
dddvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
|
||||
dddvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
|
||||
dddvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
|
||||
dddvi1055 divideint 1e-277 1e+311 -> 0
|
||||
dddvi1056 divideint 1e-277 -1e+311 -> -0
|
||||
dddvi1057 divideint -1e-277 1e+311 -> -0
|
||||
dddvi1058 divideint -1e-277 -1e+311 -> 0
|
||||
|
||||
-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
|
||||
dddvi1060 divideint 1e-291 1e+101 -> 0
|
||||
dddvi1061 divideint 1e-291 1e+102 -> 0
|
||||
dddvi1062 divideint 1e-291 1e+103 -> 0
|
||||
dddvi1063 divideint 1e-291 1e+104 -> 0
|
||||
dddvi1064 divideint 1e-291 1e+105 -> 0
|
||||
dddvi1065 divideint 1e-291 1e+106 -> 0
|
||||
dddvi1066 divideint 1e-291 1e+107 -> 0
|
||||
dddvi1067 divideint 1e-291 1e+108 -> 0
|
||||
dddvi1068 divideint 1e-291 1e+109 -> 0
|
||||
dddvi1069 divideint 1e-291 1e+110 -> 0
|
||||
|
||||
dddvi1101 divideint 1.0000E-394 1 -> 0
|
||||
dddvi1102 divideint 1.000E-394 1e+1 -> 0
|
||||
dddvi1103 divideint 1.00E-394 1e+2 -> 0
|
||||
|
||||
dddvi1118 divideint 1E-394 1e+4 -> 0
|
||||
dddvi1119 divideint 3E-394 -1e+5 -> -0
|
||||
dddvi1120 divideint 5E-394 1e+5 -> 0
|
||||
|
||||
dddvi1124 divideint 1E-394 -1e+4 -> -0
|
||||
dddvi1130 divideint 3.0E-394 -1e+5 -> -0
|
||||
|
||||
dddvi1131 divideint 1.0E-199 1e+200 -> 0
|
||||
dddvi1132 divideint 1.0E-199 1e+199 -> 0
|
||||
dddvi1133 divideint 1.0E-199 1e+198 -> 0
|
||||
dddvi1134 divideint 2.0E-199 2e+198 -> 0
|
||||
dddvi1135 divideint 4.0E-199 4e+198 -> 0
|
||||
|
||||
-- long operand checks
|
||||
dddvi401 divideint 12345678000 100 -> 123456780
|
||||
dddvi402 divideint 1 12345678000 -> 0
|
||||
dddvi403 divideint 1234567800 10 -> 123456780
|
||||
dddvi404 divideint 1 1234567800 -> 0
|
||||
dddvi405 divideint 1234567890 10 -> 123456789
|
||||
dddvi406 divideint 1 1234567890 -> 0
|
||||
dddvi407 divideint 1234567891 10 -> 123456789
|
||||
dddvi408 divideint 1 1234567891 -> 0
|
||||
dddvi409 divideint 12345678901 100 -> 123456789
|
||||
dddvi410 divideint 1 12345678901 -> 0
|
||||
dddvi411 divideint 1234567896 10 -> 123456789
|
||||
dddvi412 divideint 1 1234567896 -> 0
|
||||
dddvi413 divideint 12345678948 100 -> 123456789
|
||||
dddvi414 divideint 12345678949 100 -> 123456789
|
||||
dddvi415 divideint 12345678950 100 -> 123456789
|
||||
dddvi416 divideint 12345678951 100 -> 123456789
|
||||
dddvi417 divideint 12345678999 100 -> 123456789
|
||||
dddvi441 divideint 12345678000 1 -> 12345678000
|
||||
dddvi442 divideint 1 12345678000 -> 0
|
||||
dddvi443 divideint 1234567800 1 -> 1234567800
|
||||
dddvi444 divideint 1 1234567800 -> 0
|
||||
dddvi445 divideint 1234567890 1 -> 1234567890
|
||||
dddvi446 divideint 1 1234567890 -> 0
|
||||
dddvi447 divideint 1234567891 1 -> 1234567891
|
||||
dddvi448 divideint 1 1234567891 -> 0
|
||||
dddvi449 divideint 12345678901 1 -> 12345678901
|
||||
dddvi450 divideint 1 12345678901 -> 0
|
||||
dddvi451 divideint 1234567896 1 -> 1234567896
|
||||
dddvi452 divideint 1 1234567896 -> 0
|
||||
|
||||
-- more zeros, etc.
|
||||
dddvi531 divideint 5.00 1E-3 -> 5000
|
||||
dddvi532 divideint 00.00 0.000 -> NaN Division_undefined
|
||||
dddvi533 divideint 00.00 0E-3 -> NaN Division_undefined
|
||||
dddvi534 divideint 0 -0 -> NaN Division_undefined
|
||||
dddvi535 divideint -0 0 -> NaN Division_undefined
|
||||
dddvi536 divideint -0 -0 -> NaN Division_undefined
|
||||
|
||||
dddvi541 divideint 0 -1 -> -0
|
||||
dddvi542 divideint -0 -1 -> 0
|
||||
dddvi543 divideint 0 1 -> 0
|
||||
dddvi544 divideint -0 1 -> -0
|
||||
dddvi545 divideint -1 0 -> -Infinity Division_by_zero
|
||||
dddvi546 divideint -1 -0 -> Infinity Division_by_zero
|
||||
dddvi547 divideint 1 0 -> Infinity Division_by_zero
|
||||
dddvi548 divideint 1 -0 -> -Infinity Division_by_zero
|
||||
|
||||
dddvi551 divideint 0.0 -1 -> -0
|
||||
dddvi552 divideint -0.0 -1 -> 0
|
||||
dddvi553 divideint 0.0 1 -> 0
|
||||
dddvi554 divideint -0.0 1 -> -0
|
||||
dddvi555 divideint -1.0 0 -> -Infinity Division_by_zero
|
||||
dddvi556 divideint -1.0 -0 -> Infinity Division_by_zero
|
||||
dddvi557 divideint 1.0 0 -> Infinity Division_by_zero
|
||||
dddvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
|
||||
|
||||
dddvi561 divideint 0 -1.0 -> -0
|
||||
dddvi562 divideint -0 -1.0 -> 0
|
||||
dddvi563 divideint 0 1.0 -> 0
|
||||
dddvi564 divideint -0 1.0 -> -0
|
||||
dddvi565 divideint -1 0.0 -> -Infinity Division_by_zero
|
||||
dddvi566 divideint -1 -0.0 -> Infinity Division_by_zero
|
||||
dddvi567 divideint 1 0.0 -> Infinity Division_by_zero
|
||||
dddvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
|
||||
|
||||
dddvi571 divideint 0.0 -1.0 -> -0
|
||||
dddvi572 divideint -0.0 -1.0 -> 0
|
||||
dddvi573 divideint 0.0 1.0 -> 0
|
||||
dddvi574 divideint -0.0 1.0 -> -0
|
||||
dddvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
|
||||
dddvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
|
||||
dddvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
|
||||
dddvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
|
||||
|
||||
-- Specials
|
||||
dddvi580 divideint Inf -Inf -> NaN Invalid_operation
|
||||
dddvi581 divideint Inf -1000 -> -Infinity
|
||||
dddvi582 divideint Inf -1 -> -Infinity
|
||||
dddvi583 divideint Inf -0 -> -Infinity
|
||||
dddvi584 divideint Inf 0 -> Infinity
|
||||
dddvi585 divideint Inf 1 -> Infinity
|
||||
dddvi586 divideint Inf 1000 -> Infinity
|
||||
dddvi587 divideint Inf Inf -> NaN Invalid_operation
|
||||
dddvi588 divideint -1000 Inf -> -0
|
||||
dddvi589 divideint -Inf Inf -> NaN Invalid_operation
|
||||
dddvi590 divideint -1 Inf -> -0
|
||||
dddvi591 divideint -0 Inf -> -0
|
||||
dddvi592 divideint 0 Inf -> 0
|
||||
dddvi593 divideint 1 Inf -> 0
|
||||
dddvi594 divideint 1000 Inf -> 0
|
||||
dddvi595 divideint Inf Inf -> NaN Invalid_operation
|
||||
|
||||
dddvi600 divideint -Inf -Inf -> NaN Invalid_operation
|
||||
dddvi601 divideint -Inf -1000 -> Infinity
|
||||
dddvi602 divideint -Inf -1 -> Infinity
|
||||
dddvi603 divideint -Inf -0 -> Infinity
|
||||
dddvi604 divideint -Inf 0 -> -Infinity
|
||||
dddvi605 divideint -Inf 1 -> -Infinity
|
||||
dddvi606 divideint -Inf 1000 -> -Infinity
|
||||
dddvi607 divideint -Inf Inf -> NaN Invalid_operation
|
||||
dddvi608 divideint -1000 Inf -> -0
|
||||
dddvi609 divideint -Inf -Inf -> NaN Invalid_operation
|
||||
dddvi610 divideint -1 -Inf -> 0
|
||||
dddvi611 divideint -0 -Inf -> 0
|
||||
dddvi612 divideint 0 -Inf -> -0
|
||||
dddvi613 divideint 1 -Inf -> -0
|
||||
dddvi614 divideint 1000 -Inf -> -0
|
||||
dddvi615 divideint Inf -Inf -> NaN Invalid_operation
|
||||
|
||||
dddvi621 divideint NaN -Inf -> NaN
|
||||
dddvi622 divideint NaN -1000 -> NaN
|
||||
dddvi623 divideint NaN -1 -> NaN
|
||||
dddvi624 divideint NaN -0 -> NaN
|
||||
dddvi625 divideint NaN 0 -> NaN
|
||||
dddvi626 divideint NaN 1 -> NaN
|
||||
dddvi627 divideint NaN 1000 -> NaN
|
||||
dddvi628 divideint NaN Inf -> NaN
|
||||
dddvi629 divideint NaN NaN -> NaN
|
||||
dddvi630 divideint -Inf NaN -> NaN
|
||||
dddvi631 divideint -1000 NaN -> NaN
|
||||
dddvi632 divideint -1 NaN -> NaN
|
||||
dddvi633 divideint -0 NaN -> NaN
|
||||
dddvi634 divideint 0 NaN -> NaN
|
||||
dddvi635 divideint 1 NaN -> NaN
|
||||
dddvi636 divideint 1000 NaN -> NaN
|
||||
dddvi637 divideint Inf NaN -> NaN
|
||||
|
||||
dddvi641 divideint sNaN -Inf -> NaN Invalid_operation
|
||||
dddvi642 divideint sNaN -1000 -> NaN Invalid_operation
|
||||
dddvi643 divideint sNaN -1 -> NaN Invalid_operation
|
||||
dddvi644 divideint sNaN -0 -> NaN Invalid_operation
|
||||
dddvi645 divideint sNaN 0 -> NaN Invalid_operation
|
||||
dddvi646 divideint sNaN 1 -> NaN Invalid_operation
|
||||
dddvi647 divideint sNaN 1000 -> NaN Invalid_operation
|
||||
dddvi648 divideint sNaN NaN -> NaN Invalid_operation
|
||||
dddvi649 divideint sNaN sNaN -> NaN Invalid_operation
|
||||
dddvi650 divideint NaN sNaN -> NaN Invalid_operation
|
||||
dddvi651 divideint -Inf sNaN -> NaN Invalid_operation
|
||||
dddvi652 divideint -1000 sNaN -> NaN Invalid_operation
|
||||
dddvi653 divideint -1 sNaN -> NaN Invalid_operation
|
||||
dddvi654 divideint -0 sNaN -> NaN Invalid_operation
|
||||
dddvi655 divideint 0 sNaN -> NaN Invalid_operation
|
||||
dddvi656 divideint 1 sNaN -> NaN Invalid_operation
|
||||
dddvi657 divideint 1000 sNaN -> NaN Invalid_operation
|
||||
dddvi658 divideint Inf sNaN -> NaN Invalid_operation
|
||||
dddvi659 divideint NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
dddvi661 divideint NaN9 -Inf -> NaN9
|
||||
dddvi662 divideint NaN8 1000 -> NaN8
|
||||
dddvi663 divideint NaN7 Inf -> NaN7
|
||||
dddvi664 divideint -NaN6 NaN5 -> -NaN6
|
||||
dddvi665 divideint -Inf NaN4 -> NaN4
|
||||
dddvi666 divideint -1000 NaN3 -> NaN3
|
||||
dddvi667 divideint Inf -NaN2 -> -NaN2
|
||||
|
||||
dddvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
dddvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
|
||||
dddvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
|
||||
dddvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
|
||||
dddvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
dddvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
dddvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
|
||||
dddvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
dddvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
|
||||
|
||||
-- Null tests
|
||||
dddvi900 divideint 10 # -> NaN Invalid_operation
|
||||
dddvi901 divideint # 10 -> NaN Invalid_operation
|
@ -0,0 +1,495 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddEncode.decTest -- decimal eight-byte format testcases --
|
||||
-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
-- [Previously called decimal64.decTest]
|
||||
version: 2.58
|
||||
|
||||
-- This set of tests is for the eight-byte concrete representation.
|
||||
-- Its characteristics are:
|
||||
--
|
||||
-- 1 bit sign
|
||||
-- 5 bits combination field
|
||||
-- 8 bits exponent continuation
|
||||
-- 50 bits coefficient continuation
|
||||
--
|
||||
-- Total exponent length 10 bits
|
||||
-- Total coefficient length 54 bits (16 digits)
|
||||
--
|
||||
-- Elimit = 767 (maximum encoded exponent)
|
||||
-- Emax = 384 (largest exponent value)
|
||||
-- Emin = -383 (smallest exponent value)
|
||||
-- bias = 398 (subtracted from encoded exponent) = -Etiny
|
||||
|
||||
-- The testcases here have only exactly representable data on the
|
||||
-- 'left-hand-side'; rounding from strings is tested in 'base'
|
||||
-- testcase groups.
|
||||
|
||||
extended: 1
|
||||
clamp: 1
|
||||
precision: 16
|
||||
rounding: half_up
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
|
||||
-- General testcases
|
||||
-- (mostly derived from the Strawman 4 document and examples)
|
||||
dece001 apply #A2300000000003D0 -> -7.50
|
||||
dece002 apply -7.50 -> #A2300000000003D0
|
||||
-- derivative canonical plain strings
|
||||
dece003 apply #A23c0000000003D0 -> -7.50E+3
|
||||
dece004 apply -7.50E+3 -> #A23c0000000003D0
|
||||
dece005 apply #A2380000000003D0 -> -750
|
||||
dece006 apply -750 -> #A2380000000003D0
|
||||
dece007 apply #A2340000000003D0 -> -75.0
|
||||
dece008 apply -75.0 -> #A2340000000003D0
|
||||
dece009 apply #A22c0000000003D0 -> -0.750
|
||||
dece010 apply -0.750 -> #A22c0000000003D0
|
||||
dece011 apply #A2280000000003D0 -> -0.0750
|
||||
dece012 apply -0.0750 -> #A2280000000003D0
|
||||
dece013 apply #A2200000000003D0 -> -0.000750
|
||||
dece014 apply -0.000750 -> #A2200000000003D0
|
||||
dece015 apply #A2180000000003D0 -> -0.00000750
|
||||
dece016 apply -0.00000750 -> #A2180000000003D0
|
||||
dece017 apply #A2140000000003D0 -> -7.50E-7
|
||||
dece018 apply -7.50E-7 -> #A2140000000003D0
|
||||
|
||||
-- Normality
|
||||
dece020 apply 1234567890123456 -> #263934b9c1e28e56
|
||||
dece021 apply -1234567890123456 -> #a63934b9c1e28e56
|
||||
dece022 apply 1234.567890123456 -> #260934b9c1e28e56
|
||||
dece023 apply #260934b9c1e28e56 -> 1234.567890123456
|
||||
dece024 apply 1111111111111111 -> #2638912449124491
|
||||
dece025 apply 9999999999999999 -> #6e38ff3fcff3fcff
|
||||
|
||||
-- Nmax and similar
|
||||
dece031 apply 9999999999999999E+369 -> #77fcff3fcff3fcff
|
||||
dece032 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
|
||||
dece033 apply #77fcff3fcff3fcff -> 9.999999999999999E+384
|
||||
dece034 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56
|
||||
dece035 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384
|
||||
-- fold-downs (more below)
|
||||
dece036 apply 1.23E+384 -> #47fd300000000000 Clamped
|
||||
dece037 apply #47fd300000000000 -> 1.230000000000000E+384
|
||||
decd038 apply 1E+384 -> #47fc000000000000 Clamped
|
||||
decd039 apply #47fc000000000000 -> 1.000000000000000E+384
|
||||
|
||||
decd051 apply 12345 -> #22380000000049c5
|
||||
decd052 apply #22380000000049c5 -> 12345
|
||||
decd053 apply 1234 -> #2238000000000534
|
||||
decd054 apply #2238000000000534 -> 1234
|
||||
decd055 apply 123 -> #22380000000000a3
|
||||
decd056 apply #22380000000000a3 -> 123
|
||||
decd057 apply 12 -> #2238000000000012
|
||||
decd058 apply #2238000000000012 -> 12
|
||||
decd059 apply 1 -> #2238000000000001
|
||||
decd060 apply #2238000000000001 -> 1
|
||||
decd061 apply 1.23 -> #22300000000000a3
|
||||
decd062 apply #22300000000000a3 -> 1.23
|
||||
decd063 apply 123.45 -> #22300000000049c5
|
||||
decd064 apply #22300000000049c5 -> 123.45
|
||||
|
||||
-- Nmin and below
|
||||
decd071 apply 1E-383 -> #003c000000000001
|
||||
decd072 apply #003c000000000001 -> 1E-383
|
||||
decd073 apply 1.000000000000000E-383 -> #0400000000000000
|
||||
decd074 apply #0400000000000000 -> 1.000000000000000E-383
|
||||
decd075 apply 1.000000000000001E-383 -> #0400000000000001
|
||||
decd076 apply #0400000000000001 -> 1.000000000000001E-383
|
||||
|
||||
decd077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal
|
||||
decd078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal
|
||||
decd079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal
|
||||
decd080 apply #0000000000000010 -> 1.0E-397 Subnormal
|
||||
decd081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal
|
||||
decd082 apply #0004000000000001 -> 1E-397 Subnormal
|
||||
decd083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal
|
||||
decd084 apply #0000000000000001 -> 1E-398 Subnormal
|
||||
-- next is smallest all-nines
|
||||
decd085 apply 9999999999999999E-398 -> #6400ff3fcff3fcff
|
||||
decd086 apply #6400ff3fcff3fcff -> 9.999999999999999E-383
|
||||
-- and a problematic divide result
|
||||
decd088 apply 1.111111111111111E-383 -> #0400912449124491
|
||||
decd089 apply #0400912449124491 -> 1.111111111111111E-383
|
||||
|
||||
-- forties
|
||||
decd090 apply 40 -> #2238000000000040
|
||||
decd091 apply 39.99 -> #2230000000000cff
|
||||
|
||||
-- underflows cannot be tested as all LHS exact
|
||||
|
||||
-- Same again, negatives
|
||||
-- Nmax and similar
|
||||
decd122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff
|
||||
decd123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384
|
||||
decd124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56
|
||||
decd125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384
|
||||
-- fold-downs (more below)
|
||||
decd130 apply -1.23E+384 -> #c7fd300000000000 Clamped
|
||||
decd131 apply #c7fd300000000000 -> -1.230000000000000E+384
|
||||
decd132 apply -1E+384 -> #c7fc000000000000 Clamped
|
||||
decd133 apply #c7fc000000000000 -> -1.000000000000000E+384
|
||||
|
||||
-- overflows
|
||||
decd151 apply -12345 -> #a2380000000049c5
|
||||
decd152 apply #a2380000000049c5 -> -12345
|
||||
decd153 apply -1234 -> #a238000000000534
|
||||
decd154 apply #a238000000000534 -> -1234
|
||||
decd155 apply -123 -> #a2380000000000a3
|
||||
decd156 apply #a2380000000000a3 -> -123
|
||||
decd157 apply -12 -> #a238000000000012
|
||||
decd158 apply #a238000000000012 -> -12
|
||||
decd159 apply -1 -> #a238000000000001
|
||||
decd160 apply #a238000000000001 -> -1
|
||||
decd161 apply -1.23 -> #a2300000000000a3
|
||||
decd162 apply #a2300000000000a3 -> -1.23
|
||||
decd163 apply -123.45 -> #a2300000000049c5
|
||||
decd164 apply #a2300000000049c5 -> -123.45
|
||||
|
||||
-- Nmin and below
|
||||
decd171 apply -1E-383 -> #803c000000000001
|
||||
decd172 apply #803c000000000001 -> -1E-383
|
||||
decd173 apply -1.000000000000000E-383 -> #8400000000000000
|
||||
decd174 apply #8400000000000000 -> -1.000000000000000E-383
|
||||
decd175 apply -1.000000000000001E-383 -> #8400000000000001
|
||||
decd176 apply #8400000000000001 -> -1.000000000000001E-383
|
||||
|
||||
decd177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal
|
||||
decd178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal
|
||||
decd179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal
|
||||
decd180 apply #8000000000000010 -> -1.0E-397 Subnormal
|
||||
decd181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal
|
||||
decd182 apply #8004000000000001 -> -1E-397 Subnormal
|
||||
decd183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal
|
||||
decd184 apply #8000000000000001 -> -1E-398 Subnormal
|
||||
-- next is smallest all-nines
|
||||
decd185 apply -9999999999999999E-398 -> #e400ff3fcff3fcff
|
||||
decd186 apply #e400ff3fcff3fcff -> -9.999999999999999E-383
|
||||
-- and a tricky subnormal
|
||||
decd187 apply 1.11111111111524E-384 -> #00009124491246a4 Subnormal
|
||||
decd188 apply #00009124491246a4 -> 1.11111111111524E-384 Subnormal
|
||||
|
||||
-- near-underflows
|
||||
decd189 apply -1e-398 -> #8000000000000001 Subnormal
|
||||
decd190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
|
||||
|
||||
-- zeros
|
||||
decd401 apply 0E-500 -> #0000000000000000 Clamped
|
||||
decd402 apply 0E-400 -> #0000000000000000 Clamped
|
||||
decd403 apply 0E-398 -> #0000000000000000
|
||||
decd404 apply #0000000000000000 -> 0E-398
|
||||
decd405 apply 0.000000000000000E-383 -> #0000000000000000
|
||||
decd406 apply #0000000000000000 -> 0E-398
|
||||
decd407 apply 0E-2 -> #2230000000000000
|
||||
decd408 apply #2230000000000000 -> 0.00
|
||||
decd409 apply 0 -> #2238000000000000
|
||||
decd410 apply #2238000000000000 -> 0
|
||||
decd411 apply 0E+3 -> #2244000000000000
|
||||
decd412 apply #2244000000000000 -> 0E+3
|
||||
decd413 apply 0E+369 -> #43fc000000000000
|
||||
decd414 apply #43fc000000000000 -> 0E+369
|
||||
-- clamped zeros...
|
||||
decd415 apply 0E+370 -> #43fc000000000000 Clamped
|
||||
decd416 apply #43fc000000000000 -> 0E+369
|
||||
decd417 apply 0E+384 -> #43fc000000000000 Clamped
|
||||
decd418 apply #43fc000000000000 -> 0E+369
|
||||
decd419 apply 0E+400 -> #43fc000000000000 Clamped
|
||||
decd420 apply #43fc000000000000 -> 0E+369
|
||||
decd421 apply 0E+500 -> #43fc000000000000 Clamped
|
||||
decd422 apply #43fc000000000000 -> 0E+369
|
||||
|
||||
-- negative zeros
|
||||
decd431 apply -0E-400 -> #8000000000000000 Clamped
|
||||
decd432 apply -0E-400 -> #8000000000000000 Clamped
|
||||
decd433 apply -0E-398 -> #8000000000000000
|
||||
decd434 apply #8000000000000000 -> -0E-398
|
||||
decd435 apply -0.000000000000000E-383 -> #8000000000000000
|
||||
decd436 apply #8000000000000000 -> -0E-398
|
||||
decd437 apply -0E-2 -> #a230000000000000
|
||||
decd438 apply #a230000000000000 -> -0.00
|
||||
decd439 apply -0 -> #a238000000000000
|
||||
decd440 apply #a238000000000000 -> -0
|
||||
decd441 apply -0E+3 -> #a244000000000000
|
||||
decd442 apply #a244000000000000 -> -0E+3
|
||||
decd443 apply -0E+369 -> #c3fc000000000000
|
||||
decd444 apply #c3fc000000000000 -> -0E+369
|
||||
-- clamped zeros...
|
||||
decd445 apply -0E+370 -> #c3fc000000000000 Clamped
|
||||
decd446 apply #c3fc000000000000 -> -0E+369
|
||||
decd447 apply -0E+384 -> #c3fc000000000000 Clamped
|
||||
decd448 apply #c3fc000000000000 -> -0E+369
|
||||
decd449 apply -0E+400 -> #c3fc000000000000 Clamped
|
||||
decd450 apply #c3fc000000000000 -> -0E+369
|
||||
decd451 apply -0E+500 -> #c3fc000000000000 Clamped
|
||||
decd452 apply #c3fc000000000000 -> -0E+369
|
||||
|
||||
-- exponents
|
||||
decd460 apply #225c000000000007 -> 7E+9
|
||||
decd461 apply 7E+9 -> #225c000000000007
|
||||
decd462 apply #23c4000000000007 -> 7E+99
|
||||
decd463 apply 7E+99 -> #23c4000000000007
|
||||
|
||||
-- Specials
|
||||
decd500 apply Infinity -> #7800000000000000
|
||||
decd501 apply #7878787878787878 -> #7800000000000000
|
||||
decd502 apply #7800000000000000 -> Infinity
|
||||
decd503 apply #7979797979797979 -> #7800000000000000
|
||||
decd504 apply #7900000000000000 -> Infinity
|
||||
decd505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000
|
||||
decd506 apply #7a00000000000000 -> Infinity
|
||||
decd507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000
|
||||
decd508 apply #7b00000000000000 -> Infinity
|
||||
|
||||
decd509 apply NaN -> #7c00000000000000
|
||||
decd510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
|
||||
decd511 apply #7c00000000000000 -> NaN
|
||||
decd512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
|
||||
decd513 apply #7d00000000000000 -> NaN
|
||||
decd514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
|
||||
decd515 apply #7e00000000000000 -> sNaN
|
||||
decd516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
|
||||
decd517 apply #7f00000000000000 -> sNaN
|
||||
decd518 apply #7fffffffffffffff -> sNaN999999999999999
|
||||
decd519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff
|
||||
|
||||
decd520 apply -Infinity -> #f800000000000000
|
||||
decd521 apply #f878787878787878 -> #f800000000000000
|
||||
decd522 apply #f800000000000000 -> -Infinity
|
||||
decd523 apply #f979797979797979 -> #f800000000000000
|
||||
decd524 apply #f900000000000000 -> -Infinity
|
||||
decd525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000
|
||||
decd526 apply #fa00000000000000 -> -Infinity
|
||||
decd527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000
|
||||
decd528 apply #fb00000000000000 -> -Infinity
|
||||
|
||||
decd529 apply -NaN -> #fc00000000000000
|
||||
decd530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
|
||||
decd531 apply #fc00000000000000 -> -NaN
|
||||
decd532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
|
||||
decd533 apply #fd00000000000000 -> -NaN
|
||||
decd534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
|
||||
decd535 apply #fe00000000000000 -> -sNaN
|
||||
decd536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
|
||||
decd537 apply #ff00000000000000 -> -sNaN
|
||||
decd538 apply #ffffffffffffffff -> -sNaN999999999999999
|
||||
decd539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff
|
||||
|
||||
-- diagnostic NaNs
|
||||
decd540 apply NaN -> #7c00000000000000
|
||||
decd541 apply NaN0 -> #7c00000000000000
|
||||
decd542 apply NaN1 -> #7c00000000000001
|
||||
decd543 apply NaN12 -> #7c00000000000012
|
||||
decd544 apply NaN79 -> #7c00000000000079
|
||||
decd545 apply NaN12345 -> #7c000000000049c5
|
||||
decd546 apply NaN123456 -> #7c00000000028e56
|
||||
decd547 apply NaN799799 -> #7c000000000f7fdf
|
||||
decd548 apply NaN799799799799799 -> #7c03dff7fdff7fdf
|
||||
decd549 apply NaN999999999999999 -> #7c00ff3fcff3fcff
|
||||
-- too many digits
|
||||
|
||||
-- fold-down full sequence
|
||||
decd601 apply 1E+384 -> #47fc000000000000 Clamped
|
||||
decd602 apply #47fc000000000000 -> 1.000000000000000E+384
|
||||
decd603 apply 1E+383 -> #43fc800000000000 Clamped
|
||||
decd604 apply #43fc800000000000 -> 1.00000000000000E+383
|
||||
decd605 apply 1E+382 -> #43fc100000000000 Clamped
|
||||
decd606 apply #43fc100000000000 -> 1.0000000000000E+382
|
||||
decd607 apply 1E+381 -> #43fc010000000000 Clamped
|
||||
decd608 apply #43fc010000000000 -> 1.000000000000E+381
|
||||
decd609 apply 1E+380 -> #43fc002000000000 Clamped
|
||||
decd610 apply #43fc002000000000 -> 1.00000000000E+380
|
||||
decd611 apply 1E+379 -> #43fc000400000000 Clamped
|
||||
decd612 apply #43fc000400000000 -> 1.0000000000E+379
|
||||
decd613 apply 1E+378 -> #43fc000040000000 Clamped
|
||||
decd614 apply #43fc000040000000 -> 1.000000000E+378
|
||||
decd615 apply 1E+377 -> #43fc000008000000 Clamped
|
||||
decd616 apply #43fc000008000000 -> 1.00000000E+377
|
||||
decd617 apply 1E+376 -> #43fc000001000000 Clamped
|
||||
decd618 apply #43fc000001000000 -> 1.0000000E+376
|
||||
decd619 apply 1E+375 -> #43fc000000100000 Clamped
|
||||
decd620 apply #43fc000000100000 -> 1.000000E+375
|
||||
decd621 apply 1E+374 -> #43fc000000020000 Clamped
|
||||
decd622 apply #43fc000000020000 -> 1.00000E+374
|
||||
decd623 apply 1E+373 -> #43fc000000004000 Clamped
|
||||
decd624 apply #43fc000000004000 -> 1.0000E+373
|
||||
decd625 apply 1E+372 -> #43fc000000000400 Clamped
|
||||
decd626 apply #43fc000000000400 -> 1.000E+372
|
||||
decd627 apply 1E+371 -> #43fc000000000080 Clamped
|
||||
decd628 apply #43fc000000000080 -> 1.00E+371
|
||||
decd629 apply 1E+370 -> #43fc000000000010 Clamped
|
||||
decd630 apply #43fc000000000010 -> 1.0E+370
|
||||
decd631 apply 1E+369 -> #43fc000000000001
|
||||
decd632 apply #43fc000000000001 -> 1E+369
|
||||
decd633 apply 1E+368 -> #43f8000000000001
|
||||
decd634 apply #43f8000000000001 -> 1E+368
|
||||
-- same with 9s
|
||||
decd641 apply 9E+384 -> #77fc000000000000 Clamped
|
||||
decd642 apply #77fc000000000000 -> 9.000000000000000E+384
|
||||
decd643 apply 9E+383 -> #43fc8c0000000000 Clamped
|
||||
decd644 apply #43fc8c0000000000 -> 9.00000000000000E+383
|
||||
decd645 apply 9E+382 -> #43fc1a0000000000 Clamped
|
||||
decd646 apply #43fc1a0000000000 -> 9.0000000000000E+382
|
||||
decd647 apply 9E+381 -> #43fc090000000000 Clamped
|
||||
decd648 apply #43fc090000000000 -> 9.000000000000E+381
|
||||
decd649 apply 9E+380 -> #43fc002300000000 Clamped
|
||||
decd650 apply #43fc002300000000 -> 9.00000000000E+380
|
||||
decd651 apply 9E+379 -> #43fc000680000000 Clamped
|
||||
decd652 apply #43fc000680000000 -> 9.0000000000E+379
|
||||
decd653 apply 9E+378 -> #43fc000240000000 Clamped
|
||||
decd654 apply #43fc000240000000 -> 9.000000000E+378
|
||||
decd655 apply 9E+377 -> #43fc000008c00000 Clamped
|
||||
decd656 apply #43fc000008c00000 -> 9.00000000E+377
|
||||
decd657 apply 9E+376 -> #43fc000001a00000 Clamped
|
||||
decd658 apply #43fc000001a00000 -> 9.0000000E+376
|
||||
decd659 apply 9E+375 -> #43fc000000900000 Clamped
|
||||
decd660 apply #43fc000000900000 -> 9.000000E+375
|
||||
decd661 apply 9E+374 -> #43fc000000023000 Clamped
|
||||
decd662 apply #43fc000000023000 -> 9.00000E+374
|
||||
decd663 apply 9E+373 -> #43fc000000006800 Clamped
|
||||
decd664 apply #43fc000000006800 -> 9.0000E+373
|
||||
decd665 apply 9E+372 -> #43fc000000002400 Clamped
|
||||
decd666 apply #43fc000000002400 -> 9.000E+372
|
||||
decd667 apply 9E+371 -> #43fc00000000008c Clamped
|
||||
decd668 apply #43fc00000000008c -> 9.00E+371
|
||||
decd669 apply 9E+370 -> #43fc00000000001a Clamped
|
||||
decd670 apply #43fc00000000001a -> 9.0E+370
|
||||
decd671 apply 9E+369 -> #43fc000000000009
|
||||
decd672 apply #43fc000000000009 -> 9E+369
|
||||
decd673 apply 9E+368 -> #43f8000000000009
|
||||
decd674 apply #43f8000000000009 -> 9E+368
|
||||
|
||||
|
||||
-- Selected DPD codes
|
||||
decd700 apply #2238000000000000 -> 0
|
||||
decd701 apply #2238000000000009 -> 9
|
||||
decd702 apply #2238000000000010 -> 10
|
||||
decd703 apply #2238000000000019 -> 19
|
||||
decd704 apply #2238000000000020 -> 20
|
||||
decd705 apply #2238000000000029 -> 29
|
||||
decd706 apply #2238000000000030 -> 30
|
||||
decd707 apply #2238000000000039 -> 39
|
||||
decd708 apply #2238000000000040 -> 40
|
||||
decd709 apply #2238000000000049 -> 49
|
||||
decd710 apply #2238000000000050 -> 50
|
||||
decd711 apply #2238000000000059 -> 59
|
||||
decd712 apply #2238000000000060 -> 60
|
||||
decd713 apply #2238000000000069 -> 69
|
||||
decd714 apply #2238000000000070 -> 70
|
||||
decd715 apply #2238000000000071 -> 71
|
||||
decd716 apply #2238000000000072 -> 72
|
||||
decd717 apply #2238000000000073 -> 73
|
||||
decd718 apply #2238000000000074 -> 74
|
||||
decd719 apply #2238000000000075 -> 75
|
||||
decd720 apply #2238000000000076 -> 76
|
||||
decd721 apply #2238000000000077 -> 77
|
||||
decd722 apply #2238000000000078 -> 78
|
||||
decd723 apply #2238000000000079 -> 79
|
||||
|
||||
decd725 apply #223800000000029e -> 994
|
||||
decd726 apply #223800000000029f -> 995
|
||||
decd727 apply #22380000000002a0 -> 520
|
||||
decd728 apply #22380000000002a1 -> 521
|
||||
-- from telco test data
|
||||
decd730 apply #2238000000000188 -> 308
|
||||
decd731 apply #22380000000001a3 -> 323
|
||||
decd732 apply #223800000000002a -> 82
|
||||
decd733 apply #22380000000001a9 -> 329
|
||||
decd734 apply #2238000000000081 -> 101
|
||||
decd735 apply #22380000000002a2 -> 522
|
||||
|
||||
-- DPD: one of each of the huffman groups
|
||||
decd740 apply #22380000000003f7 -> 777
|
||||
decd741 apply #22380000000003f8 -> 778
|
||||
decd742 apply #22380000000003eb -> 787
|
||||
decd743 apply #223800000000037d -> 877
|
||||
decd744 apply #223800000000039f -> 997
|
||||
decd745 apply #22380000000003bf -> 979
|
||||
decd746 apply #22380000000003df -> 799
|
||||
decd747 apply #223800000000006e -> 888
|
||||
|
||||
-- DPD all-highs cases (includes the 24 redundant codes)
|
||||
decd750 apply #223800000000006e -> 888
|
||||
decd751 apply #223800000000016e -> 888
|
||||
decd752 apply #223800000000026e -> 888
|
||||
decd753 apply #223800000000036e -> 888
|
||||
decd754 apply #223800000000006f -> 889
|
||||
decd755 apply #223800000000016f -> 889
|
||||
decd756 apply #223800000000026f -> 889
|
||||
decd757 apply #223800000000036f -> 889
|
||||
|
||||
decd760 apply #223800000000007e -> 898
|
||||
decd761 apply #223800000000017e -> 898
|
||||
decd762 apply #223800000000027e -> 898
|
||||
decd763 apply #223800000000037e -> 898
|
||||
decd764 apply #223800000000007f -> 899
|
||||
decd765 apply #223800000000017f -> 899
|
||||
decd766 apply #223800000000027f -> 899
|
||||
decd767 apply #223800000000037f -> 899
|
||||
|
||||
decd770 apply #22380000000000ee -> 988
|
||||
decd771 apply #22380000000001ee -> 988
|
||||
decd772 apply #22380000000002ee -> 988
|
||||
decd773 apply #22380000000003ee -> 988
|
||||
decd774 apply #22380000000000ef -> 989
|
||||
decd775 apply #22380000000001ef -> 989
|
||||
decd776 apply #22380000000002ef -> 989
|
||||
decd777 apply #22380000000003ef -> 989
|
||||
|
||||
decd780 apply #22380000000000fe -> 998
|
||||
decd781 apply #22380000000001fe -> 998
|
||||
decd782 apply #22380000000002fe -> 998
|
||||
decd783 apply #22380000000003fe -> 998
|
||||
decd784 apply #22380000000000ff -> 999
|
||||
decd785 apply #22380000000001ff -> 999
|
||||
decd786 apply #22380000000002ff -> 999
|
||||
decd787 apply #22380000000003ff -> 999
|
||||
|
||||
-- values around [u]int32 edges (zeros done earlier)
|
||||
decd800 apply -2147483646 -> #a23800008c78af46
|
||||
decd801 apply -2147483647 -> #a23800008c78af47
|
||||
decd802 apply -2147483648 -> #a23800008c78af48
|
||||
decd803 apply -2147483649 -> #a23800008c78af49
|
||||
decd804 apply 2147483646 -> #223800008c78af46
|
||||
decd805 apply 2147483647 -> #223800008c78af47
|
||||
decd806 apply 2147483648 -> #223800008c78af48
|
||||
decd807 apply 2147483649 -> #223800008c78af49
|
||||
decd808 apply 4294967294 -> #2238000115afb55a
|
||||
decd809 apply 4294967295 -> #2238000115afb55b
|
||||
decd810 apply 4294967296 -> #2238000115afb57a
|
||||
decd811 apply 4294967297 -> #2238000115afb57b
|
||||
|
||||
decd820 apply #a23800008c78af46 -> -2147483646
|
||||
decd821 apply #a23800008c78af47 -> -2147483647
|
||||
decd822 apply #a23800008c78af48 -> -2147483648
|
||||
decd823 apply #a23800008c78af49 -> -2147483649
|
||||
decd824 apply #223800008c78af46 -> 2147483646
|
||||
decd825 apply #223800008c78af47 -> 2147483647
|
||||
decd826 apply #223800008c78af48 -> 2147483648
|
||||
decd827 apply #223800008c78af49 -> 2147483649
|
||||
decd828 apply #2238000115afb55a -> 4294967294
|
||||
decd829 apply #2238000115afb55b -> 4294967295
|
||||
decd830 apply #2238000115afb57a -> 4294967296
|
||||
decd831 apply #2238000115afb57b -> 4294967297
|
||||
|
||||
-- for narrowing
|
||||
decd840 apply #2870000000000000 -> 2.000000000000000E-99
|
||||
|
||||
-- some miscellaneous
|
||||
decd850 apply #0004070000000000 -> 7.000000000000E-385 Subnormal
|
||||
decd851 apply #0008000000020000 -> 1.00000E-391 Subnormal
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddInvert.decTest -- digitwise logical INVERT for decDoubles --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check (truth table)
|
||||
ddinv001 invert 0 -> 1111111111111111
|
||||
ddinv002 invert 1 -> 1111111111111110
|
||||
ddinv003 invert 10 -> 1111111111111101
|
||||
ddinv004 invert 111111111 -> 1111111000000000
|
||||
ddinv005 invert 000000000 -> 1111111111111111
|
||||
-- and at msd and msd-1
|
||||
ddinv007 invert 0000000000000000 -> 1111111111111111
|
||||
ddinv008 invert 1000000000000000 -> 111111111111111
|
||||
ddinv009 invert 0000000000000000 -> 1111111111111111
|
||||
ddinv010 invert 0100000000000000 -> 1011111111111111
|
||||
ddinv011 invert 0111111111111111 -> 1000000000000000
|
||||
ddinv012 invert 1111111111111111 -> 0
|
||||
ddinv013 invert 0011111111111111 -> 1100000000000000
|
||||
ddinv014 invert 0111111111111111 -> 1000000000000000
|
||||
|
||||
-- Various lengths
|
||||
-- 123456789 1234567890123456
|
||||
ddinv021 invert 111111111 -> 1111111000000000
|
||||
ddinv022 invert 111111111111 -> 1111000000000000
|
||||
ddinv023 invert 11111111 -> 1111111100000000
|
||||
ddinv025 invert 1111111 -> 1111111110000000
|
||||
ddinv026 invert 111111 -> 1111111111000000
|
||||
ddinv027 invert 11111 -> 1111111111100000
|
||||
ddinv028 invert 1111 -> 1111111111110000
|
||||
ddinv029 invert 111 -> 1111111111111000
|
||||
ddinv031 invert 11 -> 1111111111111100
|
||||
ddinv032 invert 1 -> 1111111111111110
|
||||
ddinv033 invert 111111111111 -> 1111000000000000
|
||||
ddinv034 invert 11111111111 -> 1111100000000000
|
||||
ddinv035 invert 1111111111 -> 1111110000000000
|
||||
ddinv036 invert 111111111 -> 1111111000000000
|
||||
|
||||
ddinv040 invert 011111111 -> 1111111100000000
|
||||
ddinv041 invert 101111111 -> 1111111010000000
|
||||
ddinv042 invert 110111111 -> 1111111001000000
|
||||
ddinv043 invert 111011111 -> 1111111000100000
|
||||
ddinv044 invert 111101111 -> 1111111000010000
|
||||
ddinv045 invert 111110111 -> 1111111000001000
|
||||
ddinv046 invert 111111011 -> 1111111000000100
|
||||
ddinv047 invert 111111101 -> 1111111000000010
|
||||
ddinv048 invert 111111110 -> 1111111000000001
|
||||
ddinv049 invert 011111011 -> 1111111100000100
|
||||
ddinv050 invert 101111101 -> 1111111010000010
|
||||
ddinv051 invert 110111110 -> 1111111001000001
|
||||
ddinv052 invert 111011101 -> 1111111000100010
|
||||
ddinv053 invert 111101011 -> 1111111000010100
|
||||
ddinv054 invert 111110111 -> 1111111000001000
|
||||
ddinv055 invert 111101011 -> 1111111000010100
|
||||
ddinv056 invert 111011101 -> 1111111000100010
|
||||
ddinv057 invert 110111110 -> 1111111001000001
|
||||
ddinv058 invert 101111101 -> 1111111010000010
|
||||
ddinv059 invert 011111011 -> 1111111100000100
|
||||
|
||||
ddinv080 invert 1000000011111111 -> 111111100000000
|
||||
ddinv081 invert 0100000101111111 -> 1011111010000000
|
||||
ddinv082 invert 0010000110111111 -> 1101111001000000
|
||||
ddinv083 invert 0001000111011111 -> 1110111000100000
|
||||
ddinv084 invert 0000100111101111 -> 1111011000010000
|
||||
ddinv085 invert 0000010111110111 -> 1111101000001000
|
||||
ddinv086 invert 0000001111111011 -> 1111110000000100
|
||||
ddinv087 invert 0000010111111101 -> 1111101000000010
|
||||
ddinv088 invert 0000100111111110 -> 1111011000000001
|
||||
ddinv089 invert 0001000011111011 -> 1110111100000100
|
||||
ddinv090 invert 0010000101111101 -> 1101111010000010
|
||||
ddinv091 invert 0100000110111110 -> 1011111001000001
|
||||
ddinv092 invert 1000000111011101 -> 111111000100010
|
||||
ddinv093 invert 0100000111101011 -> 1011111000010100
|
||||
ddinv094 invert 0010000111110111 -> 1101111000001000
|
||||
ddinv095 invert 0001000111101011 -> 1110111000010100
|
||||
ddinv096 invert 0000100111011101 -> 1111011000100010
|
||||
ddinv097 invert 0000010110111110 -> 1111101001000001
|
||||
ddinv098 invert 0000001101111101 -> 1111110010000010
|
||||
ddinv099 invert 0000010011111011 -> 1111101100000100
|
||||
|
||||
-- non-0/1 should not be accepted, nor should signs
|
||||
ddinv220 invert 111111112 -> NaN Invalid_operation
|
||||
ddinv221 invert 333333333 -> NaN Invalid_operation
|
||||
ddinv222 invert 555555555 -> NaN Invalid_operation
|
||||
ddinv223 invert 777777777 -> NaN Invalid_operation
|
||||
ddinv224 invert 999999999 -> NaN Invalid_operation
|
||||
ddinv225 invert 222222222 -> NaN Invalid_operation
|
||||
ddinv226 invert 444444444 -> NaN Invalid_operation
|
||||
ddinv227 invert 666666666 -> NaN Invalid_operation
|
||||
ddinv228 invert 888888888 -> NaN Invalid_operation
|
||||
ddinv229 invert 999999999 -> NaN Invalid_operation
|
||||
ddinv230 invert 999999999 -> NaN Invalid_operation
|
||||
ddinv231 invert 999999999 -> NaN Invalid_operation
|
||||
ddinv232 invert 999999999 -> NaN Invalid_operation
|
||||
-- a few randoms
|
||||
ddinv240 invert 567468689 -> NaN Invalid_operation
|
||||
ddinv241 invert 567367689 -> NaN Invalid_operation
|
||||
ddinv242 invert -631917772 -> NaN Invalid_operation
|
||||
ddinv243 invert -756253257 -> NaN Invalid_operation
|
||||
ddinv244 invert 835590149 -> NaN Invalid_operation
|
||||
-- test MSD
|
||||
ddinv250 invert 2000000000000000 -> NaN Invalid_operation
|
||||
ddinv251 invert 3000000000000000 -> NaN Invalid_operation
|
||||
ddinv252 invert 4000000000000000 -> NaN Invalid_operation
|
||||
ddinv253 invert 5000000000000000 -> NaN Invalid_operation
|
||||
ddinv254 invert 6000000000000000 -> NaN Invalid_operation
|
||||
ddinv255 invert 7000000000000000 -> NaN Invalid_operation
|
||||
ddinv256 invert 8000000000000000 -> NaN Invalid_operation
|
||||
ddinv257 invert 9000000000000000 -> NaN Invalid_operation
|
||||
-- test MSD-1
|
||||
ddinv270 invert 0200001000000000 -> NaN Invalid_operation
|
||||
ddinv271 invert 0300000100000000 -> NaN Invalid_operation
|
||||
ddinv272 invert 0400000010000000 -> NaN Invalid_operation
|
||||
ddinv273 invert 0500000001000000 -> NaN Invalid_operation
|
||||
ddinv274 invert 1600000000100000 -> NaN Invalid_operation
|
||||
ddinv275 invert 1700000000010000 -> NaN Invalid_operation
|
||||
ddinv276 invert 1800000000001000 -> NaN Invalid_operation
|
||||
ddinv277 invert 1900000000000100 -> NaN Invalid_operation
|
||||
-- test LSD
|
||||
ddinv280 invert 0010000000000002 -> NaN Invalid_operation
|
||||
ddinv281 invert 0001000000000003 -> NaN Invalid_operation
|
||||
ddinv282 invert 0000100000000004 -> NaN Invalid_operation
|
||||
ddinv283 invert 0000010000000005 -> NaN Invalid_operation
|
||||
ddinv284 invert 1000001000000006 -> NaN Invalid_operation
|
||||
ddinv285 invert 1000000100000007 -> NaN Invalid_operation
|
||||
ddinv286 invert 1000000010000008 -> NaN Invalid_operation
|
||||
ddinv287 invert 1000000001000009 -> NaN Invalid_operation
|
||||
-- test Middie
|
||||
ddinv288 invert 0010000020000000 -> NaN Invalid_operation
|
||||
ddinv289 invert 0001000030000001 -> NaN Invalid_operation
|
||||
ddinv290 invert 0000100040000010 -> NaN Invalid_operation
|
||||
ddinv291 invert 0000010050000100 -> NaN Invalid_operation
|
||||
ddinv292 invert 1000001060001000 -> NaN Invalid_operation
|
||||
ddinv293 invert 1000000170010000 -> NaN Invalid_operation
|
||||
ddinv294 invert 1000000080100000 -> NaN Invalid_operation
|
||||
ddinv295 invert 1000000091000000 -> NaN Invalid_operation
|
||||
-- sign
|
||||
ddinv296 invert -1000000001000000 -> NaN Invalid_operation
|
||||
ddinv299 invert 1000000001000000 -> 111111110111111
|
||||
|
||||
|
||||
-- Nmax, Nmin, Ntiny-like
|
||||
ddinv341 invert 9.99999999E+299 -> NaN Invalid_operation
|
||||
ddinv342 invert 1E-299 -> NaN Invalid_operation
|
||||
ddinv343 invert 1.00000000E-299 -> NaN Invalid_operation
|
||||
ddinv344 invert 1E-207 -> NaN Invalid_operation
|
||||
ddinv345 invert -1E-207 -> NaN Invalid_operation
|
||||
ddinv346 invert -1.00000000E-299 -> NaN Invalid_operation
|
||||
ddinv347 invert -1E-299 -> NaN Invalid_operation
|
||||
ddinv348 invert -9.99999999E+299 -> NaN Invalid_operation
|
||||
|
||||
-- A few other non-integers
|
||||
ddinv361 invert 1.0 -> NaN Invalid_operation
|
||||
ddinv362 invert 1E+1 -> NaN Invalid_operation
|
||||
ddinv363 invert 0.0 -> NaN Invalid_operation
|
||||
ddinv364 invert 0E+1 -> NaN Invalid_operation
|
||||
ddinv365 invert 9.9 -> NaN Invalid_operation
|
||||
ddinv366 invert 9E+1 -> NaN Invalid_operation
|
||||
|
||||
-- All Specials are in error
|
||||
ddinv788 invert -Inf -> NaN Invalid_operation
|
||||
ddinv794 invert Inf -> NaN Invalid_operation
|
||||
ddinv821 invert NaN -> NaN Invalid_operation
|
||||
ddinv841 invert sNaN -> NaN Invalid_operation
|
||||
-- propagating NaNs
|
||||
ddinv861 invert NaN1 -> NaN Invalid_operation
|
||||
ddinv862 invert +NaN2 -> NaN Invalid_operation
|
||||
ddinv863 invert NaN3 -> NaN Invalid_operation
|
||||
ddinv864 invert NaN4 -> NaN Invalid_operation
|
||||
ddinv865 invert NaN5 -> NaN Invalid_operation
|
||||
ddinv871 invert sNaN11 -> NaN Invalid_operation
|
||||
ddinv872 invert sNaN12 -> NaN Invalid_operation
|
||||
ddinv873 invert sNaN13 -> NaN Invalid_operation
|
||||
ddinv874 invert sNaN14 -> NaN Invalid_operation
|
||||
ddinv875 invert sNaN15 -> NaN Invalid_operation
|
||||
ddinv876 invert NaN16 -> NaN Invalid_operation
|
||||
ddinv881 invert +NaN25 -> NaN Invalid_operation
|
||||
ddinv882 invert -NaN26 -> NaN Invalid_operation
|
||||
ddinv883 invert -sNaN27 -> NaN Invalid_operation
|
@ -0,0 +1,159 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles --
|
||||
-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- basics
|
||||
ddlogb000 logb 0 -> -Infinity Division_by_zero
|
||||
ddlogb001 logb 1E-398 -> -398
|
||||
ddlogb002 logb 1E-383 -> -383
|
||||
ddlogb003 logb 0.001 -> -3
|
||||
ddlogb004 logb 0.03 -> -2
|
||||
ddlogb005 logb 1 -> 0
|
||||
ddlogb006 logb 2 -> 0
|
||||
ddlogb007 logb 2.5 -> 0
|
||||
ddlogb008 logb 2.500 -> 0
|
||||
ddlogb009 logb 10 -> 1
|
||||
ddlogb010 logb 70 -> 1
|
||||
ddlogb011 logb 100 -> 2
|
||||
ddlogb012 logb 333 -> 2
|
||||
ddlogb013 logb 9E+384 -> 384
|
||||
ddlogb014 logb +Infinity -> Infinity
|
||||
|
||||
-- negatives appear to be treated as positives
|
||||
ddlogb021 logb -0 -> -Infinity Division_by_zero
|
||||
ddlogb022 logb -1E-398 -> -398
|
||||
ddlogb023 logb -9E-383 -> -383
|
||||
ddlogb024 logb -0.001 -> -3
|
||||
ddlogb025 logb -1 -> 0
|
||||
ddlogb026 logb -2 -> 0
|
||||
ddlogb027 logb -10 -> 1
|
||||
ddlogb028 logb -70 -> 1
|
||||
ddlogb029 logb -100 -> 2
|
||||
ddlogb030 logb -9E+384 -> 384
|
||||
ddlogb031 logb -Infinity -> Infinity
|
||||
|
||||
-- zeros
|
||||
ddlogb111 logb 0 -> -Infinity Division_by_zero
|
||||
ddlogb112 logb -0 -> -Infinity Division_by_zero
|
||||
ddlogb113 logb 0E+4 -> -Infinity Division_by_zero
|
||||
ddlogb114 logb -0E+4 -> -Infinity Division_by_zero
|
||||
ddlogb115 logb 0.0000 -> -Infinity Division_by_zero
|
||||
ddlogb116 logb -0.0000 -> -Infinity Division_by_zero
|
||||
ddlogb117 logb 0E-141 -> -Infinity Division_by_zero
|
||||
ddlogb118 logb -0E-141 -> -Infinity Division_by_zero
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddlogb121 logb 268268268 -> 8
|
||||
ddlogb122 logb -268268268 -> 8
|
||||
ddlogb123 logb 134134134 -> 8
|
||||
ddlogb124 logb -134134134 -> 8
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddlogb131 logb 9.999999999999999E+384 -> 384
|
||||
ddlogb132 logb 1E-383 -> -383
|
||||
ddlogb133 logb 1.000000000000000E-383 -> -383
|
||||
ddlogb134 logb 1E-398 -> -398
|
||||
|
||||
ddlogb135 logb -1E-398 -> -398
|
||||
ddlogb136 logb -1.000000000000000E-383 -> -383
|
||||
ddlogb137 logb -1E-383 -> -383
|
||||
ddlogb138 logb -9.999999999999999E+384 -> 384
|
||||
|
||||
-- ones
|
||||
ddlogb0061 logb 1 -> 0
|
||||
ddlogb0062 logb 1.0 -> 0
|
||||
ddlogb0063 logb 1.000000000000000 -> 0
|
||||
|
||||
-- notable cases -- exact powers of 10
|
||||
ddlogb1100 logb 1 -> 0
|
||||
ddlogb1101 logb 10 -> 1
|
||||
ddlogb1102 logb 100 -> 2
|
||||
ddlogb1103 logb 1000 -> 3
|
||||
ddlogb1104 logb 10000 -> 4
|
||||
ddlogb1105 logb 100000 -> 5
|
||||
ddlogb1106 logb 1000000 -> 6
|
||||
ddlogb1107 logb 10000000 -> 7
|
||||
ddlogb1108 logb 100000000 -> 8
|
||||
ddlogb1109 logb 1000000000 -> 9
|
||||
ddlogb1110 logb 10000000000 -> 10
|
||||
ddlogb1111 logb 100000000000 -> 11
|
||||
ddlogb1112 logb 1000000000000 -> 12
|
||||
ddlogb1113 logb 0.00000000001 -> -11
|
||||
ddlogb1114 logb 0.0000000001 -> -10
|
||||
ddlogb1115 logb 0.000000001 -> -9
|
||||
ddlogb1116 logb 0.00000001 -> -8
|
||||
ddlogb1117 logb 0.0000001 -> -7
|
||||
ddlogb1118 logb 0.000001 -> -6
|
||||
ddlogb1119 logb 0.00001 -> -5
|
||||
ddlogb1120 logb 0.0001 -> -4
|
||||
ddlogb1121 logb 0.001 -> -3
|
||||
ddlogb1122 logb 0.01 -> -2
|
||||
ddlogb1123 logb 0.1 -> -1
|
||||
ddlogb1124 logb 1E-99 -> -99
|
||||
ddlogb1125 logb 1E-100 -> -100
|
||||
ddlogb1127 logb 1E-299 -> -299
|
||||
ddlogb1126 logb 1E-383 -> -383
|
||||
|
||||
-- suggestions from Ilan Nehama
|
||||
ddlogb1400 logb 10E-3 -> -2
|
||||
ddlogb1401 logb 10E-2 -> -1
|
||||
ddlogb1402 logb 100E-2 -> 0
|
||||
ddlogb1403 logb 1000E-2 -> 1
|
||||
ddlogb1404 logb 10000E-2 -> 2
|
||||
ddlogb1405 logb 10E-1 -> 0
|
||||
ddlogb1406 logb 100E-1 -> 1
|
||||
ddlogb1407 logb 1000E-1 -> 2
|
||||
ddlogb1408 logb 10000E-1 -> 3
|
||||
ddlogb1409 logb 10E0 -> 1
|
||||
ddlogb1410 logb 100E0 -> 2
|
||||
ddlogb1411 logb 1000E0 -> 3
|
||||
ddlogb1412 logb 10000E0 -> 4
|
||||
ddlogb1413 logb 10E1 -> 2
|
||||
ddlogb1414 logb 100E1 -> 3
|
||||
ddlogb1415 logb 1000E1 -> 4
|
||||
ddlogb1416 logb 10000E1 -> 5
|
||||
ddlogb1417 logb 10E2 -> 3
|
||||
ddlogb1418 logb 100E2 -> 4
|
||||
ddlogb1419 logb 1000E2 -> 5
|
||||
ddlogb1420 logb 10000E2 -> 6
|
||||
|
||||
-- special values
|
||||
ddlogb820 logb Infinity -> Infinity
|
||||
ddlogb821 logb 0 -> -Infinity Division_by_zero
|
||||
ddlogb822 logb NaN -> NaN
|
||||
ddlogb823 logb sNaN -> NaN Invalid_operation
|
||||
-- propagating NaNs
|
||||
ddlogb824 logb sNaN123 -> NaN123 Invalid_operation
|
||||
ddlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
|
||||
ddlogb826 logb NaN456 -> NaN456
|
||||
ddlogb827 logb -NaN654 -> -NaN654
|
||||
ddlogb828 logb NaN1 -> NaN1
|
||||
|
||||
-- Null test
|
||||
ddlogb900 logb # -> NaN Invalid_operation
|
||||
|
||||
|
@ -0,0 +1,322 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMax.decTest -- decDouble maxnum --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- we assume that base comparison is tested in compare.decTest, so
|
||||
-- these mainly cover special cases and rounding
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddmax001 max -2 -2 -> -2
|
||||
ddmax002 max -2 -1 -> -1
|
||||
ddmax003 max -2 0 -> 0
|
||||
ddmax004 max -2 1 -> 1
|
||||
ddmax005 max -2 2 -> 2
|
||||
ddmax006 max -1 -2 -> -1
|
||||
ddmax007 max -1 -1 -> -1
|
||||
ddmax008 max -1 0 -> 0
|
||||
ddmax009 max -1 1 -> 1
|
||||
ddmax010 max -1 2 -> 2
|
||||
ddmax011 max 0 -2 -> 0
|
||||
ddmax012 max 0 -1 -> 0
|
||||
ddmax013 max 0 0 -> 0
|
||||
ddmax014 max 0 1 -> 1
|
||||
ddmax015 max 0 2 -> 2
|
||||
ddmax016 max 1 -2 -> 1
|
||||
ddmax017 max 1 -1 -> 1
|
||||
ddmax018 max 1 0 -> 1
|
||||
ddmax019 max 1 1 -> 1
|
||||
ddmax020 max 1 2 -> 2
|
||||
ddmax021 max 2 -2 -> 2
|
||||
ddmax022 max 2 -1 -> 2
|
||||
ddmax023 max 2 0 -> 2
|
||||
ddmax025 max 2 1 -> 2
|
||||
ddmax026 max 2 2 -> 2
|
||||
|
||||
-- extended zeros
|
||||
ddmax030 max 0 0 -> 0
|
||||
ddmax031 max 0 -0 -> 0
|
||||
ddmax032 max 0 -0.0 -> 0
|
||||
ddmax033 max 0 0.0 -> 0
|
||||
ddmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
|
||||
ddmax035 max -0 -0 -> -0
|
||||
ddmax036 max -0 -0.0 -> -0.0
|
||||
ddmax037 max -0 0.0 -> 0.0
|
||||
ddmax038 max 0.0 0 -> 0
|
||||
ddmax039 max 0.0 -0 -> 0.0
|
||||
ddmax040 max 0.0 -0.0 -> 0.0
|
||||
ddmax041 max 0.0 0.0 -> 0.0
|
||||
ddmax042 max -0.0 0 -> 0
|
||||
ddmax043 max -0.0 -0 -> -0.0
|
||||
ddmax044 max -0.0 -0.0 -> -0.0
|
||||
ddmax045 max -0.0 0.0 -> 0.0
|
||||
|
||||
ddmax050 max -0E1 0E1 -> 0E+1
|
||||
ddmax051 max -0E2 0E2 -> 0E+2
|
||||
ddmax052 max -0E2 0E1 -> 0E+1
|
||||
ddmax053 max -0E1 0E2 -> 0E+2
|
||||
ddmax054 max 0E1 -0E1 -> 0E+1
|
||||
ddmax055 max 0E2 -0E2 -> 0E+2
|
||||
ddmax056 max 0E2 -0E1 -> 0E+2
|
||||
ddmax057 max 0E1 -0E2 -> 0E+1
|
||||
|
||||
ddmax058 max 0E1 0E1 -> 0E+1
|
||||
ddmax059 max 0E2 0E2 -> 0E+2
|
||||
ddmax060 max 0E2 0E1 -> 0E+2
|
||||
ddmax061 max 0E1 0E2 -> 0E+2
|
||||
ddmax062 max -0E1 -0E1 -> -0E+1
|
||||
ddmax063 max -0E2 -0E2 -> -0E+2
|
||||
ddmax064 max -0E2 -0E1 -> -0E+1
|
||||
ddmax065 max -0E1 -0E2 -> -0E+1
|
||||
|
||||
-- Specials
|
||||
ddmax090 max Inf -Inf -> Infinity
|
||||
ddmax091 max Inf -1000 -> Infinity
|
||||
ddmax092 max Inf -1 -> Infinity
|
||||
ddmax093 max Inf -0 -> Infinity
|
||||
ddmax094 max Inf 0 -> Infinity
|
||||
ddmax095 max Inf 1 -> Infinity
|
||||
ddmax096 max Inf 1000 -> Infinity
|
||||
ddmax097 max Inf Inf -> Infinity
|
||||
ddmax098 max -1000 Inf -> Infinity
|
||||
ddmax099 max -Inf Inf -> Infinity
|
||||
ddmax100 max -1 Inf -> Infinity
|
||||
ddmax101 max -0 Inf -> Infinity
|
||||
ddmax102 max 0 Inf -> Infinity
|
||||
ddmax103 max 1 Inf -> Infinity
|
||||
ddmax104 max 1000 Inf -> Infinity
|
||||
ddmax105 max Inf Inf -> Infinity
|
||||
|
||||
ddmax120 max -Inf -Inf -> -Infinity
|
||||
ddmax121 max -Inf -1000 -> -1000
|
||||
ddmax122 max -Inf -1 -> -1
|
||||
ddmax123 max -Inf -0 -> -0
|
||||
ddmax124 max -Inf 0 -> 0
|
||||
ddmax125 max -Inf 1 -> 1
|
||||
ddmax126 max -Inf 1000 -> 1000
|
||||
ddmax127 max -Inf Inf -> Infinity
|
||||
ddmax128 max -Inf -Inf -> -Infinity
|
||||
ddmax129 max -1000 -Inf -> -1000
|
||||
ddmax130 max -1 -Inf -> -1
|
||||
ddmax131 max -0 -Inf -> -0
|
||||
ddmax132 max 0 -Inf -> 0
|
||||
ddmax133 max 1 -Inf -> 1
|
||||
ddmax134 max 1000 -Inf -> 1000
|
||||
ddmax135 max Inf -Inf -> Infinity
|
||||
|
||||
-- 2004.08.02 754r chooses number over NaN in mixed cases
|
||||
ddmax141 max NaN -Inf -> -Infinity
|
||||
ddmax142 max NaN -1000 -> -1000
|
||||
ddmax143 max NaN -1 -> -1
|
||||
ddmax144 max NaN -0 -> -0
|
||||
ddmax145 max NaN 0 -> 0
|
||||
ddmax146 max NaN 1 -> 1
|
||||
ddmax147 max NaN 1000 -> 1000
|
||||
ddmax148 max NaN Inf -> Infinity
|
||||
ddmax149 max NaN NaN -> NaN
|
||||
ddmax150 max -Inf NaN -> -Infinity
|
||||
ddmax151 max -1000 NaN -> -1000
|
||||
ddmax152 max -1 NaN -> -1
|
||||
ddmax153 max -0 NaN -> -0
|
||||
ddmax154 max 0 NaN -> 0
|
||||
ddmax155 max 1 NaN -> 1
|
||||
ddmax156 max 1000 NaN -> 1000
|
||||
ddmax157 max Inf NaN -> Infinity
|
||||
|
||||
ddmax161 max sNaN -Inf -> NaN Invalid_operation
|
||||
ddmax162 max sNaN -1000 -> NaN Invalid_operation
|
||||
ddmax163 max sNaN -1 -> NaN Invalid_operation
|
||||
ddmax164 max sNaN -0 -> NaN Invalid_operation
|
||||
ddmax165 max sNaN 0 -> NaN Invalid_operation
|
||||
ddmax166 max sNaN 1 -> NaN Invalid_operation
|
||||
ddmax167 max sNaN 1000 -> NaN Invalid_operation
|
||||
ddmax168 max sNaN NaN -> NaN Invalid_operation
|
||||
ddmax169 max sNaN sNaN -> NaN Invalid_operation
|
||||
ddmax170 max NaN sNaN -> NaN Invalid_operation
|
||||
ddmax171 max -Inf sNaN -> NaN Invalid_operation
|
||||
ddmax172 max -1000 sNaN -> NaN Invalid_operation
|
||||
ddmax173 max -1 sNaN -> NaN Invalid_operation
|
||||
ddmax174 max -0 sNaN -> NaN Invalid_operation
|
||||
ddmax175 max 0 sNaN -> NaN Invalid_operation
|
||||
ddmax176 max 1 sNaN -> NaN Invalid_operation
|
||||
ddmax177 max 1000 sNaN -> NaN Invalid_operation
|
||||
ddmax178 max Inf sNaN -> NaN Invalid_operation
|
||||
ddmax179 max NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddmax181 max NaN9 -Inf -> -Infinity
|
||||
ddmax182 max NaN8 9 -> 9
|
||||
ddmax183 max -NaN7 Inf -> Infinity
|
||||
|
||||
ddmax184 max -NaN1 NaN11 -> -NaN1
|
||||
ddmax185 max NaN2 NaN12 -> NaN2
|
||||
ddmax186 max -NaN13 -NaN7 -> -NaN13
|
||||
ddmax187 max NaN14 -NaN5 -> NaN14
|
||||
|
||||
ddmax188 max -Inf NaN4 -> -Infinity
|
||||
ddmax189 max -9 -NaN3 -> -9
|
||||
ddmax190 max Inf NaN2 -> Infinity
|
||||
|
||||
ddmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
ddmax192 max sNaN98 -1 -> NaN98 Invalid_operation
|
||||
ddmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
|
||||
ddmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
|
||||
ddmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
ddmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddmax197 max 0 sNaN91 -> NaN91 Invalid_operation
|
||||
ddmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
ddmax199 max NaN sNaN89 -> NaN89 Invalid_operation
|
||||
|
||||
-- old rounding checks
|
||||
ddmax221 max 12345678000 1 -> 12345678000
|
||||
ddmax222 max 1 12345678000 -> 12345678000
|
||||
ddmax223 max 1234567800 1 -> 1234567800
|
||||
ddmax224 max 1 1234567800 -> 1234567800
|
||||
ddmax225 max 1234567890 1 -> 1234567890
|
||||
ddmax226 max 1 1234567890 -> 1234567890
|
||||
ddmax227 max 1234567891 1 -> 1234567891
|
||||
ddmax228 max 1 1234567891 -> 1234567891
|
||||
ddmax229 max 12345678901 1 -> 12345678901
|
||||
ddmax230 max 1 12345678901 -> 12345678901
|
||||
ddmax231 max 1234567896 1 -> 1234567896
|
||||
ddmax232 max 1 1234567896 -> 1234567896
|
||||
ddmax233 max -1234567891 1 -> 1
|
||||
ddmax234 max 1 -1234567891 -> 1
|
||||
ddmax235 max -12345678901 1 -> 1
|
||||
ddmax236 max 1 -12345678901 -> 1
|
||||
ddmax237 max -1234567896 1 -> 1
|
||||
ddmax238 max 1 -1234567896 -> 1
|
||||
|
||||
-- from examples
|
||||
ddmax280 max '3' '2' -> '3'
|
||||
ddmax281 max '-10' '3' -> '3'
|
||||
ddmax282 max '1.0' '1' -> '1'
|
||||
ddmax283 max '1' '1.0' -> '1'
|
||||
ddmax284 max '7' 'NaN' -> '7'
|
||||
|
||||
-- expanded list from min/max 754r purple prose
|
||||
-- [explicit tests for exponent ordering]
|
||||
ddmax401 max Inf 1.1 -> Infinity
|
||||
ddmax402 max 1.1 1 -> 1.1
|
||||
ddmax403 max 1 1.0 -> 1
|
||||
ddmax404 max 1.0 0.1 -> 1.0
|
||||
ddmax405 max 0.1 0.10 -> 0.1
|
||||
ddmax406 max 0.10 0.100 -> 0.10
|
||||
ddmax407 max 0.10 0 -> 0.10
|
||||
ddmax408 max 0 0.0 -> 0
|
||||
ddmax409 max 0.0 -0 -> 0.0
|
||||
ddmax410 max 0.0 -0.0 -> 0.0
|
||||
ddmax411 max 0.00 -0.0 -> 0.00
|
||||
ddmax412 max 0.0 -0.00 -> 0.0
|
||||
ddmax413 max 0 -0.0 -> 0
|
||||
ddmax414 max 0 -0 -> 0
|
||||
ddmax415 max -0.0 -0 -> -0.0
|
||||
ddmax416 max -0 -0.100 -> -0
|
||||
ddmax417 max -0.100 -0.10 -> -0.100
|
||||
ddmax418 max -0.10 -0.1 -> -0.10
|
||||
ddmax419 max -0.1 -1.0 -> -0.1
|
||||
ddmax420 max -1.0 -1 -> -1.0
|
||||
ddmax421 max -1 -1.1 -> -1
|
||||
ddmax423 max -1.1 -Inf -> -1.1
|
||||
-- same with operands reversed
|
||||
ddmax431 max 1.1 Inf -> Infinity
|
||||
ddmax432 max 1 1.1 -> 1.1
|
||||
ddmax433 max 1.0 1 -> 1
|
||||
ddmax434 max 0.1 1.0 -> 1.0
|
||||
ddmax435 max 0.10 0.1 -> 0.1
|
||||
ddmax436 max 0.100 0.10 -> 0.10
|
||||
ddmax437 max 0 0.10 -> 0.10
|
||||
ddmax438 max 0.0 0 -> 0
|
||||
ddmax439 max -0 0.0 -> 0.0
|
||||
ddmax440 max -0.0 0.0 -> 0.0
|
||||
ddmax441 max -0.0 0.00 -> 0.00
|
||||
ddmax442 max -0.00 0.0 -> 0.0
|
||||
ddmax443 max -0.0 0 -> 0
|
||||
ddmax444 max -0 0 -> 0
|
||||
ddmax445 max -0 -0.0 -> -0.0
|
||||
ddmax446 max -0.100 -0 -> -0
|
||||
ddmax447 max -0.10 -0.100 -> -0.100
|
||||
ddmax448 max -0.1 -0.10 -> -0.10
|
||||
ddmax449 max -1.0 -0.1 -> -0.1
|
||||
ddmax450 max -1 -1.0 -> -1.0
|
||||
ddmax451 max -1.1 -1 -> -1
|
||||
ddmax453 max -Inf -1.1 -> -1.1
|
||||
-- largies
|
||||
ddmax460 max 1000 1E+3 -> 1E+3
|
||||
ddmax461 max 1E+3 1000 -> 1E+3
|
||||
ddmax462 max 1000 -1E+3 -> 1000
|
||||
ddmax463 max 1E+3 -1000 -> 1E+3
|
||||
ddmax464 max -1000 1E+3 -> 1E+3
|
||||
ddmax465 max -1E+3 1000 -> 1000
|
||||
ddmax466 max -1000 -1E+3 -> -1000
|
||||
ddmax467 max -1E+3 -1000 -> -1000
|
||||
|
||||
-- misalignment traps for little-endian
|
||||
ddmax471 max 1.0 0.1 -> 1.0
|
||||
ddmax472 max 0.1 1.0 -> 1.0
|
||||
ddmax473 max 10.0 0.1 -> 10.0
|
||||
ddmax474 max 0.1 10.0 -> 10.0
|
||||
ddmax475 max 100 1.0 -> 100
|
||||
ddmax476 max 1.0 100 -> 100
|
||||
ddmax477 max 1000 10.0 -> 1000
|
||||
ddmax478 max 10.0 1000 -> 1000
|
||||
ddmax479 max 10000 100.0 -> 10000
|
||||
ddmax480 max 100.0 10000 -> 10000
|
||||
ddmax481 max 100000 1000.0 -> 100000
|
||||
ddmax482 max 1000.0 100000 -> 100000
|
||||
ddmax483 max 1000000 10000.0 -> 1000000
|
||||
ddmax484 max 10000.0 1000000 -> 1000000
|
||||
|
||||
-- subnormals
|
||||
ddmax510 max 1.00E-383 0 -> 1.00E-383
|
||||
ddmax511 max 0.1E-383 0 -> 1E-384 Subnormal
|
||||
ddmax512 max 0.10E-383 0 -> 1.0E-384 Subnormal
|
||||
ddmax513 max 0.100E-383 0 -> 1.00E-384 Subnormal
|
||||
ddmax514 max 0.01E-383 0 -> 1E-385 Subnormal
|
||||
ddmax515 max 0.999E-383 0 -> 9.99E-384 Subnormal
|
||||
ddmax516 max 0.099E-383 0 -> 9.9E-385 Subnormal
|
||||
ddmax517 max 0.009E-383 0 -> 9E-386 Subnormal
|
||||
ddmax518 max 0.001E-383 0 -> 1E-386 Subnormal
|
||||
ddmax519 max 0.0009E-383 0 -> 9E-387 Subnormal
|
||||
ddmax520 max 0.0001E-383 0 -> 1E-387 Subnormal
|
||||
|
||||
ddmax530 max -1.00E-383 0 -> 0
|
||||
ddmax531 max -0.1E-383 0 -> 0
|
||||
ddmax532 max -0.10E-383 0 -> 0
|
||||
ddmax533 max -0.100E-383 0 -> 0
|
||||
ddmax534 max -0.01E-383 0 -> 0
|
||||
ddmax535 max -0.999E-383 0 -> 0
|
||||
ddmax536 max -0.099E-383 0 -> 0
|
||||
ddmax537 max -0.009E-383 0 -> 0
|
||||
ddmax538 max -0.001E-383 0 -> 0
|
||||
ddmax539 max -0.0009E-383 0 -> 0
|
||||
ddmax540 max -0.0001E-383 0 -> 0
|
||||
|
||||
-- Null tests
|
||||
ddmax900 max 10 # -> NaN Invalid_operation
|
||||
ddmax901 max # 10 -> NaN Invalid_operation
|
||||
|
||||
|
||||
|
@ -0,0 +1,304 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMaxMag.decTest -- decDouble maxnummag --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- we assume that base comparison is tested in compare.decTest, so
|
||||
-- these mainly cover special cases and rounding
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddmxg001 maxmag -2 -2 -> -2
|
||||
ddmxg002 maxmag -2 -1 -> -2
|
||||
ddmxg003 maxmag -2 0 -> -2
|
||||
ddmxg004 maxmag -2 1 -> -2
|
||||
ddmxg005 maxmag -2 2 -> 2
|
||||
ddmxg006 maxmag -1 -2 -> -2
|
||||
ddmxg007 maxmag -1 -1 -> -1
|
||||
ddmxg008 maxmag -1 0 -> -1
|
||||
ddmxg009 maxmag -1 1 -> 1
|
||||
ddmxg010 maxmag -1 2 -> 2
|
||||
ddmxg011 maxmag 0 -2 -> -2
|
||||
ddmxg012 maxmag 0 -1 -> -1
|
||||
ddmxg013 maxmag 0 0 -> 0
|
||||
ddmxg014 maxmag 0 1 -> 1
|
||||
ddmxg015 maxmag 0 2 -> 2
|
||||
ddmxg016 maxmag 1 -2 -> -2
|
||||
ddmxg017 maxmag 1 -1 -> 1
|
||||
ddmxg018 maxmag 1 0 -> 1
|
||||
ddmxg019 maxmag 1 1 -> 1
|
||||
ddmxg020 maxmag 1 2 -> 2
|
||||
ddmxg021 maxmag 2 -2 -> 2
|
||||
ddmxg022 maxmag 2 -1 -> 2
|
||||
ddmxg023 maxmag 2 0 -> 2
|
||||
ddmxg025 maxmag 2 1 -> 2
|
||||
ddmxg026 maxmag 2 2 -> 2
|
||||
|
||||
-- extended zeros
|
||||
ddmxg030 maxmag 0 0 -> 0
|
||||
ddmxg031 maxmag 0 -0 -> 0
|
||||
ddmxg032 maxmag 0 -0.0 -> 0
|
||||
ddmxg033 maxmag 0 0.0 -> 0
|
||||
ddmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
|
||||
ddmxg035 maxmag -0 -0 -> -0
|
||||
ddmxg036 maxmag -0 -0.0 -> -0.0
|
||||
ddmxg037 maxmag -0 0.0 -> 0.0
|
||||
ddmxg038 maxmag 0.0 0 -> 0
|
||||
ddmxg039 maxmag 0.0 -0 -> 0.0
|
||||
ddmxg040 maxmag 0.0 -0.0 -> 0.0
|
||||
ddmxg041 maxmag 0.0 0.0 -> 0.0
|
||||
ddmxg042 maxmag -0.0 0 -> 0
|
||||
ddmxg043 maxmag -0.0 -0 -> -0.0
|
||||
ddmxg044 maxmag -0.0 -0.0 -> -0.0
|
||||
ddmxg045 maxmag -0.0 0.0 -> 0.0
|
||||
|
||||
ddmxg050 maxmag -0E1 0E1 -> 0E+1
|
||||
ddmxg051 maxmag -0E2 0E2 -> 0E+2
|
||||
ddmxg052 maxmag -0E2 0E1 -> 0E+1
|
||||
ddmxg053 maxmag -0E1 0E2 -> 0E+2
|
||||
ddmxg054 maxmag 0E1 -0E1 -> 0E+1
|
||||
ddmxg055 maxmag 0E2 -0E2 -> 0E+2
|
||||
ddmxg056 maxmag 0E2 -0E1 -> 0E+2
|
||||
ddmxg057 maxmag 0E1 -0E2 -> 0E+1
|
||||
|
||||
ddmxg058 maxmag 0E1 0E1 -> 0E+1
|
||||
ddmxg059 maxmag 0E2 0E2 -> 0E+2
|
||||
ddmxg060 maxmag 0E2 0E1 -> 0E+2
|
||||
ddmxg061 maxmag 0E1 0E2 -> 0E+2
|
||||
ddmxg062 maxmag -0E1 -0E1 -> -0E+1
|
||||
ddmxg063 maxmag -0E2 -0E2 -> -0E+2
|
||||
ddmxg064 maxmag -0E2 -0E1 -> -0E+1
|
||||
ddmxg065 maxmag -0E1 -0E2 -> -0E+1
|
||||
|
||||
-- Specials
|
||||
ddmxg090 maxmag Inf -Inf -> Infinity
|
||||
ddmxg091 maxmag Inf -1000 -> Infinity
|
||||
ddmxg092 maxmag Inf -1 -> Infinity
|
||||
ddmxg093 maxmag Inf -0 -> Infinity
|
||||
ddmxg094 maxmag Inf 0 -> Infinity
|
||||
ddmxg095 maxmag Inf 1 -> Infinity
|
||||
ddmxg096 maxmag Inf 1000 -> Infinity
|
||||
ddmxg097 maxmag Inf Inf -> Infinity
|
||||
ddmxg098 maxmag -1000 Inf -> Infinity
|
||||
ddmxg099 maxmag -Inf Inf -> Infinity
|
||||
ddmxg100 maxmag -1 Inf -> Infinity
|
||||
ddmxg101 maxmag -0 Inf -> Infinity
|
||||
ddmxg102 maxmag 0 Inf -> Infinity
|
||||
ddmxg103 maxmag 1 Inf -> Infinity
|
||||
ddmxg104 maxmag 1000 Inf -> Infinity
|
||||
ddmxg105 maxmag Inf Inf -> Infinity
|
||||
|
||||
ddmxg120 maxmag -Inf -Inf -> -Infinity
|
||||
ddmxg121 maxmag -Inf -1000 -> -Infinity
|
||||
ddmxg122 maxmag -Inf -1 -> -Infinity
|
||||
ddmxg123 maxmag -Inf -0 -> -Infinity
|
||||
ddmxg124 maxmag -Inf 0 -> -Infinity
|
||||
ddmxg125 maxmag -Inf 1 -> -Infinity
|
||||
ddmxg126 maxmag -Inf 1000 -> -Infinity
|
||||
ddmxg127 maxmag -Inf Inf -> Infinity
|
||||
ddmxg128 maxmag -Inf -Inf -> -Infinity
|
||||
ddmxg129 maxmag -1000 -Inf -> -Infinity
|
||||
ddmxg130 maxmag -1 -Inf -> -Infinity
|
||||
ddmxg131 maxmag -0 -Inf -> -Infinity
|
||||
ddmxg132 maxmag 0 -Inf -> -Infinity
|
||||
ddmxg133 maxmag 1 -Inf -> -Infinity
|
||||
ddmxg134 maxmag 1000 -Inf -> -Infinity
|
||||
ddmxg135 maxmag Inf -Inf -> Infinity
|
||||
|
||||
-- 2004.08.02 754r chooses number over NaN in mixed cases
|
||||
ddmxg141 maxmag NaN -Inf -> -Infinity
|
||||
ddmxg142 maxmag NaN -1000 -> -1000
|
||||
ddmxg143 maxmag NaN -1 -> -1
|
||||
ddmxg144 maxmag NaN -0 -> -0
|
||||
ddmxg145 maxmag NaN 0 -> 0
|
||||
ddmxg146 maxmag NaN 1 -> 1
|
||||
ddmxg147 maxmag NaN 1000 -> 1000
|
||||
ddmxg148 maxmag NaN Inf -> Infinity
|
||||
ddmxg149 maxmag NaN NaN -> NaN
|
||||
ddmxg150 maxmag -Inf NaN -> -Infinity
|
||||
ddmxg151 maxmag -1000 NaN -> -1000
|
||||
ddmxg152 maxmag -1 NaN -> -1
|
||||
ddmxg153 maxmag -0 NaN -> -0
|
||||
ddmxg154 maxmag 0 NaN -> 0
|
||||
ddmxg155 maxmag 1 NaN -> 1
|
||||
ddmxg156 maxmag 1000 NaN -> 1000
|
||||
ddmxg157 maxmag Inf NaN -> Infinity
|
||||
|
||||
ddmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
|
||||
ddmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
|
||||
ddmxg163 maxmag sNaN -1 -> NaN Invalid_operation
|
||||
ddmxg164 maxmag sNaN -0 -> NaN Invalid_operation
|
||||
ddmxg165 maxmag sNaN 0 -> NaN Invalid_operation
|
||||
ddmxg166 maxmag sNaN 1 -> NaN Invalid_operation
|
||||
ddmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
|
||||
ddmxg168 maxmag sNaN NaN -> NaN Invalid_operation
|
||||
ddmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
|
||||
ddmxg170 maxmag NaN sNaN -> NaN Invalid_operation
|
||||
ddmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
|
||||
ddmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
|
||||
ddmxg173 maxmag -1 sNaN -> NaN Invalid_operation
|
||||
ddmxg174 maxmag -0 sNaN -> NaN Invalid_operation
|
||||
ddmxg175 maxmag 0 sNaN -> NaN Invalid_operation
|
||||
ddmxg176 maxmag 1 sNaN -> NaN Invalid_operation
|
||||
ddmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
|
||||
ddmxg178 maxmag Inf sNaN -> NaN Invalid_operation
|
||||
ddmxg179 maxmag NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddmxg181 maxmag NaN9 -Inf -> -Infinity
|
||||
ddmxg182 maxmag NaN8 9 -> 9
|
||||
ddmxg183 maxmag -NaN7 Inf -> Infinity
|
||||
|
||||
ddmxg184 maxmag -NaN1 NaN11 -> -NaN1
|
||||
ddmxg185 maxmag NaN2 NaN12 -> NaN2
|
||||
ddmxg186 maxmag -NaN13 -NaN7 -> -NaN13
|
||||
ddmxg187 maxmag NaN14 -NaN5 -> NaN14
|
||||
|
||||
ddmxg188 maxmag -Inf NaN4 -> -Infinity
|
||||
ddmxg189 maxmag -9 -NaN3 -> -9
|
||||
ddmxg190 maxmag Inf NaN2 -> Infinity
|
||||
|
||||
ddmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
ddmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
|
||||
ddmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
|
||||
ddmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
|
||||
ddmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
ddmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
|
||||
ddmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
ddmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
|
||||
|
||||
-- old rounding checks
|
||||
ddmxg221 maxmag 12345678000 1 -> 12345678000
|
||||
ddmxg222 maxmag 1 12345678000 -> 12345678000
|
||||
ddmxg223 maxmag 1234567800 1 -> 1234567800
|
||||
ddmxg224 maxmag 1 1234567800 -> 1234567800
|
||||
ddmxg225 maxmag 1234567890 1 -> 1234567890
|
||||
ddmxg226 maxmag 1 1234567890 -> 1234567890
|
||||
ddmxg227 maxmag 1234567891 1 -> 1234567891
|
||||
ddmxg228 maxmag 1 1234567891 -> 1234567891
|
||||
ddmxg229 maxmag 12345678901 1 -> 12345678901
|
||||
ddmxg230 maxmag 1 12345678901 -> 12345678901
|
||||
ddmxg231 maxmag 1234567896 1 -> 1234567896
|
||||
ddmxg232 maxmag 1 1234567896 -> 1234567896
|
||||
ddmxg233 maxmag -1234567891 1 -> -1234567891
|
||||
ddmxg234 maxmag 1 -1234567891 -> -1234567891
|
||||
ddmxg235 maxmag -12345678901 1 -> -12345678901
|
||||
ddmxg236 maxmag 1 -12345678901 -> -12345678901
|
||||
ddmxg237 maxmag -1234567896 1 -> -1234567896
|
||||
ddmxg238 maxmag 1 -1234567896 -> -1234567896
|
||||
|
||||
-- from examples
|
||||
ddmxg280 maxmag '3' '2' -> '3'
|
||||
ddmxg281 maxmag '-10' '3' -> '-10'
|
||||
ddmxg282 maxmag '1.0' '1' -> '1'
|
||||
ddmxg283 maxmag '1' '1.0' -> '1'
|
||||
ddmxg284 maxmag '7' 'NaN' -> '7'
|
||||
|
||||
-- expanded list from min/max 754r purple prose
|
||||
-- [explicit tests for exponent ordering]
|
||||
ddmxg401 maxmag Inf 1.1 -> Infinity
|
||||
ddmxg402 maxmag 1.1 1 -> 1.1
|
||||
ddmxg403 maxmag 1 1.0 -> 1
|
||||
ddmxg404 maxmag 1.0 0.1 -> 1.0
|
||||
ddmxg405 maxmag 0.1 0.10 -> 0.1
|
||||
ddmxg406 maxmag 0.10 0.100 -> 0.10
|
||||
ddmxg407 maxmag 0.10 0 -> 0.10
|
||||
ddmxg408 maxmag 0 0.0 -> 0
|
||||
ddmxg409 maxmag 0.0 -0 -> 0.0
|
||||
ddmxg410 maxmag 0.0 -0.0 -> 0.0
|
||||
ddmxg411 maxmag 0.00 -0.0 -> 0.00
|
||||
ddmxg412 maxmag 0.0 -0.00 -> 0.0
|
||||
ddmxg413 maxmag 0 -0.0 -> 0
|
||||
ddmxg414 maxmag 0 -0 -> 0
|
||||
ddmxg415 maxmag -0.0 -0 -> -0.0
|
||||
ddmxg416 maxmag -0 -0.100 -> -0.100
|
||||
ddmxg417 maxmag -0.100 -0.10 -> -0.100
|
||||
ddmxg418 maxmag -0.10 -0.1 -> -0.10
|
||||
ddmxg419 maxmag -0.1 -1.0 -> -1.0
|
||||
ddmxg420 maxmag -1.0 -1 -> -1.0
|
||||
ddmxg421 maxmag -1 -1.1 -> -1.1
|
||||
ddmxg423 maxmag -1.1 -Inf -> -Infinity
|
||||
-- same with operands reversed
|
||||
ddmxg431 maxmag 1.1 Inf -> Infinity
|
||||
ddmxg432 maxmag 1 1.1 -> 1.1
|
||||
ddmxg433 maxmag 1.0 1 -> 1
|
||||
ddmxg434 maxmag 0.1 1.0 -> 1.0
|
||||
ddmxg435 maxmag 0.10 0.1 -> 0.1
|
||||
ddmxg436 maxmag 0.100 0.10 -> 0.10
|
||||
ddmxg437 maxmag 0 0.10 -> 0.10
|
||||
ddmxg438 maxmag 0.0 0 -> 0
|
||||
ddmxg439 maxmag -0 0.0 -> 0.0
|
||||
ddmxg440 maxmag -0.0 0.0 -> 0.0
|
||||
ddmxg441 maxmag -0.0 0.00 -> 0.00
|
||||
ddmxg442 maxmag -0.00 0.0 -> 0.0
|
||||
ddmxg443 maxmag -0.0 0 -> 0
|
||||
ddmxg444 maxmag -0 0 -> 0
|
||||
ddmxg445 maxmag -0 -0.0 -> -0.0
|
||||
ddmxg446 maxmag -0.100 -0 -> -0.100
|
||||
ddmxg447 maxmag -0.10 -0.100 -> -0.100
|
||||
ddmxg448 maxmag -0.1 -0.10 -> -0.10
|
||||
ddmxg449 maxmag -1.0 -0.1 -> -1.0
|
||||
ddmxg450 maxmag -1 -1.0 -> -1.0
|
||||
ddmxg451 maxmag -1.1 -1 -> -1.1
|
||||
ddmxg453 maxmag -Inf -1.1 -> -Infinity
|
||||
-- largies
|
||||
ddmxg460 maxmag 1000 1E+3 -> 1E+3
|
||||
ddmxg461 maxmag 1E+3 1000 -> 1E+3
|
||||
ddmxg462 maxmag 1000 -1E+3 -> 1000
|
||||
ddmxg463 maxmag 1E+3 -1000 -> 1E+3
|
||||
ddmxg464 maxmag -1000 1E+3 -> 1E+3
|
||||
ddmxg465 maxmag -1E+3 1000 -> 1000
|
||||
ddmxg466 maxmag -1000 -1E+3 -> -1000
|
||||
ddmxg467 maxmag -1E+3 -1000 -> -1000
|
||||
|
||||
-- subnormals
|
||||
ddmxg510 maxmag 1.00E-383 0 -> 1.00E-383
|
||||
ddmxg511 maxmag 0.1E-383 0 -> 1E-384 Subnormal
|
||||
ddmxg512 maxmag 0.10E-383 0 -> 1.0E-384 Subnormal
|
||||
ddmxg513 maxmag 0.100E-383 0 -> 1.00E-384 Subnormal
|
||||
ddmxg514 maxmag 0.01E-383 0 -> 1E-385 Subnormal
|
||||
ddmxg515 maxmag 0.999E-383 0 -> 9.99E-384 Subnormal
|
||||
ddmxg516 maxmag 0.099E-383 0 -> 9.9E-385 Subnormal
|
||||
ddmxg517 maxmag 0.009E-383 0 -> 9E-386 Subnormal
|
||||
ddmxg518 maxmag 0.001E-383 0 -> 1E-386 Subnormal
|
||||
ddmxg519 maxmag 0.0009E-383 0 -> 9E-387 Subnormal
|
||||
ddmxg520 maxmag 0.0001E-383 0 -> 1E-387 Subnormal
|
||||
|
||||
ddmxg530 maxmag -1.00E-383 0 -> -1.00E-383
|
||||
ddmxg531 maxmag -0.1E-383 0 -> -1E-384 Subnormal
|
||||
ddmxg532 maxmag -0.10E-383 0 -> -1.0E-384 Subnormal
|
||||
ddmxg533 maxmag -0.100E-383 0 -> -1.00E-384 Subnormal
|
||||
ddmxg534 maxmag -0.01E-383 0 -> -1E-385 Subnormal
|
||||
ddmxg535 maxmag -0.999E-383 0 -> -9.99E-384 Subnormal
|
||||
ddmxg536 maxmag -0.099E-383 0 -> -9.9E-385 Subnormal
|
||||
ddmxg537 maxmag -0.009E-383 0 -> -9E-386 Subnormal
|
||||
ddmxg538 maxmag -0.001E-383 0 -> -1E-386 Subnormal
|
||||
ddmxg539 maxmag -0.0009E-383 0 -> -9E-387 Subnormal
|
||||
ddmxg540 maxmag -0.0001E-383 0 -> -1E-387 Subnormal
|
||||
|
||||
-- Null tests
|
||||
ddmxg900 maxmag 10 # -> NaN Invalid_operation
|
||||
ddmxg901 maxmag # 10 -> NaN Invalid_operation
|
||||
|
@ -0,0 +1,309 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMin.decTest -- decDouble minnum --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- we assume that base comparison is tested in compare.decTest, so
|
||||
-- these mainly cover special cases and rounding
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddmin001 min -2 -2 -> -2
|
||||
ddmin002 min -2 -1 -> -2
|
||||
ddmin003 min -2 0 -> -2
|
||||
ddmin004 min -2 1 -> -2
|
||||
ddmin005 min -2 2 -> -2
|
||||
ddmin006 min -1 -2 -> -2
|
||||
ddmin007 min -1 -1 -> -1
|
||||
ddmin008 min -1 0 -> -1
|
||||
ddmin009 min -1 1 -> -1
|
||||
ddmin010 min -1 2 -> -1
|
||||
ddmin011 min 0 -2 -> -2
|
||||
ddmin012 min 0 -1 -> -1
|
||||
ddmin013 min 0 0 -> 0
|
||||
ddmin014 min 0 1 -> 0
|
||||
ddmin015 min 0 2 -> 0
|
||||
ddmin016 min 1 -2 -> -2
|
||||
ddmin017 min 1 -1 -> -1
|
||||
ddmin018 min 1 0 -> 0
|
||||
ddmin019 min 1 1 -> 1
|
||||
ddmin020 min 1 2 -> 1
|
||||
ddmin021 min 2 -2 -> -2
|
||||
ddmin022 min 2 -1 -> -1
|
||||
ddmin023 min 2 0 -> 0
|
||||
ddmin025 min 2 1 -> 1
|
||||
ddmin026 min 2 2 -> 2
|
||||
|
||||
-- extended zeros
|
||||
ddmin030 min 0 0 -> 0
|
||||
ddmin031 min 0 -0 -> -0
|
||||
ddmin032 min 0 -0.0 -> -0.0
|
||||
ddmin033 min 0 0.0 -> 0.0
|
||||
ddmin034 min -0 0 -> -0
|
||||
ddmin035 min -0 -0 -> -0
|
||||
ddmin036 min -0 -0.0 -> -0
|
||||
ddmin037 min -0 0.0 -> -0
|
||||
ddmin038 min 0.0 0 -> 0.0
|
||||
ddmin039 min 0.0 -0 -> -0
|
||||
ddmin040 min 0.0 -0.0 -> -0.0
|
||||
ddmin041 min 0.0 0.0 -> 0.0
|
||||
ddmin042 min -0.0 0 -> -0.0
|
||||
ddmin043 min -0.0 -0 -> -0
|
||||
ddmin044 min -0.0 -0.0 -> -0.0
|
||||
ddmin045 min -0.0 0.0 -> -0.0
|
||||
|
||||
ddmin046 min 0E1 -0E1 -> -0E+1
|
||||
ddmin047 min -0E1 0E2 -> -0E+1
|
||||
ddmin048 min 0E2 0E1 -> 0E+1
|
||||
ddmin049 min 0E1 0E2 -> 0E+1
|
||||
ddmin050 min -0E3 -0E2 -> -0E+3
|
||||
ddmin051 min -0E2 -0E3 -> -0E+3
|
||||
|
||||
-- Specials
|
||||
ddmin090 min Inf -Inf -> -Infinity
|
||||
ddmin091 min Inf -1000 -> -1000
|
||||
ddmin092 min Inf -1 -> -1
|
||||
ddmin093 min Inf -0 -> -0
|
||||
ddmin094 min Inf 0 -> 0
|
||||
ddmin095 min Inf 1 -> 1
|
||||
ddmin096 min Inf 1000 -> 1000
|
||||
ddmin097 min Inf Inf -> Infinity
|
||||
ddmin098 min -1000 Inf -> -1000
|
||||
ddmin099 min -Inf Inf -> -Infinity
|
||||
ddmin100 min -1 Inf -> -1
|
||||
ddmin101 min -0 Inf -> -0
|
||||
ddmin102 min 0 Inf -> 0
|
||||
ddmin103 min 1 Inf -> 1
|
||||
ddmin104 min 1000 Inf -> 1000
|
||||
ddmin105 min Inf Inf -> Infinity
|
||||
|
||||
ddmin120 min -Inf -Inf -> -Infinity
|
||||
ddmin121 min -Inf -1000 -> -Infinity
|
||||
ddmin122 min -Inf -1 -> -Infinity
|
||||
ddmin123 min -Inf -0 -> -Infinity
|
||||
ddmin124 min -Inf 0 -> -Infinity
|
||||
ddmin125 min -Inf 1 -> -Infinity
|
||||
ddmin126 min -Inf 1000 -> -Infinity
|
||||
ddmin127 min -Inf Inf -> -Infinity
|
||||
ddmin128 min -Inf -Inf -> -Infinity
|
||||
ddmin129 min -1000 -Inf -> -Infinity
|
||||
ddmin130 min -1 -Inf -> -Infinity
|
||||
ddmin131 min -0 -Inf -> -Infinity
|
||||
ddmin132 min 0 -Inf -> -Infinity
|
||||
ddmin133 min 1 -Inf -> -Infinity
|
||||
ddmin134 min 1000 -Inf -> -Infinity
|
||||
ddmin135 min Inf -Inf -> -Infinity
|
||||
|
||||
-- 2004.08.02 754r chooses number over NaN in mixed cases
|
||||
ddmin141 min NaN -Inf -> -Infinity
|
||||
ddmin142 min NaN -1000 -> -1000
|
||||
ddmin143 min NaN -1 -> -1
|
||||
ddmin144 min NaN -0 -> -0
|
||||
ddmin145 min NaN 0 -> 0
|
||||
ddmin146 min NaN 1 -> 1
|
||||
ddmin147 min NaN 1000 -> 1000
|
||||
ddmin148 min NaN Inf -> Infinity
|
||||
ddmin149 min NaN NaN -> NaN
|
||||
ddmin150 min -Inf NaN -> -Infinity
|
||||
ddmin151 min -1000 NaN -> -1000
|
||||
ddmin152 min -1 -NaN -> -1
|
||||
ddmin153 min -0 NaN -> -0
|
||||
ddmin154 min 0 -NaN -> 0
|
||||
ddmin155 min 1 NaN -> 1
|
||||
ddmin156 min 1000 NaN -> 1000
|
||||
ddmin157 min Inf NaN -> Infinity
|
||||
|
||||
ddmin161 min sNaN -Inf -> NaN Invalid_operation
|
||||
ddmin162 min sNaN -1000 -> NaN Invalid_operation
|
||||
ddmin163 min sNaN -1 -> NaN Invalid_operation
|
||||
ddmin164 min sNaN -0 -> NaN Invalid_operation
|
||||
ddmin165 min -sNaN 0 -> -NaN Invalid_operation
|
||||
ddmin166 min -sNaN 1 -> -NaN Invalid_operation
|
||||
ddmin167 min sNaN 1000 -> NaN Invalid_operation
|
||||
ddmin168 min sNaN NaN -> NaN Invalid_operation
|
||||
ddmin169 min sNaN sNaN -> NaN Invalid_operation
|
||||
ddmin170 min NaN sNaN -> NaN Invalid_operation
|
||||
ddmin171 min -Inf sNaN -> NaN Invalid_operation
|
||||
ddmin172 min -1000 sNaN -> NaN Invalid_operation
|
||||
ddmin173 min -1 sNaN -> NaN Invalid_operation
|
||||
ddmin174 min -0 sNaN -> NaN Invalid_operation
|
||||
ddmin175 min 0 sNaN -> NaN Invalid_operation
|
||||
ddmin176 min 1 sNaN -> NaN Invalid_operation
|
||||
ddmin177 min 1000 sNaN -> NaN Invalid_operation
|
||||
ddmin178 min Inf sNaN -> NaN Invalid_operation
|
||||
ddmin179 min NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddmin181 min NaN9 -Inf -> -Infinity
|
||||
ddmin182 min -NaN8 9990 -> 9990
|
||||
ddmin183 min NaN71 Inf -> Infinity
|
||||
|
||||
ddmin184 min NaN1 NaN54 -> NaN1
|
||||
ddmin185 min NaN22 -NaN53 -> NaN22
|
||||
ddmin186 min -NaN3 NaN6 -> -NaN3
|
||||
ddmin187 min -NaN44 NaN7 -> -NaN44
|
||||
|
||||
ddmin188 min -Inf NaN41 -> -Infinity
|
||||
ddmin189 min -9999 -NaN33 -> -9999
|
||||
ddmin190 min Inf NaN2 -> Infinity
|
||||
|
||||
ddmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
ddmin192 min sNaN98 -11 -> NaN98 Invalid_operation
|
||||
ddmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
|
||||
ddmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
|
||||
ddmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
ddmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddmin197 min 088 sNaN91 -> NaN91 Invalid_operation
|
||||
ddmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
ddmin199 min NaN sNaN86 -> NaN86 Invalid_operation
|
||||
|
||||
-- old rounding checks
|
||||
ddmin221 min -12345678000 1 -> -12345678000
|
||||
ddmin222 min 1 -12345678000 -> -12345678000
|
||||
ddmin223 min -1234567800 1 -> -1234567800
|
||||
ddmin224 min 1 -1234567800 -> -1234567800
|
||||
ddmin225 min -1234567890 1 -> -1234567890
|
||||
ddmin226 min 1 -1234567890 -> -1234567890
|
||||
ddmin227 min -1234567891 1 -> -1234567891
|
||||
ddmin228 min 1 -1234567891 -> -1234567891
|
||||
ddmin229 min -12345678901 1 -> -12345678901
|
||||
ddmin230 min 1 -12345678901 -> -12345678901
|
||||
ddmin231 min -1234567896 1 -> -1234567896
|
||||
ddmin232 min 1 -1234567896 -> -1234567896
|
||||
ddmin233 min 1234567891 1 -> 1
|
||||
ddmin234 min 1 1234567891 -> 1
|
||||
ddmin235 min 12345678901 1 -> 1
|
||||
ddmin236 min 1 12345678901 -> 1
|
||||
ddmin237 min 1234567896 1 -> 1
|
||||
ddmin238 min 1 1234567896 -> 1
|
||||
|
||||
-- from examples
|
||||
ddmin280 min '3' '2' -> '2'
|
||||
ddmin281 min '-10' '3' -> '-10'
|
||||
ddmin282 min '1.0' '1' -> '1.0'
|
||||
ddmin283 min '1' '1.0' -> '1.0'
|
||||
ddmin284 min '7' 'NaN' -> '7'
|
||||
|
||||
-- expanded list from min/max 754r purple prose
|
||||
-- [explicit tests for exponent ordering]
|
||||
ddmin401 min Inf 1.1 -> 1.1
|
||||
ddmin402 min 1.1 1 -> 1
|
||||
ddmin403 min 1 1.0 -> 1.0
|
||||
ddmin404 min 1.0 0.1 -> 0.1
|
||||
ddmin405 min 0.1 0.10 -> 0.10
|
||||
ddmin406 min 0.10 0.100 -> 0.100
|
||||
ddmin407 min 0.10 0 -> 0
|
||||
ddmin408 min 0 0.0 -> 0.0
|
||||
ddmin409 min 0.0 -0 -> -0
|
||||
ddmin410 min 0.0 -0.0 -> -0.0
|
||||
ddmin411 min 0.00 -0.0 -> -0.0
|
||||
ddmin412 min 0.0 -0.00 -> -0.00
|
||||
ddmin413 min 0 -0.0 -> -0.0
|
||||
ddmin414 min 0 -0 -> -0
|
||||
ddmin415 min -0.0 -0 -> -0
|
||||
ddmin416 min -0 -0.100 -> -0.100
|
||||
ddmin417 min -0.100 -0.10 -> -0.10
|
||||
ddmin418 min -0.10 -0.1 -> -0.1
|
||||
ddmin419 min -0.1 -1.0 -> -1.0
|
||||
ddmin420 min -1.0 -1 -> -1
|
||||
ddmin421 min -1 -1.1 -> -1.1
|
||||
ddmin423 min -1.1 -Inf -> -Infinity
|
||||
-- same with operands reversed
|
||||
ddmin431 min 1.1 Inf -> 1.1
|
||||
ddmin432 min 1 1.1 -> 1
|
||||
ddmin433 min 1.0 1 -> 1.0
|
||||
ddmin434 min 0.1 1.0 -> 0.1
|
||||
ddmin435 min 0.10 0.1 -> 0.10
|
||||
ddmin436 min 0.100 0.10 -> 0.100
|
||||
ddmin437 min 0 0.10 -> 0
|
||||
ddmin438 min 0.0 0 -> 0.0
|
||||
ddmin439 min -0 0.0 -> -0
|
||||
ddmin440 min -0.0 0.0 -> -0.0
|
||||
ddmin441 min -0.0 0.00 -> -0.0
|
||||
ddmin442 min -0.00 0.0 -> -0.00
|
||||
ddmin443 min -0.0 0 -> -0.0
|
||||
ddmin444 min -0 0 -> -0
|
||||
ddmin445 min -0 -0.0 -> -0
|
||||
ddmin446 min -0.100 -0 -> -0.100
|
||||
ddmin447 min -0.10 -0.100 -> -0.10
|
||||
ddmin448 min -0.1 -0.10 -> -0.1
|
||||
ddmin449 min -1.0 -0.1 -> -1.0
|
||||
ddmin450 min -1 -1.0 -> -1
|
||||
ddmin451 min -1.1 -1 -> -1.1
|
||||
ddmin453 min -Inf -1.1 -> -Infinity
|
||||
-- largies
|
||||
ddmin460 min 1000 1E+3 -> 1000
|
||||
ddmin461 min 1E+3 1000 -> 1000
|
||||
ddmin462 min 1000 -1E+3 -> -1E+3
|
||||
ddmin463 min 1E+3 -384 -> -384
|
||||
ddmin464 min -384 1E+3 -> -384
|
||||
ddmin465 min -1E+3 1000 -> -1E+3
|
||||
ddmin466 min -384 -1E+3 -> -1E+3
|
||||
ddmin467 min -1E+3 -384 -> -1E+3
|
||||
|
||||
-- misalignment traps for little-endian
|
||||
ddmin471 min 1.0 0.1 -> 0.1
|
||||
ddmin472 min 0.1 1.0 -> 0.1
|
||||
ddmin473 min 10.0 0.1 -> 0.1
|
||||
ddmin474 min 0.1 10.0 -> 0.1
|
||||
ddmin475 min 100 1.0 -> 1.0
|
||||
ddmin476 min 1.0 100 -> 1.0
|
||||
ddmin477 min 1000 10.0 -> 10.0
|
||||
ddmin478 min 10.0 1000 -> 10.0
|
||||
ddmin479 min 10000 100.0 -> 100.0
|
||||
ddmin480 min 100.0 10000 -> 100.0
|
||||
ddmin481 min 100000 1000.0 -> 1000.0
|
||||
ddmin482 min 1000.0 100000 -> 1000.0
|
||||
ddmin483 min 1000000 10000.0 -> 10000.0
|
||||
ddmin484 min 10000.0 1000000 -> 10000.0
|
||||
|
||||
-- subnormals
|
||||
ddmin510 min 1.00E-383 0 -> 0
|
||||
ddmin511 min 0.1E-383 0 -> 0
|
||||
ddmin512 min 0.10E-383 0 -> 0
|
||||
ddmin513 min 0.100E-383 0 -> 0
|
||||
ddmin514 min 0.01E-383 0 -> 0
|
||||
ddmin515 min 0.999E-383 0 -> 0
|
||||
ddmin516 min 0.099E-383 0 -> 0
|
||||
ddmin517 min 0.009E-383 0 -> 0
|
||||
ddmin518 min 0.001E-383 0 -> 0
|
||||
ddmin519 min 0.0009E-383 0 -> 0
|
||||
ddmin520 min 0.0001E-383 0 -> 0
|
||||
|
||||
ddmin530 min -1.00E-383 0 -> -1.00E-383
|
||||
ddmin531 min -0.1E-383 0 -> -1E-384 Subnormal
|
||||
ddmin532 min -0.10E-383 0 -> -1.0E-384 Subnormal
|
||||
ddmin533 min -0.100E-383 0 -> -1.00E-384 Subnormal
|
||||
ddmin534 min -0.01E-383 0 -> -1E-385 Subnormal
|
||||
ddmin535 min -0.999E-383 0 -> -9.99E-384 Subnormal
|
||||
ddmin536 min -0.099E-383 0 -> -9.9E-385 Subnormal
|
||||
ddmin537 min -0.009E-383 0 -> -9E-386 Subnormal
|
||||
ddmin538 min -0.001E-383 0 -> -1E-386 Subnormal
|
||||
ddmin539 min -0.0009E-383 0 -> -9E-387 Subnormal
|
||||
ddmin540 min -0.0001E-383 0 -> -1E-387 Subnormal
|
||||
|
||||
|
||||
-- Null tests
|
||||
ddmin900 min 10 # -> NaN Invalid_operation
|
||||
ddmin901 min # 10 -> NaN Invalid_operation
|
@ -0,0 +1,293 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMinMag.decTest -- decDouble minnummag --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- we assume that base comparison is tested in compare.decTest, so
|
||||
-- these mainly cover special cases and rounding
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddmng001 minmag -2 -2 -> -2
|
||||
ddmng002 minmag -2 -1 -> -1
|
||||
ddmng003 minmag -2 0 -> 0
|
||||
ddmng004 minmag -2 1 -> 1
|
||||
ddmng005 minmag -2 2 -> -2
|
||||
ddmng006 minmag -1 -2 -> -1
|
||||
ddmng007 minmag -1 -1 -> -1
|
||||
ddmng008 minmag -1 0 -> 0
|
||||
ddmng009 minmag -1 1 -> -1
|
||||
ddmng010 minmag -1 2 -> -1
|
||||
ddmng011 minmag 0 -2 -> 0
|
||||
ddmng012 minmag 0 -1 -> 0
|
||||
ddmng013 minmag 0 0 -> 0
|
||||
ddmng014 minmag 0 1 -> 0
|
||||
ddmng015 minmag 0 2 -> 0
|
||||
ddmng016 minmag 1 -2 -> 1
|
||||
ddmng017 minmag 1 -1 -> -1
|
||||
ddmng018 minmag 1 0 -> 0
|
||||
ddmng019 minmag 1 1 -> 1
|
||||
ddmng020 minmag 1 2 -> 1
|
||||
ddmng021 minmag 2 -2 -> -2
|
||||
ddmng022 minmag 2 -1 -> -1
|
||||
ddmng023 minmag 2 0 -> 0
|
||||
ddmng025 minmag 2 1 -> 1
|
||||
ddmng026 minmag 2 2 -> 2
|
||||
|
||||
-- extended zeros
|
||||
ddmng030 minmag 0 0 -> 0
|
||||
ddmng031 minmag 0 -0 -> -0
|
||||
ddmng032 minmag 0 -0.0 -> -0.0
|
||||
ddmng033 minmag 0 0.0 -> 0.0
|
||||
ddmng034 minmag -0 0 -> -0
|
||||
ddmng035 minmag -0 -0 -> -0
|
||||
ddmng036 minmag -0 -0.0 -> -0
|
||||
ddmng037 minmag -0 0.0 -> -0
|
||||
ddmng038 minmag 0.0 0 -> 0.0
|
||||
ddmng039 minmag 0.0 -0 -> -0
|
||||
ddmng040 minmag 0.0 -0.0 -> -0.0
|
||||
ddmng041 minmag 0.0 0.0 -> 0.0
|
||||
ddmng042 minmag -0.0 0 -> -0.0
|
||||
ddmng043 minmag -0.0 -0 -> -0
|
||||
ddmng044 minmag -0.0 -0.0 -> -0.0
|
||||
ddmng045 minmag -0.0 0.0 -> -0.0
|
||||
|
||||
ddmng046 minmag 0E1 -0E1 -> -0E+1
|
||||
ddmng047 minmag -0E1 0E2 -> -0E+1
|
||||
ddmng048 minmag 0E2 0E1 -> 0E+1
|
||||
ddmng049 minmag 0E1 0E2 -> 0E+1
|
||||
ddmng050 minmag -0E3 -0E2 -> -0E+3
|
||||
ddmng051 minmag -0E2 -0E3 -> -0E+3
|
||||
|
||||
-- Specials
|
||||
ddmng090 minmag Inf -Inf -> -Infinity
|
||||
ddmng091 minmag Inf -1000 -> -1000
|
||||
ddmng092 minmag Inf -1 -> -1
|
||||
ddmng093 minmag Inf -0 -> -0
|
||||
ddmng094 minmag Inf 0 -> 0
|
||||
ddmng095 minmag Inf 1 -> 1
|
||||
ddmng096 minmag Inf 1000 -> 1000
|
||||
ddmng097 minmag Inf Inf -> Infinity
|
||||
ddmng098 minmag -1000 Inf -> -1000
|
||||
ddmng099 minmag -Inf Inf -> -Infinity
|
||||
ddmng100 minmag -1 Inf -> -1
|
||||
ddmng101 minmag -0 Inf -> -0
|
||||
ddmng102 minmag 0 Inf -> 0
|
||||
ddmng103 minmag 1 Inf -> 1
|
||||
ddmng104 minmag 1000 Inf -> 1000
|
||||
ddmng105 minmag Inf Inf -> Infinity
|
||||
|
||||
ddmng120 minmag -Inf -Inf -> -Infinity
|
||||
ddmng121 minmag -Inf -1000 -> -1000
|
||||
ddmng122 minmag -Inf -1 -> -1
|
||||
ddmng123 minmag -Inf -0 -> -0
|
||||
ddmng124 minmag -Inf 0 -> 0
|
||||
ddmng125 minmag -Inf 1 -> 1
|
||||
ddmng126 minmag -Inf 1000 -> 1000
|
||||
ddmng127 minmag -Inf Inf -> -Infinity
|
||||
ddmng128 minmag -Inf -Inf -> -Infinity
|
||||
ddmng129 minmag -1000 -Inf -> -1000
|
||||
ddmng130 minmag -1 -Inf -> -1
|
||||
ddmng131 minmag -0 -Inf -> -0
|
||||
ddmng132 minmag 0 -Inf -> 0
|
||||
ddmng133 minmag 1 -Inf -> 1
|
||||
ddmng134 minmag 1000 -Inf -> 1000
|
||||
ddmng135 minmag Inf -Inf -> -Infinity
|
||||
|
||||
-- 2004.08.02 754r chooses number over NaN in mixed cases
|
||||
ddmng141 minmag NaN -Inf -> -Infinity
|
||||
ddmng142 minmag NaN -1000 -> -1000
|
||||
ddmng143 minmag NaN -1 -> -1
|
||||
ddmng144 minmag NaN -0 -> -0
|
||||
ddmng145 minmag NaN 0 -> 0
|
||||
ddmng146 minmag NaN 1 -> 1
|
||||
ddmng147 minmag NaN 1000 -> 1000
|
||||
ddmng148 minmag NaN Inf -> Infinity
|
||||
ddmng149 minmag NaN NaN -> NaN
|
||||
ddmng150 minmag -Inf NaN -> -Infinity
|
||||
ddmng151 minmag -1000 NaN -> -1000
|
||||
ddmng152 minmag -1 -NaN -> -1
|
||||
ddmng153 minmag -0 NaN -> -0
|
||||
ddmng154 minmag 0 -NaN -> 0
|
||||
ddmng155 minmag 1 NaN -> 1
|
||||
ddmng156 minmag 1000 NaN -> 1000
|
||||
ddmng157 minmag Inf NaN -> Infinity
|
||||
|
||||
ddmng161 minmag sNaN -Inf -> NaN Invalid_operation
|
||||
ddmng162 minmag sNaN -1000 -> NaN Invalid_operation
|
||||
ddmng163 minmag sNaN -1 -> NaN Invalid_operation
|
||||
ddmng164 minmag sNaN -0 -> NaN Invalid_operation
|
||||
ddmng165 minmag -sNaN 0 -> -NaN Invalid_operation
|
||||
ddmng166 minmag -sNaN 1 -> -NaN Invalid_operation
|
||||
ddmng167 minmag sNaN 1000 -> NaN Invalid_operation
|
||||
ddmng168 minmag sNaN NaN -> NaN Invalid_operation
|
||||
ddmng169 minmag sNaN sNaN -> NaN Invalid_operation
|
||||
ddmng170 minmag NaN sNaN -> NaN Invalid_operation
|
||||
ddmng171 minmag -Inf sNaN -> NaN Invalid_operation
|
||||
ddmng172 minmag -1000 sNaN -> NaN Invalid_operation
|
||||
ddmng173 minmag -1 sNaN -> NaN Invalid_operation
|
||||
ddmng174 minmag -0 sNaN -> NaN Invalid_operation
|
||||
ddmng175 minmag 0 sNaN -> NaN Invalid_operation
|
||||
ddmng176 minmag 1 sNaN -> NaN Invalid_operation
|
||||
ddmng177 minmag 1000 sNaN -> NaN Invalid_operation
|
||||
ddmng178 minmag Inf sNaN -> NaN Invalid_operation
|
||||
ddmng179 minmag NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddmng181 minmag NaN9 -Inf -> -Infinity
|
||||
ddmng182 minmag -NaN8 9990 -> 9990
|
||||
ddmng183 minmag NaN71 Inf -> Infinity
|
||||
|
||||
ddmng184 minmag NaN1 NaN54 -> NaN1
|
||||
ddmng185 minmag NaN22 -NaN53 -> NaN22
|
||||
ddmng186 minmag -NaN3 NaN6 -> -NaN3
|
||||
ddmng187 minmag -NaN44 NaN7 -> -NaN44
|
||||
|
||||
ddmng188 minmag -Inf NaN41 -> -Infinity
|
||||
ddmng189 minmag -9999 -NaN33 -> -9999
|
||||
ddmng190 minmag Inf NaN2 -> Infinity
|
||||
|
||||
ddmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
ddmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
|
||||
ddmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
|
||||
ddmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
|
||||
ddmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
ddmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
|
||||
ddmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
ddmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
|
||||
|
||||
-- old rounding checks
|
||||
ddmng221 minmag -12345678000 1 -> 1
|
||||
ddmng222 minmag 1 -12345678000 -> 1
|
||||
ddmng223 minmag -1234567800 1 -> 1
|
||||
ddmng224 minmag 1 -1234567800 -> 1
|
||||
ddmng225 minmag -1234567890 1 -> 1
|
||||
ddmng226 minmag 1 -1234567890 -> 1
|
||||
ddmng227 minmag -1234567891 1 -> 1
|
||||
ddmng228 minmag 1 -1234567891 -> 1
|
||||
ddmng229 minmag -12345678901 1 -> 1
|
||||
ddmng230 minmag 1 -12345678901 -> 1
|
||||
ddmng231 minmag -1234567896 1 -> 1
|
||||
ddmng232 minmag 1 -1234567896 -> 1
|
||||
ddmng233 minmag 1234567891 1 -> 1
|
||||
ddmng234 minmag 1 1234567891 -> 1
|
||||
ddmng235 minmag 12345678901 1 -> 1
|
||||
ddmng236 minmag 1 12345678901 -> 1
|
||||
ddmng237 minmag 1234567896 1 -> 1
|
||||
ddmng238 minmag 1 1234567896 -> 1
|
||||
|
||||
-- from examples
|
||||
ddmng280 minmag '3' '2' -> '2'
|
||||
ddmng281 minmag '-10' '3' -> '3'
|
||||
ddmng282 minmag '1.0' '1' -> '1.0'
|
||||
ddmng283 minmag '1' '1.0' -> '1.0'
|
||||
ddmng284 minmag '7' 'NaN' -> '7'
|
||||
|
||||
-- expanded list from min/max 754r purple prose
|
||||
-- [explicit tests for exponent ordering]
|
||||
ddmng401 minmag Inf 1.1 -> 1.1
|
||||
ddmng402 minmag 1.1 1 -> 1
|
||||
ddmng403 minmag 1 1.0 -> 1.0
|
||||
ddmng404 minmag 1.0 0.1 -> 0.1
|
||||
ddmng405 minmag 0.1 0.10 -> 0.10
|
||||
ddmng406 minmag 0.10 0.100 -> 0.100
|
||||
ddmng407 minmag 0.10 0 -> 0
|
||||
ddmng408 minmag 0 0.0 -> 0.0
|
||||
ddmng409 minmag 0.0 -0 -> -0
|
||||
ddmng410 minmag 0.0 -0.0 -> -0.0
|
||||
ddmng411 minmag 0.00 -0.0 -> -0.0
|
||||
ddmng412 minmag 0.0 -0.00 -> -0.00
|
||||
ddmng413 minmag 0 -0.0 -> -0.0
|
||||
ddmng414 minmag 0 -0 -> -0
|
||||
ddmng415 minmag -0.0 -0 -> -0
|
||||
ddmng416 minmag -0 -0.100 -> -0
|
||||
ddmng417 minmag -0.100 -0.10 -> -0.10
|
||||
ddmng418 minmag -0.10 -0.1 -> -0.1
|
||||
ddmng419 minmag -0.1 -1.0 -> -0.1
|
||||
ddmng420 minmag -1.0 -1 -> -1
|
||||
ddmng421 minmag -1 -1.1 -> -1
|
||||
ddmng423 minmag -1.1 -Inf -> -1.1
|
||||
-- same with operands reversed
|
||||
ddmng431 minmag 1.1 Inf -> 1.1
|
||||
ddmng432 minmag 1 1.1 -> 1
|
||||
ddmng433 minmag 1.0 1 -> 1.0
|
||||
ddmng434 minmag 0.1 1.0 -> 0.1
|
||||
ddmng435 minmag 0.10 0.1 -> 0.10
|
||||
ddmng436 minmag 0.100 0.10 -> 0.100
|
||||
ddmng437 minmag 0 0.10 -> 0
|
||||
ddmng438 minmag 0.0 0 -> 0.0
|
||||
ddmng439 minmag -0 0.0 -> -0
|
||||
ddmng440 minmag -0.0 0.0 -> -0.0
|
||||
ddmng441 minmag -0.0 0.00 -> -0.0
|
||||
ddmng442 minmag -0.00 0.0 -> -0.00
|
||||
ddmng443 minmag -0.0 0 -> -0.0
|
||||
ddmng444 minmag -0 0 -> -0
|
||||
ddmng445 minmag -0 -0.0 -> -0
|
||||
ddmng446 minmag -0.100 -0 -> -0
|
||||
ddmng447 minmag -0.10 -0.100 -> -0.10
|
||||
ddmng448 minmag -0.1 -0.10 -> -0.1
|
||||
ddmng449 minmag -1.0 -0.1 -> -0.1
|
||||
ddmng450 minmag -1 -1.0 -> -1
|
||||
ddmng451 minmag -1.1 -1 -> -1
|
||||
ddmng453 minmag -Inf -1.1 -> -1.1
|
||||
-- largies
|
||||
ddmng460 minmag 1000 1E+3 -> 1000
|
||||
ddmng461 minmag 1E+3 1000 -> 1000
|
||||
ddmng462 minmag 1000 -1E+3 -> -1E+3
|
||||
ddmng463 minmag 1E+3 -384 -> -384
|
||||
ddmng464 minmag -384 1E+3 -> -384
|
||||
ddmng465 minmag -1E+3 1000 -> -1E+3
|
||||
ddmng466 minmag -384 -1E+3 -> -384
|
||||
ddmng467 minmag -1E+3 -384 -> -384
|
||||
|
||||
-- subnormals
|
||||
ddmng510 minmag 1.00E-383 0 -> 0
|
||||
ddmng511 minmag 0.1E-383 0 -> 0
|
||||
ddmng512 minmag 0.10E-383 0 -> 0
|
||||
ddmng513 minmag 0.100E-383 0 -> 0
|
||||
ddmng514 minmag 0.01E-383 0 -> 0
|
||||
ddmng515 minmag 0.999E-383 0 -> 0
|
||||
ddmng516 minmag 0.099E-383 0 -> 0
|
||||
ddmng517 minmag 0.009E-383 0 -> 0
|
||||
ddmng518 minmag 0.001E-383 0 -> 0
|
||||
ddmng519 minmag 0.0009E-383 0 -> 0
|
||||
ddmng520 minmag 0.0001E-383 0 -> 0
|
||||
|
||||
ddmng530 minmag -1.00E-383 0 -> 0
|
||||
ddmng531 minmag -0.1E-383 0 -> 0
|
||||
ddmng532 minmag -0.10E-383 0 -> 0
|
||||
ddmng533 minmag -0.100E-383 0 -> 0
|
||||
ddmng534 minmag -0.01E-383 0 -> 0
|
||||
ddmng535 minmag -0.999E-383 0 -> 0
|
||||
ddmng536 minmag -0.099E-383 0 -> 0
|
||||
ddmng537 minmag -0.009E-383 0 -> 0
|
||||
ddmng538 minmag -0.001E-383 0 -> 0
|
||||
ddmng539 minmag -0.0009E-383 0 -> 0
|
||||
ddmng540 minmag -0.0001E-383 0 -> 0
|
||||
|
||||
|
||||
-- Null tests
|
||||
ddmng900 minmag 10 # -> NaN Invalid_operation
|
||||
ddmng901 minmag # 10 -> NaN Invalid_operation
|
@ -0,0 +1,88 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMinus.decTest -- decDouble 0-x --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- All operands and results are decDoubles.
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- Sanity check
|
||||
ddmns001 minus +7.50 -> -7.50
|
||||
|
||||
-- Infinities
|
||||
ddmns011 minus Infinity -> -Infinity
|
||||
ddmns012 minus -Infinity -> Infinity
|
||||
|
||||
-- NaNs, 0 payload
|
||||
ddmns021 minus NaN -> NaN
|
||||
ddmns022 minus -NaN -> -NaN
|
||||
ddmns023 minus sNaN -> NaN Invalid_operation
|
||||
ddmns024 minus -sNaN -> -NaN Invalid_operation
|
||||
|
||||
-- NaNs, non-0 payload
|
||||
ddmns031 minus NaN13 -> NaN13
|
||||
ddmns032 minus -NaN13 -> -NaN13
|
||||
ddmns033 minus sNaN13 -> NaN13 Invalid_operation
|
||||
ddmns034 minus -sNaN13 -> -NaN13 Invalid_operation
|
||||
ddmns035 minus NaN70 -> NaN70
|
||||
ddmns036 minus -NaN70 -> -NaN70
|
||||
ddmns037 minus sNaN101 -> NaN101 Invalid_operation
|
||||
ddmns038 minus -sNaN101 -> -NaN101 Invalid_operation
|
||||
|
||||
-- finites
|
||||
ddmns101 minus 7 -> -7
|
||||
ddmns102 minus -7 -> 7
|
||||
ddmns103 minus 75 -> -75
|
||||
ddmns104 minus -75 -> 75
|
||||
ddmns105 minus 7.50 -> -7.50
|
||||
ddmns106 minus -7.50 -> 7.50
|
||||
ddmns107 minus 7.500 -> -7.500
|
||||
ddmns108 minus -7.500 -> 7.500
|
||||
|
||||
-- zeros
|
||||
ddmns111 minus 0 -> 0
|
||||
ddmns112 minus -0 -> 0
|
||||
ddmns113 minus 0E+4 -> 0E+4
|
||||
ddmns114 minus -0E+4 -> 0E+4
|
||||
ddmns115 minus 0.0000 -> 0.0000
|
||||
ddmns116 minus -0.0000 -> 0.0000
|
||||
ddmns117 minus 0E-141 -> 0E-141
|
||||
ddmns118 minus -0E-141 -> 0E-141
|
||||
|
||||
-- full coefficients, alternating bits
|
||||
ddmns121 minus 2682682682682682 -> -2682682682682682
|
||||
ddmns122 minus -2682682682682682 -> 2682682682682682
|
||||
ddmns123 minus 1341341341341341 -> -1341341341341341
|
||||
ddmns124 minus -1341341341341341 -> 1341341341341341
|
||||
|
||||
-- Nmax, Nmin, Ntiny
|
||||
ddmns131 minus 9.999999999999999E+384 -> -9.999999999999999E+384
|
||||
ddmns132 minus 1E-383 -> -1E-383
|
||||
ddmns133 minus 1.000000000000000E-383 -> -1.000000000000000E-383
|
||||
ddmns134 minus 1E-398 -> -1E-398 Subnormal
|
||||
|
||||
ddmns135 minus -1E-398 -> 1E-398 Subnormal
|
||||
ddmns136 minus -1.000000000000000E-383 -> 1.000000000000000E-383
|
||||
ddmns137 minus -1E-383 -> 1E-383
|
||||
ddmns138 minus -9.999999999999999E+384 -> 9.999999999999999E+384
|
@ -0,0 +1,553 @@
|
||||
------------------------------------------------------------------------
|
||||
-- ddMultiply.decTest -- decDouble multiplication --
|
||||
-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
|
||||
------------------------------------------------------------------------
|
||||
-- Please see the document "General Decimal Arithmetic Testcases" --
|
||||
-- at http://www2.hursley.ibm.com/decimal for the description of --
|
||||
-- these testcases. --
|
||||
-- --
|
||||
-- These testcases are experimental ('beta' versions), and they --
|
||||
-- may contain errors. They are offered on an as-is basis. In --
|
||||
-- particular, achieving the same results as the tests here is not --
|
||||
-- a guarantee that an implementation complies with any Standard --
|
||||
-- or specification. The tests are not exhaustive. --
|
||||
-- --
|
||||
-- Please send comments, suggestions, and corrections to the author: --
|
||||
-- Mike Cowlishaw, IBM Fellow --
|
||||
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
|
||||
-- mfc@uk.ibm.com --
|
||||
------------------------------------------------------------------------
|
||||
version: 2.58
|
||||
|
||||
-- This set of tests are for decDoubles only; all arguments are
|
||||
-- representable in a decDouble
|
||||
precision: 16
|
||||
maxExponent: 384
|
||||
minExponent: -383
|
||||
extended: 1
|
||||
clamp: 1
|
||||
rounding: half_even
|
||||
|
||||
-- sanity checks
|
||||
ddmul000 multiply 2 2 -> 4
|
||||
ddmul001 multiply 2 3 -> 6
|
||||
ddmul002 multiply 5 1 -> 5
|
||||
ddmul003 multiply 5 2 -> 10
|
||||
ddmul004 multiply 1.20 2 -> 2.40
|
||||
ddmul005 multiply 1.20 0 -> 0.00
|
||||
ddmul006 multiply 1.20 -2 -> -2.40
|
||||
ddmul007 multiply -1.20 2 -> -2.40
|
||||
ddmul008 multiply -1.20 0 -> -0.00
|
||||
ddmul009 multiply -1.20 -2 -> 2.40
|
||||
ddmul010 multiply 5.09 7.1 -> 36.139
|
||||
ddmul011 multiply 2.5 4 -> 10.0
|
||||
ddmul012 multiply 2.50 4 -> 10.00
|
||||
ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
|
||||
ddmul015 multiply 2.50 4 -> 10.00
|
||||
ddmul016 multiply 9.999999999 9.999999999 -> 99.99999998000000 Inexact Rounded
|
||||
ddmul017 multiply 9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
|
||||
ddmul018 multiply -9.999999999 9.999999999 -> -99.99999998000000 Inexact Rounded
|
||||
ddmul019 multiply -9.999999999 -9.999999999 -> 99.99999998000000 Inexact Rounded
|
||||
|
||||
-- zeros, etc.
|
||||
ddmul021 multiply 0 0 -> 0
|
||||
ddmul022 multiply 0 -0 -> -0
|
||||
ddmul023 multiply -0 0 -> -0
|
||||
ddmul024 multiply -0 -0 -> 0
|
||||
ddmul025 multiply -0.0 -0.0 -> 0.00
|
||||
ddmul026 multiply -0.0 -0.0 -> 0.00
|
||||
ddmul027 multiply -0.0 -0.0 -> 0.00
|
||||
ddmul028 multiply -0.0 -0.0 -> 0.00
|
||||
ddmul030 multiply 5.00 1E-3 -> 0.00500
|
||||
ddmul031 multiply 00.00 0.000 -> 0.00000
|
||||
ddmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
|
||||
ddmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
|
||||
ddmul034 multiply -5.00 1E-3 -> -0.00500
|
||||
ddmul035 multiply -00.00 0.000 -> -0.00000
|
||||
ddmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
|
||||
ddmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
|
||||
ddmul038 multiply 5.00 -1E-3 -> -0.00500
|
||||
ddmul039 multiply 00.00 -0.000 -> -0.00000
|
||||
ddmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
|
||||
ddmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
|
||||
ddmul042 multiply -5.00 -1E-3 -> 0.00500
|
||||
ddmul043 multiply -00.00 -0.000 -> 0.00000
|
||||
ddmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
|
||||
ddmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
|
||||
|
||||
-- examples from decarith
|
||||
ddmul050 multiply 1.20 3 -> 3.60
|
||||
ddmul051 multiply 7 3 -> 21
|
||||
ddmul052 multiply 0.9 0.8 -> 0.72
|
||||
ddmul053 multiply 0.9 -0 -> -0.0
|
||||
ddmul054 multiply 654321 654321 -> 428135971041
|
||||
|
||||
ddmul060 multiply 123.45 1e7 -> 1.2345E+9
|
||||
ddmul061 multiply 123.45 1e8 -> 1.2345E+10
|
||||
ddmul062 multiply 123.45 1e+9 -> 1.2345E+11
|
||||
ddmul063 multiply 123.45 1e10 -> 1.2345E+12
|
||||
ddmul064 multiply 123.45 1e11 -> 1.2345E+13
|
||||
ddmul065 multiply 123.45 1e12 -> 1.2345E+14
|
||||
ddmul066 multiply 123.45 1e13 -> 1.2345E+15
|
||||
|
||||
|
||||
-- test some intermediate lengths
|
||||
-- 1234567890123456
|
||||
ddmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
|
||||
ddmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
|
||||
ddmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
|
||||
ddmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
|
||||
|
||||
-- test some more edge cases and carries
|
||||
ddmul101 multiply 9 9 -> 81
|
||||
ddmul102 multiply 9 90 -> 810
|
||||
ddmul103 multiply 9 900 -> 8100
|
||||
ddmul104 multiply 9 9000 -> 81000
|
||||
ddmul105 multiply 9 90000 -> 810000
|
||||
ddmul106 multiply 9 900000 -> 8100000
|
||||
ddmul107 multiply 9 9000000 -> 81000000
|
||||
ddmul108 multiply 9 90000000 -> 810000000
|
||||
ddmul109 multiply 9 900000000 -> 8100000000
|
||||
ddmul110 multiply 9 9000000000 -> 81000000000
|
||||
ddmul111 multiply 9 90000000000 -> 810000000000
|
||||
ddmul112 multiply 9 900000000000 -> 8100000000000
|
||||
ddmul113 multiply 9 9000000000000 -> 81000000000000
|
||||
ddmul114 multiply 9 90000000000000 -> 810000000000000
|
||||
ddmul115 multiply 9 900000000000000 -> 8100000000000000
|
||||
--ddmul116 multiply 9 9000000000000000 -> 81000000000000000
|
||||
--ddmul117 multiply 9 90000000000000000 -> 810000000000000000
|
||||
--ddmul118 multiply 9 900000000000000000 -> 8100000000000000000
|
||||
--ddmul119 multiply 9 9000000000000000000 -> 81000000000000000000
|
||||
--ddmul120 multiply 9 90000000000000000000 -> 810000000000000000000
|
||||
--ddmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
|
||||
--ddmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
|
||||
--ddmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
|
||||
-- test some more edge cases without carries
|
||||
ddmul131 multiply 3 3 -> 9
|
||||
ddmul132 multiply 3 30 -> 90
|
||||
ddmul133 multiply 3 300 -> 900
|
||||
ddmul134 multiply 3 3000 -> 9000
|
||||
ddmul135 multiply 3 30000 -> 90000
|
||||
ddmul136 multiply 3 300000 -> 900000
|
||||
ddmul137 multiply 3 3000000 -> 9000000
|
||||
ddmul138 multiply 3 30000000 -> 90000000
|
||||
ddmul139 multiply 3 300000000 -> 900000000
|
||||
ddmul140 multiply 3 3000000000 -> 9000000000
|
||||
ddmul141 multiply 3 30000000000 -> 90000000000
|
||||
ddmul142 multiply 3 300000000000 -> 900000000000
|
||||
ddmul143 multiply 3 3000000000000 -> 9000000000000
|
||||
ddmul144 multiply 3 30000000000000 -> 90000000000000
|
||||
ddmul145 multiply 3 300000000000000 -> 900000000000000
|
||||
|
||||
-- test some edge cases with exact rounding
|
||||
ddmul301 multiply 9 9 -> 81
|
||||
ddmul302 multiply 9 90 -> 810
|
||||
ddmul303 multiply 9 900 -> 8100
|
||||
ddmul304 multiply 9 9000 -> 81000
|
||||
ddmul305 multiply 9 90000 -> 810000
|
||||
ddmul306 multiply 9 900000 -> 8100000
|
||||
ddmul307 multiply 9 9000000 -> 81000000
|
||||
ddmul308 multiply 9 90000000 -> 810000000
|
||||
ddmul309 multiply 9 900000000 -> 8100000000
|
||||
ddmul310 multiply 9 9000000000 -> 81000000000
|
||||
ddmul311 multiply 9 90000000000 -> 810000000000
|
||||
ddmul312 multiply 9 900000000000 -> 8100000000000
|
||||
ddmul313 multiply 9 9000000000000 -> 81000000000000
|
||||
ddmul314 multiply 9 90000000000000 -> 810000000000000
|
||||
ddmul315 multiply 9 900000000000000 -> 8100000000000000
|
||||
ddmul316 multiply 9 9000000000000000 -> 8.100000000000000E+16 Rounded
|
||||
ddmul317 multiply 90 9000000000000000 -> 8.100000000000000E+17 Rounded
|
||||
ddmul318 multiply 900 9000000000000000 -> 8.100000000000000E+18 Rounded
|
||||
ddmul319 multiply 9000 9000000000000000 -> 8.100000000000000E+19 Rounded
|
||||
ddmul320 multiply 90000 9000000000000000 -> 8.100000000000000E+20 Rounded
|
||||
ddmul321 multiply 900000 9000000000000000 -> 8.100000000000000E+21 Rounded
|
||||
ddmul322 multiply 9000000 9000000000000000 -> 8.100000000000000E+22 Rounded
|
||||
ddmul323 multiply 90000000 9000000000000000 -> 8.100000000000000E+23 Rounded
|
||||
|
||||
-- tryzeros cases
|
||||
ddmul504 multiply 0E-260 1000E-260 -> 0E-398 Clamped
|
||||
ddmul505 multiply 100E+260 0E+260 -> 0E+369 Clamped
|
||||
-- 65K-1 case
|
||||
ddmul506 multiply 77.1 850 -> 65535.0
|
||||
|
||||
-- mixed with zeros
|
||||
ddmul541 multiply 0 -1 -> -0
|
||||
ddmul542 multiply -0 -1 -> 0
|
||||
ddmul543 multiply 0 1 -> 0
|
||||
ddmul544 multiply -0 1 -> -0
|
||||
ddmul545 multiply -1 0 -> -0
|
||||
ddmul546 multiply -1 -0 -> 0
|
||||
ddmul547 multiply 1 0 -> 0
|
||||
ddmul548 multiply 1 -0 -> -0
|
||||
|
||||
ddmul551 multiply 0.0 -1 -> -0.0
|
||||
ddmul552 multiply -0.0 -1 -> 0.0
|
||||
ddmul553 multiply 0.0 1 -> 0.0
|
||||
ddmul554 multiply -0.0 1 -> -0.0
|
||||
ddmul555 multiply -1.0 0 -> -0.0
|
||||
ddmul556 multiply -1.0 -0 -> 0.0
|
||||
ddmul557 multiply 1.0 0 -> 0.0
|
||||
ddmul558 multiply 1.0 -0 -> -0.0
|
||||
|
||||
ddmul561 multiply 0 -1.0 -> -0.0
|
||||
ddmul562 multiply -0 -1.0 -> 0.0
|
||||
ddmul563 multiply 0 1.0 -> 0.0
|
||||
ddmul564 multiply -0 1.0 -> -0.0
|
||||
ddmul565 multiply -1 0.0 -> -0.0
|
||||
ddmul566 multiply -1 -0.0 -> 0.0
|
||||
ddmul567 multiply 1 0.0 -> 0.0
|
||||
ddmul568 multiply 1 -0.0 -> -0.0
|
||||
|
||||
ddmul571 multiply 0.0 -1.0 -> -0.00
|
||||
ddmul572 multiply -0.0 -1.0 -> 0.00
|
||||
ddmul573 multiply 0.0 1.0 -> 0.00
|
||||
ddmul574 multiply -0.0 1.0 -> -0.00
|
||||
ddmul575 multiply -1.0 0.0 -> -0.00
|
||||
ddmul576 multiply -1.0 -0.0 -> 0.00
|
||||
ddmul577 multiply 1.0 0.0 -> 0.00
|
||||
ddmul578 multiply 1.0 -0.0 -> -0.00
|
||||
|
||||
|
||||
-- Specials
|
||||
ddmul580 multiply Inf -Inf -> -Infinity
|
||||
ddmul581 multiply Inf -1000 -> -Infinity
|
||||
ddmul582 multiply Inf -1 -> -Infinity
|
||||
ddmul583 multiply Inf -0 -> NaN Invalid_operation
|
||||
ddmul584 multiply Inf 0 -> NaN Invalid_operation
|
||||
ddmul585 multiply Inf 1 -> Infinity
|
||||
ddmul586 multiply Inf 1000 -> Infinity
|
||||
ddmul587 multiply Inf Inf -> Infinity
|
||||
ddmul588 multiply -1000 Inf -> -Infinity
|
||||
ddmul589 multiply -Inf Inf -> -Infinity
|
||||
ddmul590 multiply -1 Inf -> -Infinity
|
||||
ddmul591 multiply -0 Inf -> NaN Invalid_operation
|
||||
ddmul592 multiply 0 Inf -> NaN Invalid_operation
|
||||
ddmul593 multiply 1 Inf -> Infinity
|
||||
ddmul594 multiply 1000 Inf -> Infinity
|
||||
ddmul595 multiply Inf Inf -> Infinity
|
||||
|
||||
ddmul600 multiply -Inf -Inf -> Infinity
|
||||
ddmul601 multiply -Inf -1000 -> Infinity
|
||||
ddmul602 multiply -Inf -1 -> Infinity
|
||||
ddmul603 multiply -Inf -0 -> NaN Invalid_operation
|
||||
ddmul604 multiply -Inf 0 -> NaN Invalid_operation
|
||||
ddmul605 multiply -Inf 1 -> -Infinity
|
||||
ddmul606 multiply -Inf 1000 -> -Infinity
|
||||
ddmul607 multiply -Inf Inf -> -Infinity
|
||||
ddmul608 multiply -1000 Inf -> -Infinity
|
||||
ddmul609 multiply -Inf -Inf -> Infinity
|
||||
ddmul610 multiply -1 -Inf -> Infinity
|
||||
ddmul611 multiply -0 -Inf -> NaN Invalid_operation
|
||||
ddmul612 multiply 0 -Inf -> NaN Invalid_operation
|
||||
ddmul613 multiply 1 -Inf -> -Infinity
|
||||
ddmul614 multiply 1000 -Inf -> -Infinity
|
||||
ddmul615 multiply Inf -Inf -> -Infinity
|
||||
|
||||
ddmul621 multiply NaN -Inf -> NaN
|
||||
ddmul622 multiply NaN -1000 -> NaN
|
||||
ddmul623 multiply NaN -1 -> NaN
|
||||
ddmul624 multiply NaN -0 -> NaN
|
||||
ddmul625 multiply NaN 0 -> NaN
|
||||
ddmul626 multiply NaN 1 -> NaN
|
||||
ddmul627 multiply NaN 1000 -> NaN
|
||||
ddmul628 multiply NaN Inf -> NaN
|
||||
ddmul629 multiply NaN NaN -> NaN
|
||||
ddmul630 multiply -Inf NaN -> NaN
|
||||
ddmul631 multiply -1000 NaN -> NaN
|
||||
ddmul632 multiply -1 NaN -> NaN
|
||||
ddmul633 multiply -0 NaN -> NaN
|
||||
ddmul634 multiply 0 NaN -> NaN
|
||||
ddmul635 multiply 1 NaN -> NaN
|
||||
ddmul636 multiply 1000 NaN -> NaN
|
||||
ddmul637 multiply Inf NaN -> NaN
|
||||
|
||||
ddmul641 multiply sNaN -Inf -> NaN Invalid_operation
|
||||
ddmul642 multiply sNaN -1000 -> NaN Invalid_operation
|
||||
ddmul643 multiply sNaN -1 -> NaN Invalid_operation
|
||||
ddmul644 multiply sNaN -0 -> NaN Invalid_operation
|
||||
ddmul645 multiply sNaN 0 -> NaN Invalid_operation
|
||||
ddmul646 multiply sNaN 1 -> NaN Invalid_operation
|
||||
ddmul647 multiply sNaN 1000 -> NaN Invalid_operation
|
||||
ddmul648 multiply sNaN NaN -> NaN Invalid_operation
|
||||
ddmul649 multiply sNaN sNaN -> NaN Invalid_operation
|
||||
ddmul650 multiply NaN sNaN -> NaN Invalid_operation
|
||||
ddmul651 multiply -Inf sNaN -> NaN Invalid_operation
|
||||
ddmul652 multiply -1000 sNaN -> NaN Invalid_operation
|
||||
ddmul653 multiply -1 sNaN -> NaN Invalid_operation
|
||||
ddmul654 multiply -0 sNaN -> NaN Invalid_operation
|
||||
ddmul655 multiply 0 sNaN -> NaN Invalid_operation
|
||||
ddmul656 multiply 1 sNaN -> NaN Invalid_operation
|
||||
ddmul657 multiply 1000 sNaN -> NaN Invalid_operation
|
||||
ddmul658 multiply Inf sNaN -> NaN Invalid_operation
|
||||
ddmul659 multiply NaN sNaN -> NaN Invalid_operation
|
||||
|
||||
-- propagating NaNs
|
||||
ddmul661 multiply NaN9 -Inf -> NaN9
|
||||
ddmul662 multiply NaN8 999 -> NaN8
|
||||
ddmul663 multiply NaN71 Inf -> NaN71
|
||||
ddmul664 multiply NaN6 NaN5 -> NaN6
|
||||
ddmul665 multiply -Inf NaN4 -> NaN4
|
||||
ddmul666 multiply -999 NaN33 -> NaN33
|
||||
ddmul667 multiply Inf NaN2 -> NaN2
|
||||
|
||||
ddmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
|
||||
ddmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
|
||||
ddmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
|
||||
ddmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
|
||||
ddmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
|
||||
ddmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
|
||||
ddmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
|
||||
ddmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
|
||||
ddmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
|
||||
|
||||
ddmul681 multiply -NaN9 -Inf -> -NaN9
|
||||
ddmul682 multiply -NaN8 999 -> -NaN8
|
||||
ddmul683 multiply -NaN71 Inf -> -NaN71
|
||||
ddmul684 multiply -NaN6 -NaN5 -> -NaN6
|
||||
ddmul685 multiply -Inf -NaN4 -> -NaN4
|
||||
ddmul686 multiply -999 -NaN33 -> -NaN33
|
||||
ddmul687 multiply Inf -NaN2 -> -NaN2
|
||||
|
||||
ddmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
|
||||
ddmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
|
||||
ddmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
|
||||
ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
|
||||
ddmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
|
||||
ddmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
|
||||
ddmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
|
||||
ddmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
|
||||
ddmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
|
||||
|
||||
ddmul701 multiply -NaN -Inf -> -NaN
|
||||
ddmul702 multiply -NaN 999 -> -NaN
|
||||
ddmul703 multiply -NaN Inf -> -NaN
|
||||
ddmul704 multiply -NaN -NaN -> -NaN
|
||||
ddmul705 multiply -Inf -NaN0 -> -NaN
|
||||
ddmul706 multiply -999 -NaN -> -NaN
|
||||
ddmul707 multiply Inf -NaN -> -NaN
|
||||
|
||||
ddmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
|
||||
ddmul712 multiply -sNaN -11 -> -NaN Invalid_operation
|
||||
ddmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
|
||||
ddmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
|
||||
ddmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
|
||||
ddmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
|
||||
ddmul717 multiply 088 -sNaN -> -NaN Invalid_operation
|
||||
ddmul718 multiply Inf -sNaN -> -NaN Invalid_operation
|
||||
ddmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
|
||||
|
||||
-- overflow and underflow tests .. note subnormal results
|
||||
-- signs
|
||||
ddmul751 multiply 1e+277 1e+311 -> Infinity Overflow Inexact Rounded
|
||||
ddmul752 multiply 1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
|
||||
ddmul753 multiply -1e+277 1e+311 -> -Infinity Overflow Inexact Rounded
|
||||
ddmul754 multiply -1e+277 -1e+311 -> Infinity Overflow Inexact Rounded
|
||||
ddmul755 multiply 1e-277 1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul756 multiply 1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul757 multiply -1e-277 1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul758 multiply -1e-277 -1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
|
||||
-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
|
||||
ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
|
||||
ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
|
||||
ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
|
||||
ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
|
||||
ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
|
||||
ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
|
||||
ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
|
||||
ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
-- [no equivalent of 'subnormal' for overflow]
|
||||
ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381 Clamped
|
||||
ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382 Clamped
|
||||
ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383 Clamped
|
||||
ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384 Clamped
|
||||
ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
|
||||
ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
|
||||
ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
|
||||
ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
|
||||
ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
|
||||
ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded
|
||||
|
||||
ddmul801 multiply 1.0000E-394 1 -> 1.0000E-394 Subnormal
|
||||
ddmul802 multiply 1.000E-394 1e-1 -> 1.000E-395 Subnormal
|
||||
ddmul803 multiply 1.00E-394 1e-2 -> 1.00E-396 Subnormal
|
||||
ddmul804 multiply 1.0E-394 1e-3 -> 1.0E-397 Subnormal
|
||||
ddmul805 multiply 1.0E-394 1e-4 -> 1E-398 Subnormal Rounded
|
||||
ddmul806 multiply 1.3E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul807 multiply 1.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul808 multiply 1.7E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul809 multiply 2.3E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul810 multiply 2.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul811 multiply 2.7E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul812 multiply 1.49E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul813 multiply 1.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul814 multiply 1.51E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul815 multiply 2.49E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul816 multiply 2.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul817 multiply 2.51E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
|
||||
|
||||
ddmul818 multiply 1E-394 1e-4 -> 1E-398 Subnormal
|
||||
ddmul819 multiply 3E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul820 multiply 5E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul821 multiply 7E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul822 multiply 9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul823 multiply 9.9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
|
||||
|
||||
ddmul824 multiply 1E-394 -1e-4 -> -1E-398 Subnormal
|
||||
ddmul825 multiply 3E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul826 multiply -5E-394 1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul827 multiply 7E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul828 multiply -9E-394 1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul829 multiply 9.9E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
|
||||
ddmul830 multiply 3.0E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
|
||||
ddmul831 multiply 1.0E-199 1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
|
||||
ddmul832 multiply 1.0E-199 1e-199 -> 1E-398 Subnormal Rounded
|
||||
ddmul833 multiply 1.0E-199 1e-198 -> 1.0E-397 Subnormal
|
||||
ddmul834 multiply 2.0E-199 2e-198 -> 4.0E-397 Subnormal
|
||||
ddmul835 multiply 4.0E-199 4e-198 -> 1.60E-396 Subnormal
|
||||
ddmul836 multiply 10.0E-199 10e-198 -> 1.000E-395 Subnormal
|
||||
ddmul837 multiply 30.0E-199 30e-198 -> 9.000E-395 Subnormal
|
||||
ddmul838 multiply 40.0E-199 40e-188 -> 1.6000E-384 Subnormal
|
||||
ddmul839 multiply 40.0E-199 40e-187 -> 1.6000E-383
|
||||
ddmul840 multiply 40.0E-199 40e-186 -> 1.6000E-382
|
||||
|
||||
-- Long operand overflow may be a different path
|
||||
ddmul870 multiply 100 9.999E+383 -> Infinity Inexact Overflow Rounded
|
||||
ddmul871 multiply 100 -9.999E+383 -> -Infinity Inexact Overflow Rounded
|
||||
ddmul872 multiply 9.999E+383 100 -> Infinity Inexact Overflow Rounded
|
||||
ddmul873 multiply -9.999E+383 100 -> -Infinity Inexact Overflow Rounded
|
||||
|
||||
-- check for double-rounded subnormals
|
||||
ddmul881 multiply 1.2347E-355 1.2347E-40 -> 1.524E-395 Inexact Rounded Subnormal Underflow
|
||||
ddmul882 multiply 1.234E-355 1.234E-40 -> 1.523E-395 Inexact Rounded Subnormal Underflow
|
||||
ddmul883 multiply 1.23E-355 1.23E-40 -> 1.513E-395 Inexact Rounded Subnormal Underflow
|
||||
ddmul884 multiply 1.2E-355 1.2E-40 -> 1.44E-395 Subnormal
|
||||
ddmul885 multiply 1.2E-355 1.2E-41 -> 1.44E-396 Subnormal
|
||||
ddmul886 multiply 1.2E-355 1.2E-42 -> 1.4E-397 Subnormal Inexact Rounded Underflow
|
||||
ddmul887 multiply 1.2E-355 1.3E-42 -> 1.6E-397 Subnormal Inexact Rounded Underflow
|
||||
ddmul888 multiply 1.3E-355 1.3E-42 -> 1.7E-397 Subnormal Inexact Rounded Underflow
|
||||
ddmul889 multiply 1.3E-355 1.3E-43 -> 2E-398 Subnormal Inexact Rounded Underflow
|
||||
ddmul890 multiply 1.3E-356 1.3E-43 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
|
||||
|
||||
ddmul891 multiply 1.2345E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
|
||||
ddmul892 multiply 1.23456E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
|
||||
ddmul893 multiply 1.2345E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
|
||||
ddmul894 multiply 1.23456E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
|
||||
ddmul895 multiply 1.2345E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
|
||||
ddmul896 multiply 1.23456E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
|
||||
|
||||
-- Now explore the case where we get a normal result with Underflow
|
||||
-- 1 234567890123456
|
||||
ddmul900 multiply 0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
|
||||
ddmul901 multiply 0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
|
||||
ddmul902 multiply 9.999999999999999E-383 0.0999999999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
|
||||
ddmul903 multiply 9.999999999999999E-383 0.09999999999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
|
||||
ddmul904 multiply 9.999999999999999E-383 0.099999999999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
|
||||
ddmul905 multiply 9.999999999999999E-383 0.0999999999999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
|
||||
-- The next rounds to Nmin (b**emin); this is the distinguishing case
|
||||
-- for detecting tininess (before or after rounding) -- if after
|
||||
-- rounding then the result would be the same, but the Underflow flag
|
||||
-- would not be set
|
||||
ddmul906 multiply 9.999999999999999E-383 0.09999999999999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
|
||||
-- prove those operands were exact
|
||||
ddmul907 multiply 9.999999999999999E-383 1 -> 9.999999999999999E-383
|
||||
ddmul908 multiply 1 0.09999999999999999 -> 0.09999999999999999
|
||||
|
||||
-- reducing tiniest
|
||||
ddmul910 multiply 1e-398 0.99 -> 1E-398 Subnormal Inexact Rounded Underflow
|
||||
ddmul911 multiply 1e-398 0.75 -> 1E-398 Subnormal Inexact Rounded Underflow
|
||||
ddmul912 multiply 1e-398 0.5 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
|
||||
ddmul913 multiply 1e-398 0.25 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
|
||||
ddmul914 multiply 1e-398 0.01 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
|
||||
|
||||
-- hugest
|
||||
ddmul920 multiply 9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded
|
||||
|
||||
-- power-of-ten edge cases
|
||||
ddmul1001 multiply 1 10 -> 10
|
||||
ddmul1002 multiply 1 100 -> 100
|
||||
ddmul1003 multiply 1 1000 -> 1000
|
||||
ddmul1004 multiply 1 10000 -> 10000
|
||||
ddmul1005 multiply 1 100000 -> 100000
|
||||
ddmul1006 multiply 1 1000000 -> 1000000
|
||||
ddmul1007 multiply 1 10000000 -> 10000000
|
||||
ddmul1008 multiply 1 100000000 -> 100000000
|
||||
ddmul1009 multiply 1 1000000000 -> 1000000000
|
||||
ddmul1010 multiply 1 10000000000 -> 10000000000
|
||||
ddmul1011 multiply 1 100000000000 -> 100000000000
|
||||
ddmul1012 multiply 1 1000000000000 -> 1000000000000
|
||||
ddmul1013 multiply 1 10000000000000 -> 10000000000000
|
||||
ddmul1014 multiply 1 100000000000000 -> 100000000000000
|
||||
ddmul1015 multiply 1 1000000000000000 -> 1000000000000000
|
||||
ddmul1021 multiply 10 1 -> 10
|
||||
ddmul1022 multiply 10 10 -> 100
|
||||
ddmul1023 multiply 10 100 -> 1000
|
||||
ddmul1024 multiply 10 1000 -> 10000
|
||||
ddmul1025 multiply 10 10000 -> 100000
|
||||
ddmul1026 multiply 10 100000 -> 1000000
|
||||
ddmul1027 multiply 10 1000000 -> 10000000
|
||||
ddmul1028 multiply 10 10000000 -> 100000000
|
||||
ddmul1029 multiply 10 100000000 -> 1000000000
|
||||
ddmul1030 multiply 10 1000000000 -> 10000000000
|
||||
ddmul1031 multiply 10 10000000000 -> 100000000000
|
||||
ddmul1032 multiply 10 100000000000 -> 1000000000000
|
||||
ddmul1033 multiply 10 1000000000000 -> 10000000000000
|
||||
ddmul1034 multiply 10 10000000000000 -> 100000000000000
|
||||
ddmul1035 multiply 10 100000000000000 -> 1000000000000000
|
||||
ddmul1041 multiply 100 0.1 -> 10.0
|
||||
ddmul1042 multiply 100 1 -> 100
|
||||
ddmul1043 multiply 100 10 -> 1000
|
||||
ddmul1044 multiply 100 100 -> 10000
|
||||
ddmul1045 multiply 100 1000 -> 100000
|
||||
ddmul1046 multiply 100 10000 -> 1000000
|
||||
ddmul1047 multiply 100 100000 -> 10000000
|
||||
ddmul1048 multiply 100 1000000 -> 100000000
|
||||
ddmul1049 multiply 100 10000000 -> 1000000000
|
||||
ddmul1050 multiply 100 100000000 -> 10000000000
|
||||
ddmul1051 multiply 100 1000000000 -> 100000000000
|
||||
ddmul1052 multiply 100 10000000000 -> 1000000000000
|
||||
ddmul1053 multiply 100 100000000000 -> 10000000000000
|
||||
ddmul1054 multiply 100 1000000000000 -> 100000000000000
|
||||
ddmul1055 multiply 100 10000000000000 -> 1000000000000000
|
||||
ddmul1061 multiply 1000 0.01 -> 10.00
|
||||
ddmul1062 multiply 1000 0.1 -> 100.0
|
||||
ddmul1063 multiply 1000 1 -> 1000
|
||||
ddmul1064 multiply 1000 10 -> 10000
|
||||
ddmul1065 multiply 1000 100 -> 100000
|
||||
ddmul1066 multiply 1000 1000 -> 1000000
|
||||
ddmul1067 multiply 1000 10000 -> 10000000
|
||||
ddmul1068 multiply 1000 100000 -> 100000000
|
||||
ddmul1069 multiply 1000 1000000 -> 1000000000
|
||||
ddmul1070 multiply 1000 10000000 -> 10000000000
|
||||
ddmul1071 multiply 1000 100000000 -> 100000000000
|
||||
ddmul1072 multiply 1000 1000000000 -> 1000000000000
|
||||
ddmul1073 multiply 1000 10000000000 -> 10000000000000
|
||||
ddmul1074 multiply 1000 100000000000 -> 100000000000000
|
||||
ddmul1075 multiply 1000 1000000000000 -> 1000000000000000
|
||||
ddmul1081 multiply 10000 0.001 -> 10.000
|
||||
ddmul1082 multiply 10000 0.01 -> 100.00
|
||||
ddmul1083 multiply 10000 0.1 -> 1000.0
|
||||
ddmul1084 multiply 10000 1 -> 10000
|
||||
ddmul1085 multiply 10000 10 -> 100000
|
||||
ddmul1086 multiply 10000 100 -> 1000000
|
||||
ddmul1087 multiply 10000 1000 -> 10000000
|
||||
ddmul1088 multiply 10000 10000 -> 100000000
|
||||
ddmul1089 multiply 10000 100000 -> 1000000000
|
||||
ddmul1090 multiply 10000 1000000 -> 10000000000
|
||||
ddmul1091 multiply 10000 10000000 -> 100000000000
|
||||
ddmul1092 multiply 10000 100000000 -> 1000000000000
|
||||
ddmul1093 multiply 10000 1000000000 -> 10000000000000
|
||||
ddmul1094 multiply 10000 10000000000 -> 100000000000000
|
||||
ddmul1095 multiply 10000 100000000000 -> 1000000000000000
|
||||
|
||||
ddmul1097 multiply 10000 99999999999 -> 999999999990000
|
||||
ddmul1098 multiply 10000 99999999999 -> 999999999990000
|
||||
|
||||
|
||||
-- Null tests
|
||||
ddmul9990 multiply 10 # -> NaN Invalid_operation
|
||||
ddmul9991 multiply # 10 -> NaN Invalid_operation
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue