HPGCC3 Documentation 3.0 R003

decSingle.h

Go to the documentation of this file.
00001 /* ------------------------------------------------------------------ */
00002 /* decSingle.h -- Decimal 32-bit format module header                 */
00003 /* ------------------------------------------------------------------ */
00004 /* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
00005 /*                                                                    */
00006 /* This software is made available under the terms of the             */
00007 /* ICU License -- ICU 1.8.1 and later.                                */
00008 /*                                                                    */
00009 /* Please see decFloats.h for an overview and documentation details.  */
00010 /*                                                                    */
00011 /* Please send comments, suggestions, and corrections to the author:  */
00012 /*   mfc@uk.ibm.com  (Mike Cowlishaw FREng, IBM Fellow,               */
00013 /*   IBM UK MP8, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK     */
00014 /* ------------------------------------------------------------------ */
00015 
00016 #if !defined(DECSINGLE)
00017   #define DECSINGLE
00018 
00019   #define DECSINGLENAME       "decSingle"             /* Short name   */
00020   #define DECSINGLETITLE      "Decimal 32-bit datum"  /* Verbose name */
00021   #define DECSINGLEAUTHOR     "Mike Cowlishaw"        /* Who to blame */
00022 
00023   /* parameters for decSingles */
00024   #define DECSINGLE_Bytes    4     /* length                          */
00025   #define DECSINGLE_Pmax     7     /* maximum precision (digits)      */
00026   #define DECSINGLE_Emin   -95     /* minimum adjusted exponent       */
00027   #define DECSINGLE_Emax    96     /* maximum adjusted exponent       */
00028   #define DECSINGLE_EmaxD    3     /* maximum exponent digits         */
00029   #define DECSINGLE_Bias   101     /* bias for the exponent           */
00030   #define DECSINGLE_String  16     /* maximum string length, +1       */
00031   #define DECSINGLE_EconL    6     /* exponent continuation length    */
00032   #define DECSINGLE_Declets  2     /* count of declets                */
00033   /* highest biased exponent (Elimit-1) */
00034   #define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
00035 
00036   /* Required includes                                                */
00037   #include "decContext.h"
00038   #include "decQuad.h"
00039   #include "decDouble.h"
00040 
00041   /* The decSingle decimal 32-bit type, accessible by bytes */
00042   typedef struct {
00043     uint8_t bytes[DECSINGLE_Bytes];     /* fields: 1, 5, 6, 20 bits */
00044     } decSingle;
00045 
00046   /* ---------------------------------------------------------------- */
00047   /* Routines -- implemented as decFloat routines in common files     */
00048   /* ---------------------------------------------------------------- */
00049 
00050   /* Utilities (binary argument(s) or result, extractors, etc.) */
00051   extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
00052   extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
00053   extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
00054   extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
00055   extern int32_t     decSingleGetCoefficient(const decSingle *, uint8_t *);
00056   extern int32_t     decSingleGetExponent(const decSingle *);
00057   extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
00058   extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
00059   extern void        decSingleShow(const decSingle *, const char *);
00060   extern int32_t     decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
00061   extern char      * decSingleToEngString(const decSingle *, char *);
00062   extern int32_t     decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
00063   extern char      * decSingleToString(const decSingle *, char *);
00064   extern decDouble * decSingleToWider(const decSingle *, decDouble *);
00065   extern decSingle * decSingleZero(decSingle *);
00066 
00067   /* (No Arithmetic routines for decSingle) */
00068 
00069   /* Non-computational */
00070   extern uint32_t     decSingleRadix(const decSingle *);
00071   extern const char * decSingleVersion(void);
00072 
00073   /* decNumber conversions; these are implemented as macros so as not  */
00074   /* to force a dependency on decimal32 and decNumber in decSingle.    */
00075   #define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)
00076   #define decSingleFromNumber(dq, dn, set) (decSingle *)decimal32FromNumber((decimal32 *)(dq), dn, set)
00077 
00078 #endif