root/src/decNumber/decSingle.h

/* [previous][next][first][last][top][bottom][index][help] */
   1 // vim: filetype=c:tabstop=4:ai:expandtab
   2 // SPDX-License-Identifier: ICU
   3 // scspell-id: d897c3bb-f62c-11ec-9f78-80ee73e9b8e7
   4 /* ------------------------------------------------------------------ */
   5 /* decSingle.h -- Decimal 32-bit format module header                 */
   6 /* ------------------------------------------------------------------ */
   7 /* Copyright (c) IBM Corporation, 2000, 2008.  All rights reserved.   */
   8 /*                                                                    */
   9 /* This software is made available under the terms of the             */
  10 /* ICU License -- ICU 1.8.1 and later.                                */
  11 /*                                                                    */
  12 /* The description and User's Guide ("The decNumber C Library") for   */
  13 /* this software is included in the package as decNumber.pdf.  This   */
  14 /* document is also available in HTML, together with specifications,  */
  15 /* testcases, and Web links, on the General Decimal Arithmetic page.  */
  16 /*                                                                    */
  17 /* Please send comments, suggestions, and corrections to the author:  */
  18 /*   mfc@uk.ibm.com                                                   */
  19 /*   Mike Cowlishaw, IBM Fellow                                       */
  20 /*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
  21 /* ------------------------------------------------------------------ */
  22 
  23 #if !defined(DECSINGLE)
  24 # define DECSINGLE
  25 
  26 # define DECSINGLENAME       "decSingle"              /* Short name   */
  27 # define DECSINGLETITLE      "Decimal 32-bit datum"   /* Verbose name */
  28 # define DECSINGLEAUTHOR     "Mike Cowlishaw"         /* Who to blame */
  29 
  30   /* parameters for decSingles */
  31 # define DECSINGLE_Bytes    4      /* length                          */
  32 # define DECSINGLE_Pmax     7      /* maximum precision (digits)      */
  33 # define DECSINGLE_Emin   -95      /* minimum adjusted exponent       */
  34 # define DECSINGLE_Emax    96      /* maximum adjusted exponent       */
  35 # define DECSINGLE_EmaxD    3      /* maximum exponent digits         */
  36 # define DECSINGLE_Bias   101      /* bias for the exponent           */
  37 # define DECSINGLE_String  16      /* maximum string length, +1       */
  38 # define DECSINGLE_EconL    6      /* exponent continuation length    */
  39 # define DECSINGLE_Declets  2      /* count of declets                */
  40   /* highest biased exponent (Elimit-1) */
  41 # define DECSINGLE_Ehigh                                               \
  42     (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
  43 
  44   /* Required includes                                                */
  45 # include "decContext.h"
  46 # include "decQuad.h"
  47 # include "decDouble.h"
  48 
  49   /* The decSingle decimal 32-bit type, accessible by all sizes */
  50   typedef union {
  51     uint8_t   bytes[DECSINGLE_Bytes];   /* fields: 1, 5, 6, 20 bits */
  52     uint16_t shorts[DECSINGLE_Bytes/2];
  53     uint32_t  words[DECSINGLE_Bytes/4];
  54     } decSingle;
  55 
  56   /* ---------------------------------------------------------------- */
  57   /* Routines -- implemented as decFloat routines in common files     */
  58   /* ---------------------------------------------------------------- */
  59 
  60   /* Utilities (binary argument(s) or result, extractors, etc.) */
  61   extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
  62   extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
  63   extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);
  64   extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
  65   extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
  66   extern int32_t     decSingleGetCoefficient(const decSingle *, uint8_t *);
  67   extern int32_t     decSingleGetExponent(const decSingle *);
  68   extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
  69   extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
  70   extern void        decSingleShow(const decSingle *, const char *);
  71   extern int32_t     decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
  72   extern char      * decSingleToEngString(const decSingle *, char *);
  73   extern int32_t     decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
  74   extern char      * decSingleToString(const decSingle *, char *);
  75   extern decDouble * decSingleToWider(const decSingle *, decDouble *);
  76   extern decSingle * decSingleZero(decSingle *);
  77 
  78   /* (No Arithmetic routines for decSingle) */
  79 
  80   /* Non-computational */
  81   extern uint32_t     decSingleRadix(const decSingle *);
  82   extern const char * decSingleVersion(void);
  83 
  84   /* decNumber conversions; these are implemented as macros so as not  */
  85   /* to force a dependency on decimal32 and decNumber in decSingle.    */
  86   /* decSingleFromNumber returns a decimal32 * to avoid warnings.      */
  87 # define decSingleToNumber(dq, dn) \
  88     decimal32ToNumber((decimal32 *)(dq), dn)
  89 # define decSingleFromNumber(dq, dn, set) \
  90     decimal32FromNumber((decimal32 *)(dq), dn, set)
  91 
  92 #endif

/* [previous][next][first][last][top][bottom][index][help] */