OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [libdecnumber/] [decimal32.h] - Blame information for rev 284

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

Line No. Rev Author Line
1 38 julius
/* Decimal 32-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(DECIMAL32)
32
#define DECIMAL32
33
#define DEC32NAME     "decimal32"       /* Short name */
34
#define DEC32FULLNAME "Decimal 32-bit Number"   /* Verbose name */
35
#define DEC32AUTHOR   "Mike Cowlishaw"  /* Who to blame */
36
 
37
  /* parameters for decimal32s */
38
#define DECIMAL32_Bytes  4      /* length */
39
#define DECIMAL32_Pmax   7      /* maximum precision (digits) */
40
#define DECIMAL32_Emax   96     /* maximum adjusted exponent */
41
#define DECIMAL32_Emin  -95     /* minimum adjusted exponent */
42
#define DECIMAL32_Bias   101    /* bias for the exponent */
43
#define DECIMAL32_String 15     /* maximum string length, +1 */
44
  /* highest biased exponent (Elimit-1) */
45
#define DECIMAL32_Ehigh  (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
46
 
47
#ifndef DECNUMDIGITS
48
#define DECNUMDIGITS DECIMAL32_Pmax     /* size if not already defined */
49
#endif
50
#ifndef DECNUMBER
51
#include "decNumber.h"          /* context and number library */
52
#endif
53
 
54
  /* Decimal 32-bit type, accessible by bytes */
55
typedef struct
56
{
57
  uint8_t bytes[DECIMAL32_Bytes];       /* decimal32: 1, 5, 6, 20 bits */
58
} decimal32;
59
 
60
  /* special values [top byte excluding sign bit; last two bits are
61
     don't-care for Infinity on input, last bit don't-care for NaN] */
62
#if !defined(DECIMAL_NaN)
63
#define DECIMAL_NaN     0x7c    /* 0 11111 00 NaN */
64
#define DECIMAL_sNaN    0x7e    /* 0 11111 10 sNaN */
65
#define DECIMAL_Inf     0x78    /* 0 11110 00 Infinity */
66
#endif
67
 
68
  /* Macros for accessing decimal32 fields.  These assume the argument
69
     is a reference (pointer) to the decimal32 structure */
70
  /* Get sign */
71
#define decimal32Sign(d)       ((unsigned)(d)->bytes[0]>>7)
72
 
73
  /* Get combination field */
74
#define decimal32Comb(d)       (((d)->bytes[0] & 0x7c)>>2)
75
 
76
  /* Get exponent continuation [does not remove bias] */
77
#define decimal32ExpCon(d)     ((((d)->bytes[0] & 0x03)<<4)         \
78
                               | ((unsigned)(d)->bytes[1]>>4))
79
 
80
  /* Set sign [this assumes sign previously 0] */
81
#define decimal32SetSign(d, b) {                                    \
82
    (d)->bytes[0]|=((unsigned)(b)<<7);}
83
 
84
  /* Set exponent continuation [does not apply bias] */
85
  /* This assumes range has been checked and exponent previously 0; */
86
  /* type of exponent must be unsigned */
87
#define decimal32SetExpCon(d, e) {                                  \
88
    (d)->bytes[0]|=(uint8_t)((e)>>4);                                 \
89
    (d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);}
90
 
91
  /* ------------------------------------------------------------------ */
92
  /* Routines                                                           */
93
  /* ------------------------------------------------------------------ */
94
 
95
#ifdef IN_LIBGCC2
96
#define decimal32FromString __decimal32FromString
97
#define decimal32ToString __decimal32ToString
98
#define decimal32ToEngString __decimal32ToEngString
99
#define decimal32FromNumber __decimal32FromNumber
100
#define decimal32ToNumber __decimal32ToNumber
101
#endif
102
 
103
/* String conversions.  */
104
decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
105
char *decimal32ToString (const decimal32 *, char *);
106
char *decimal32ToEngString (const decimal32 *, char *);
107
 
108
/* decNumber conversions.  */
109
decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *);
110
decNumber *decimal32ToNumber (const decimal32 *, decNumber *);
111
 
112
#endif

powered by: WebSVN 2.1.0

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