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

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