OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libdecnumber/] [decimal64.h] - Blame information for rev 154

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Decimal 64-bit format module header for the decNumber C Library
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
   Contributed by IBM Corporation.  Author Mike Cowlishaw.
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software; you can redistribute it and/or modify it under
8
   the terms of the GNU General Public License as published by the Free
9
   Software Foundation; either version 2, or (at your option) any later
10
   version.
11
 
12
   In addition to the permissions in the GNU General Public License,
13
   the Free Software Foundation gives you unlimited permission to link
14
   the compiled version of this file into combinations with other
15
   programs, and to distribute those combinations without any
16
   restriction coming from the use of this file.  (The General Public
17
   License restrictions do apply in other respects; for example, they
18
   cover modification of the file, and distribution when not linked
19
   into a combine executable.)
20
 
21
   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
   for more details.
25
 
26
   You should have received a copy of the GNU General Public License
27
   along with GCC; see the file COPYING.  If not, write to the Free
28
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29
   02110-1301, USA.  */
30
 
31
#if !defined(DECIMAL64)
32
#define DECIMAL64
33
#define DEC64NAME     "decimal64"       /* Short name */
34
#define DEC64FULLNAME "Decimal 64-bit Number"   /* Verbose name */
35
#define DEC64AUTHOR   "Mike Cowlishaw"  /* Who to blame */
36
 
37
#if defined(DECIMAL32)
38
#error decimal64.h must precede decimal32.h for correct DECNUMDIGITS
39
#endif
40
 
41
  /* parameters for decimal64s */
42
#define DECIMAL64_Bytes  8      /* length */
43
#define DECIMAL64_Pmax   16     /* maximum precision (digits) */
44
#define DECIMAL64_Emax   384    /* maximum adjusted exponent */
45
#define DECIMAL64_Emin  -383    /* minimum adjusted exponent */
46
#define DECIMAL64_Bias   398    /* bias for the exponent */
47
#define DECIMAL64_String 24     /* maximum string length, +1 */
48
  /* highest biased exponent (Elimit-1) */
49
#define DECIMAL64_Ehigh  (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
50
 
51
#ifndef DECNUMDIGITS
52
#define DECNUMDIGITS DECIMAL64_Pmax     /* size if not already defined */
53
#endif
54
#ifndef DECNUMBER
55
#include "decNumber.h"          /* context and number library */
56
#endif
57
 
58
  /* Decimal 64-bit type, accessible by bytes */
59
typedef struct
60
{
61
  uint8_t bytes[DECIMAL64_Bytes];       /* decimal64: 1, 5, 8, 50 bits */
62
} decimal64;
63
 
64
  /* special values [top byte excluding sign bit; last two bits are
65
     don't-care for Infinity on input, last bit don't-care for NaN] */
66
#if !defined(DECIMAL_NaN)
67
#define DECIMAL_NaN     0x7c    /* 0 11111 00 NaN */
68
#define DECIMAL_sNaN    0x7e    /* 0 11111 10 sNaN */
69
#define DECIMAL_Inf     0x78    /* 0 11110 00 Infinity */
70
#endif
71
 
72
  /* Macros for accessing decimal64 fields.  These assume the argument
73
     is a reference (pointer) to the decimal64 structure */
74
  /* Get sign */
75
#define decimal64Sign(d)       ((unsigned)(d)->bytes[0]>>7)
76
 
77
  /* Get combination field */
78
#define decimal64Comb(d)       (((d)->bytes[0] & 0x7c)>>2)
79
 
80
  /* Get exponent continuation [does not remove bias] */
81
#define decimal64ExpCon(d)     ((((d)->bytes[0] & 0x03)<<6)         \
82
                               | ((unsigned)(d)->bytes[1]>>2))
83
 
84
  /* Set sign [this assumes sign previously 0] */
85
#define decimal64SetSign(d, b) {                                    \
86
    (d)->bytes[0]|=((unsigned)(b)<<7);}
87
 
88
  /* Set exponent continuation [does not apply bias] */
89
  /* This assumes range has been checked and exponent previously 0; type */
90
  /* of exponent must be unsigned */
91
#define decimal64SetExpCon(d, e) {                                  \
92
    (d)->bytes[0]|=(uint8_t)((e)>>6);                                 \
93
    (d)->bytes[1]|=(uint8_t)(((e)&0x3F)<<2);}
94
 
95
  /* ------------------------------------------------------------------ */
96
  /* Routines                                                           */
97
  /* ------------------------------------------------------------------ */
98
 
99
#ifdef IN_LIBGCC2
100
#define decimal64FromString __decimal64FromString
101
#define decimal64ToString __decimal64ToString
102
#define decimal64ToEngString __decimal64ToEngString
103
#define decimal64FromNumber __decimal64FromNumber
104
#define decimal64ToNumber __decimal64ToNumber
105
#endif
106
 
107
  /* String conversions */
108
decimal64 *decimal64FromString (decimal64 *, const char *, decContext *);
109
char *decimal64ToString (const decimal64 *, char *);
110
char *decimal64ToEngString (const decimal64 *, char *);
111
 
112
  /* decNumber conversions */
113
decimal64 *decimal64FromNumber (decimal64 *, const decNumber *, decContext *);
114
decNumber *decimal64ToNumber (const decimal64 *, decNumber *);
115
 
116
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.