github.com/matrixorigin/matrixone@v0.7.0/cgo/external/decNumber/decimal128.h (about) 1 /* ------------------------------------------------------------------ */ 2 /* Decimal 128-bit format module header */ 3 /* ------------------------------------------------------------------ */ 4 /* Copyright (c) IBM Corporation, 2000, 2005. 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(DECIMAL128) 21 #define DECIMAL128 22 #define DEC128NAME "decimal128" /* Short name */ 23 #define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */ 24 #define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */ 25 26 /* parameters for decimal128s */ 27 #define DECIMAL128_Bytes 16 /* length */ 28 #define DECIMAL128_Pmax 34 /* maximum precision (digits) */ 29 #define DECIMAL128_Emax 6144 /* maximum adjusted exponent */ 30 #define DECIMAL128_Emin -6143 /* minimum adjusted exponent */ 31 #define DECIMAL128_Bias 6176 /* bias for the exponent */ 32 #define DECIMAL128_String 43 /* maximum string length, +1 */ 33 #define DECIMAL128_EconL 12 /* exp. continuation length */ 34 /* highest biased exponent (Elimit-1) */ 35 #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) 36 37 /* check enough digits, if pre-defined */ 38 #if defined(DECNUMDIGITS) 39 #if (DECNUMDIGITS<DECIMAL128_Pmax) 40 #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use 41 #endif 42 #endif 43 44 #ifndef DECNUMDIGITS 45 #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/ 46 #endif 47 #ifndef DECNUMBER 48 #include "decNumber.h" /* context and number library */ 49 #endif 50 51 /* Decimal 128-bit type, accessible by bytes */ 52 typedef struct { 53 uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/ 54 } decimal128; 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 decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); 69 char * decimal128ToString(const decimal128 *, char *); 70 char * decimal128ToEngString(const decimal128 *, char *); 71 72 /* decNumber conversions */ 73 decimal128 * decimal128FromNumber(decimal128 *, const decNumber *, 74 decContext *); 75 decNumber * decimal128ToNumber(const decimal128 *, decNumber *); 76 77 /* Format-dependent utilities */ 78 uint32_t decimal128IsCanonical(const decimal128 *); 79 decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); 80 81 #endif