|
Packit Service |
706eca |
/* Decimal 128-bit format module header for the decNumber C Library.
|
|
Packit Service |
706eca |
Copyright (C) 2005-2018 Free Software Foundation, Inc.
|
|
Packit Service |
706eca |
Contributed by IBM Corporation. Author Mike Cowlishaw.
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
This file is part of GCC.
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
GCC is free software; you can redistribute it and/or modify it under
|
|
Packit Service |
706eca |
the terms of the GNU General Public License as published by the Free
|
|
Packit Service |
706eca |
Software Foundation; either version 3, or (at your option) any later
|
|
Packit Service |
706eca |
version.
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
Packit Service |
706eca |
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit Service |
706eca |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit Service |
706eca |
for more details.
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
Under Section 7 of GPL version 3, you are granted additional
|
|
Packit Service |
706eca |
permissions described in the GCC Runtime Library Exception, version
|
|
Packit Service |
706eca |
3.1, as published by the Free Software Foundation.
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
You should have received a copy of the GNU General Public License and
|
|
Packit Service |
706eca |
a copy of the GCC Runtime Library Exception along with this program;
|
|
Packit Service |
706eca |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
Packit Service |
706eca |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* ------------------------------------------------------------------ */
|
|
Packit Service |
706eca |
/* Decimal 128-bit format module header */
|
|
Packit Service |
706eca |
/* ------------------------------------------------------------------ */
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#if !defined(DECIMAL128)
|
|
Packit Service |
706eca |
#define DECIMAL128
|
|
Packit Service |
706eca |
#define DEC128NAME "decimal128" /* Short name */
|
|
Packit Service |
706eca |
#define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */
|
|
Packit Service |
706eca |
#define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* parameters for decimal128s */
|
|
Packit Service |
706eca |
#define DECIMAL128_Bytes 16 /* length */
|
|
Packit Service |
706eca |
#define DECIMAL128_Pmax 34 /* maximum precision (digits) */
|
|
Packit Service |
706eca |
#define DECIMAL128_Emax 6144 /* maximum adjusted exponent */
|
|
Packit Service |
706eca |
#define DECIMAL128_Emin -6143 /* minimum adjusted exponent */
|
|
Packit Service |
706eca |
#define DECIMAL128_Bias 6176 /* bias for the exponent */
|
|
Packit Service |
706eca |
#define DECIMAL128_String 43 /* maximum string length, +1 */
|
|
Packit Service |
706eca |
#define DECIMAL128_EconL 12 /* exp. continuation length */
|
|
Packit Service |
706eca |
/* highest biased exponent (Elimit-1) */
|
|
Packit Service |
706eca |
#define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* check enough digits, if pre-defined */
|
|
Packit Service |
706eca |
#if defined(DECNUMDIGITS)
|
|
Packit Service |
706eca |
#if (DECNUMDIGITS
|
|
Packit Service |
706eca |
#error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#ifndef DECNUMDIGITS
|
|
Packit Service |
706eca |
#define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
#ifndef DECNUMBER
|
|
Packit Service |
706eca |
#include "decNumber.h" /* context and number library */
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* Decimal 128-bit type, accessible by bytes */
|
|
Packit Service |
706eca |
typedef struct {
|
|
Packit Service |
706eca |
uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/
|
|
Packit Service |
706eca |
} decimal128;
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* special values [top byte excluding sign bit; last two bits are */
|
|
Packit Service |
706eca |
/* don't-care for Infinity on input, last bit don't-care for NaN] */
|
|
Packit Service |
706eca |
#if !defined(DECIMAL_NaN)
|
|
Packit Service |
706eca |
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
|
|
Packit Service |
706eca |
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
|
|
Packit Service |
706eca |
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#include "decimal128Local.h"
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* ---------------------------------------------------------------- */
|
|
Packit Service |
706eca |
/* Routines */
|
|
Packit Service |
706eca |
/* ---------------------------------------------------------------- */
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#include "decimal128Symbols.h"
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#ifdef __cplusplus
|
|
Packit Service |
706eca |
extern "C" {
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* String conversions */
|
|
Packit Service |
706eca |
decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
|
|
Packit Service |
706eca |
char * decimal128ToString(const decimal128 *, char *);
|
|
Packit Service |
706eca |
char * decimal128ToEngString(const decimal128 *, char *);
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* decNumber conversions */
|
|
Packit Service |
706eca |
decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
|
|
Packit Service |
706eca |
decContext *);
|
|
Packit Service |
706eca |
decNumber * decimal128ToNumber(const decimal128 *, decNumber *);
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
/* Format-dependent utilities */
|
|
Packit Service |
706eca |
uint32_t decimal128IsCanonical(const decimal128 *);
|
|
Packit Service |
706eca |
decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#ifdef __cplusplus
|
|
Packit Service |
706eca |
}
|
|
Packit Service |
706eca |
#endif
|
|
Packit Service |
706eca |
|
|
Packit Service |
706eca |
#endif
|