github.com/matrixorigin/matrixone@v0.7.0/cgo/external/decNumber/decimal32.h (about) 1 /* ------------------------------------------------------------------ */ 2 /* Decimal 32-bit format module header */ 3 /* ------------------------------------------------------------------ */ 4 /* Copyright (c) IBM Corporation, 2000, 2006. All rights reserved. */ 5 /* */ 6 /* This software is made available under the terms of the */ 7 /* ICU License -- ICU 1.8.1 and later. */ 8 /* */ 9 /* The description and User's Guide ("The decNumber C Library") for */ 10 /* this software is called decNumber.pdf. This document is */ 11 /* available, together with arithmetic and format specifications, */ 12 /* testcases, and Web links, on the General Decimal Arithmetic page. */ 13 /* */ 14 /* Please send comments, suggestions, and corrections to the author: */ 15 /* mfc@uk.ibm.com */ 16 /* Mike Cowlishaw, IBM Fellow */ 17 /* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */ 18 /* ------------------------------------------------------------------ */ 19 20 #if !defined(DECIMAL32) 21 #define DECIMAL32 22 #define DEC32NAME "decimal32" /* Short name */ 23 #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ 24 #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ 25 26 /* parameters for decimal32s */ 27 #define DECIMAL32_Bytes 4 /* length */ 28 #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ 29 #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ 30 #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ 31 #define DECIMAL32_Bias 101 /* bias for the exponent */ 32 #define DECIMAL32_String 15 /* maximum string length, +1 */ 33 #define DECIMAL32_EconL 6 /* exp. continuation length */ 34 /* highest biased exponent (Elimit-1) */ 35 #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) 36 37 /* check enough digits, if pre-defined */ 38 #if defined(DECNUMDIGITS) 39 #if (DECNUMDIGITS<DECIMAL32_Pmax) 40 #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use 41 #endif 42 #endif 43 44 #ifndef DECNUMDIGITS 45 #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ 46 #endif 47 #ifndef DECNUMBER 48 #include "decNumber.h" /* context and number library */ 49 #endif 50 51 /* Decimal 32-bit type, accessible by bytes */ 52 typedef struct { 53 uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ 54 } decimal32; 55 56 /* special values [top byte excluding sign bit; last two bits are */ 57 /* don't-care for Infinity on input, last bit don't-care for NaN] */ 58 #if !defined(DECIMAL_NaN) 59 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ 60 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ 61 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ 62 #endif 63 64 /* ---------------------------------------------------------------- */ 65 /* Routines */ 66 /* ---------------------------------------------------------------- */ 67 /* String conversions */ 68 decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); 69 char * decimal32ToString(const decimal32 *, char *); 70 char * decimal32ToEngString(const decimal32 *, char *); 71 72 /* decNumber conversions */ 73 decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, 74 decContext *); 75 decNumber * decimal32ToNumber(const decimal32 *, decNumber *); 76 77 /* Format-dependent utilities */ 78 uint32_t decimal32IsCanonical(const decimal32 *); 79 decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); 80 81 #endif