home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- *
- * RELATIONAL DATABASE SYSTEMS, INC.
- *
- * COPYRIGHT (c) 1981-1986 RELATIONAL DATABASE SYSTEMS, INC., MENLO PARK,
- * CALIFORNIA. All rights reserved. No part of this work covered by the
- * copyright hereon may be reproduced or used in any form or by any means
- * -- graphic, electronic, or mechanical, including photocopying,
- * recording, taping, or information storage and retrieval systems --
- * without permission of RDS.
- *
- * Title: decimal.h
- * Sccsid: @(#)decimal.h 4.6 1/31/86 06:09:08
- * Description:
- * Header file for decimal data type.
- *
- ***************************************************************************
- */
-
-
- /*
- * Unpacked Format (format for program usage)
- *
- * Signed exponent "dec_exp" ranging from -64 to +63
- * Separate sign of mantissa "dec_pos"
- * Base 100 digits (range 0 - 99) with decimal point
- * immediately to the left of first digit.
- */
-
- #ifndef DECSIZE
- #define DECSIZE 16
- #define DECUNKNOWN -2
-
- struct decimal
- {
- short dec_exp; /* exponent base 100 */
- short dec_pos; /* sign: 1=pos, 0=neg, -1=null */
- short dec_ndgts; /* number of significant digits */
- char dec_dgts[DECSIZE]; /* actual digits base 100 */
- };
- typedef struct decimal dec_t;
-
- /*
- * A decimal null will be represented internally by setting dec_pos
- * equal to DECPOSNULL
- */
-
- #define DECPOSNULL (-1)
-
- /*
- * DECLEN calculates minimum number of bytes
- * necessary to hold a decimal(m,n)
- * where m = total # significant digits and
- * n = significant digits to right of decimal
- */
-
- #define DECLEN(m,n) (((m)+((n)&1)+3)/2)
- #define DECLENGTH(len) DECLEN(PRECTOT(len),PRECDEC(len))
-
- /*
- * DECPREC calculates a default precision given
- * number of bytes used to store number
- */
-
- #define DECPREC(size) (((size-1)<<9)+2)
-
- /* macros to look at and make encoded decimal precision
- *
- * PRECTOT(x) return total precision (digits total)
- * PRECDEC(x) return decimal precision (digits to right)
- * PRECMAKE(x,y) make precision from total and decimal
- */
-
- #define PRECTOT(x) (((x)>>8) & 0xff)
- #define PRECDEC(x) ((x) & 0xff)
- #define PRECMAKE(x,y) (((x)<<8) + (y))
-
- /*
- * Packed Format (format in records in files)
- *
- * First byte =
- * top 1 bit = sign 0=neg, 1=pos
- * low 7 bits = Exponent in excess 64 format
- * Rest of bytes = base 100 digits in 100 complement format
- * Notes -- This format sorts numerically with just a
- * simple byte by byte unsigned comparison.
- * Zero is represented as 80,00,00,... (hex).
- * Negative numbers have the exponent complemented
- * and the base 100 digits in 100's complement
- */
-
- #endif /* DECSIZE */
-