osprey-gcc-4.2.0/libdecnumber/decNumber.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "config.h"
#include "decNumber.h"
#include "decNumberLocal.h"

Include dependency graph for decNumber.c:

Go to the source code of this file.

Defines

#define __NO_STRING_INLINES
#define DIVIDE   0x80
#define REMAINDER   0x40
#define DIVIDEINT   0x20
#define REMNEAR   0x10
#define COMPARE   0x01
#define COMPMAX   0x02
#define COMPMIN   0x03
#define COMPNAN   0x04
#define DEC_sNaN   0x40000000
#define BADINT   (Int)0x80000000
#define eInt   Int
#define ueInt   uInt
#define QUOT10(u, n)   ((((uInt)(u)>>(n))*multies[n])>>17)
#define decFinish(a, b, c, d)   decFinalize(a,b,c,d)
#define TODIGIT(u, cut, c)

Functions/Subroutines

static decNumberdecAddOp (decNumber *, const decNumber *, const decNumber *, decContext *, uByte, uInt *)
static void decApplyRound (decNumber *, decContext *, Int, uInt *)
static Int decCompare (const decNumber *lhs, const decNumber *rhs)
static decNumberdecCompareOp (decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *)
static void decCopyFit (decNumber *, const decNumber *, decContext *, Int *, uInt *)
static decNumberdecDivideOp (decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *)
static void decFinalize (decNumber *, decContext *, Int *, uInt *)
static Int decGetDigits (const Unit *, Int)
static Int decGetInt (const decNumber *)
static decNumberdecMultiplyOp (decNumber *, const decNumber *, const decNumber *, decContext *, uInt *)
static decNumberdecNaNs (decNumber *, const decNumber *, const decNumber *, uInt *)
static decNumberdecQuantizeOp (decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *)
static void decSetCoeff (decNumber *, decContext *, const Unit *, Int, Int *, uInt *)
static void decSetOverflow (decNumber *, decContext *, uInt *)
static void decSetSubnormal (decNumber *, decContext *, Int *, uInt *)
static Int decShiftToLeast (Unit *, Int, Int)
static Int decShiftToMost (Unit *, Int, Int)
static void decStatus (decNumber *, uInt, decContext *)
static Flag decStrEq (const char *, const char *)
static void decToString (const decNumber *, char[], Flag)
static decNumberdecTrim (decNumber *, Flag, Int *)
static Int decUnitAddSub (const Unit *, Int, const Unit *, Int, Int, Unit *, Int)
static Int decUnitCompare (const Unit *, Int, const Unit *, Int, Int)
char * decNumberToString (const decNumber *dn, char *string)
char * decNumberToEngString (const decNumber *dn, char *string)
decNumberdecNumberFromString (decNumber *dn, const char chars[], decContext *set)
decNumberdecNumberAbs (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberAdd (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberCompare (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberDivide (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberDivideInteger (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberMax (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberMin (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberMinus (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberPlus (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberMultiply (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberNormalize (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberPower (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberQuantize (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberRescale (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberRemainder (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberRemainderNear (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberSameQuantum (decNumber *res, const decNumber *lhs, const decNumber *rhs)
decNumberdecNumberSquareRoot (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberSubtract (decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set)
decNumberdecNumberToIntegralValue (decNumber *res, const decNumber *rhs, decContext *set)
decNumberdecNumberCopy (decNumber *dest, const decNumber *src)
decNumberdecNumberTrim (decNumber *dn)
const char * decNumberVersion (void)
decNumberdecNumberZero (decNumber *dn)
static void decToString (const decNumber *dn, char *string, Flag eng)

Variables

const uInt powers []
static Unit one [] = { 1 }
static const uInt multies [] = { 131073, 26215, 5243, 1049, 210 }
static const uByte resmap [10] = { 0, 3, 3, 3, 3, 5, 7, 7, 7, 7 }


Define Documentation

#define __NO_STRING_INLINES

Definition at line 163 of file decNumber.c.

#define BADINT   (Int)0x80000000

#define COMPARE   0x01

Definition at line 184 of file decNumber.c.

Referenced by arm_rtx_costs(), arm_rtx_costs_1(), arm_size_rtx_costs(), arm_xscale_rtx_costs(), avr_reorg(), avr_rtx_costs(), c4x_valid_operands(), canonicalize_condition(), combine_reversed_comparison_code(), combine_simplify_rtx(), cris_notice_update_cc(), cse_cc_succs(), decCompareOp(), decNumberCompare(), decNumberSquareRoot(), default_rtx_costs(), eliminate_regs(), eliminate_regs_1(), expand_case(), expand_end_case_type(), final_scan_insn(), find_comparison_args(), find_split_point(), frv_ifcvt_modify_insn(), frv_ifcvt_modify_tests(), frv_rtx_costs(), gcse_constant_p(), gen_binary(), gt_ggc_mx_rtx_def(), if_then_else_cond(), init_optabs(), instantiate_virtual_regs_1(), ip2k_rtx_costs(), ix86_match_ccmode(), ix86_rtx_costs(), legitimize_operands(), m32c_compare_redundant(), m68hc11_check_z_replacement(), m68hc11_rtx_costs(), m68hc11_rtx_costs_1(), m68k_rtx_costs(), machine_dependent_reorg(), make_compound_operation(), may_trap_p(), may_trap_p_1(), maybe_eliminate_biv_1(), mention_regs(), notice_update_cc(), peephole2_1(), peephole2_2(), prepare_cmp_insn(), print_exp(), ra_print_rtx_2op(), recog_1(), recog_21(), recog_31(), recog_38(), reverse_comparison(), reversed_comparison_code_parts(), rs6000_rtx_costs(), rtx_needs_barrier(), s390_rtx_costs(), simplify_binary_operation(), simplify_binary_operation_1(), simplify_comparison(), simplify_const_binary_operation(), simplify_const_relational_operation(), simplify_gen_relational(), simplify_relational_operation(), simplify_set(), sparc_rtx_costs(), split_1(), split_2(), subst_constants(), summarize_insn(), thumb_rtx_costs(), try_combine(), vax_rtx_costs(), xstormy16_expand_arith(), xstormy16_split_cbranch(), and xtensa_rtx_costs().

#define COMPMAX   0x02

Definition at line 185 of file decNumber.c.

Referenced by decCompareOp(), and decNumberMax().

#define COMPMIN   0x03

Definition at line 186 of file decNumber.c.

Referenced by decCompareOp(), and decNumberMin().

#define COMPNAN   0x04

Definition at line 187 of file decNumber.c.

Referenced by decCompareOp().

#define DEC_sNaN   0x40000000

Definition at line 189 of file decNumber.c.

Referenced by decNaNs(), and decStatus().

#define decFinish ( a,
b,
c,
d   )     decFinalize(a,b,c,d)

#define DIVIDE   0x80

Definition at line 180 of file decNumber.c.

#define DIVIDEINT   0x20

Definition at line 182 of file decNumber.c.

Referenced by decDivideOp(), and decNumberDivideInteger().

#define eInt   Int

Definition at line 196 of file decNumber.c.

Referenced by decDivideOp(), and decUnitAddSub().

#define QUOT10 ( u,
n   )     ((((uInt)(u)>>(n))*multies[n])>>17)

#define REMAINDER   0x40

Definition at line 181 of file decNumber.c.

Referenced by decDivideOp(), and decNumberRemainder().

#define REMNEAR   0x10

Definition at line 183 of file decNumber.c.

Referenced by decDivideOp(), and decNumberRemainderNear().

#define TODIGIT ( u,
cut,
c   ) 

Value:

{            \
  *(c)='0';                             \
  pow=powers[cut]*2;                    \
  if ((u)>pow) {                        \
    pow*=4;                             \
    if ((u)>=pow) {(u)-=pow; *(c)+=8;}  \
    pow/=2;                             \
    if ((u)>=pow) {(u)-=pow; *(c)+=4;}  \
    pow/=2;                             \
    }                                   \
  if ((u)>=pow) {(u)-=pow; *(c)+=2;}    \
  pow/=2;                               \
  if ((u)>=pow) {(u)-=pow; *(c)+=1;}    \
  }

Definition at line 1987 of file decNumber.c.

Referenced by decToString().

#define ueInt   uInt

Definition at line 197 of file decNumber.c.

Referenced by decUnitAddSub().


Function Documentation

static decNumber * decAddOp ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set,
uByte  negate,
uInt *  status 
) [static]

static void decApplyRound ( decNumber dn,
decContext set,
Int  residue,
uInt *  status 
) [static]

static Int decCompare ( const decNumber lhs,
const decNumber rhs 
) [static]

decNumber * decCompareOp ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set,
Flag  op,
uInt *  status 
) [static]

static void decCopyFit ( decNumber dest,
const decNumber src,
decContext set,
Int *  residue,
uInt *  status 
) [static]

static decNumber * decDivideOp ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set,
Flag  op,
uInt *  status 
) [static]

static void decFinalize ( decNumber dn,
decContext set,
Int *  residue,
uInt *  status 
) [static]

static Int decGetDigits ( const Unit *  uar,
Int  len 
) [static]

Definition at line 5563 of file decNumber.c.

References DECDPUN, Int, pow(), powers, uInt, Unit, and up.

Referenced by decAddOp(), decDivideOp(), and decMultiplyOp().

static Int decGetInt ( const decNumber dn  )  [static]

static decNumber * decMultiplyOp ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set,
uInt *  status 
) [static]

static decNumber * decNaNs ( decNumber res,
const decNumber lhs,
const decNumber rhs,
uInt *  status 
) [static]

decNumber* decNumberAbs ( decNumber res,
const decNumber rhs,
decContext set 
)

decNumber* decNumberAdd ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 685 of file decNumber.c.

References decAddOp(), decStatus(), and uInt.

Referenced by decimal_do_add().

decNumber* decNumberCompare ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 708 of file decNumber.c.

References COMPARE, decCompareOp(), decStatus(), and uInt.

Referenced by decimal_do_compare().

decNumber* decNumberCopy ( decNumber dest,
const decNumber src 
)

decNumber* decNumberDivide ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 731 of file decNumber.c.

References decDivideOp(), decStatus(), DIVIDE, and uInt.

Referenced by decimal_do_divide().

decNumber* decNumberDivideInteger ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 754 of file decNumber.c.

References decDivideOp(), decStatus(), DIVIDEINT, and uInt.

decNumber* decNumberFromString ( decNumber dn,
const char  chars[],
decContext set 
)

decNumber* decNumberMax ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 777 of file decNumber.c.

References COMPMAX, decCompareOp(), decStatus(), and uInt.

decNumber* decNumberMin ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 800 of file decNumber.c.

References COMPMIN, decCompareOp(), decStatus(), and uInt.

decNumber* decNumberMinus ( decNumber res,
const decNumber rhs,
decContext set 
)

Definition at line 824 of file decNumber.c.

References decAddOp(), DECNEG, decNumberZero(), decStatus(), decNumber::exponent, and uInt.

decNumber* decNumberMultiply ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 889 of file decNumber.c.

References decMultiplyOp(), decStatus(), and uInt.

Referenced by decimal_do_multiply().

decNumber* decNumberNormalize ( decNumber res,
const decNumber rhs,
decContext set 
)

decNumber* decNumberPlus ( decNumber res,
const decNumber rhs,
decContext set 
)

decNumber* decNumberPower ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

decNumber* decNumberQuantize ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 1263 of file decNumber.c.

References decQuantizeOp(), decStatus(), and uInt.

Referenced by decNumberToIntegralValue().

decNumber* decNumberRemainder ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 1315 of file decNumber.c.

References decDivideOp(), decStatus(), REMAINDER, and uInt.

decNumber* decNumberRemainderNear ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 1338 of file decNumber.c.

References decDivideOp(), decStatus(), REMNEAR, and uInt.

decNumber* decNumberRescale ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 1292 of file decNumber.c.

References decQuantizeOp(), decStatus(), and uInt.

Referenced by decimal_real_to_integer(), and decimal_real_to_integer2().

decNumber* decNumberSameQuantum ( decNumber res,
const decNumber lhs,
const decNumber rhs 
)

decNumber* decNumberSquareRoot ( decNumber res,
const decNumber rhs,
decContext set 
)

decNumber* decNumberSubtract ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set 
)

Definition at line 1796 of file decNumber.c.

References decAddOp(), DECNEG, decStatus(), and uInt.

Referenced by decimal_do_add().

char* decNumberToEngString ( const decNumber dn,
char *  string 
)

Definition at line 325 of file decNumber.c.

References decToString().

Referenced by decimal128ToEngString(), decimal32ToEngString(), and decimal64ToEngString().

decNumber* decNumberToIntegralValue ( decNumber res,
const decNumber rhs,
decContext set 
)

char* decNumberToString ( const decNumber dn,
char *  string 
)

decNumber* decNumberTrim ( decNumber dn  ) 

Definition at line 1918 of file decNumber.c.

References decTrim(), and Int.

const char* decNumberVersion ( void   ) 

Definition at line 1930 of file decNumber.c.

References DECVERSION.

decNumber* decNumberZero ( decNumber dn  ) 

static decNumber * decQuantizeOp ( decNumber res,
const decNumber lhs,
const decNumber rhs,
decContext set,
Flag  quant,
uInt *  status 
) [static]

static void decSetCoeff ( decNumber dn,
decContext set,
const Unit *  lsu,
Int  len,
Int *  residue,
uInt *  status 
) [static]

static void decSetOverflow ( decNumber dn,
decContext set,
uInt *  status 
) [static]

static void decSetSubnormal ( decNumber dn,
decContext set,
Int *  residue,
uInt *  status 
) [static]

static Int decShiftToLeast ( Unit *  uar,
Int  units,
Int  shift 
) [static]

Definition at line 4507 of file decNumber.c.

References count, DECDPUN, Int, powers, QUOT10, target, Unit, and up.

Referenced by decDivideOp(), decNumberSquareRoot(), and decTrim().

static Int decShiftToMost ( Unit *  uar,
Int  digits,
Int  shift 
) [static]

Definition at line 4448 of file decNumber.c.

References D2U, DECDPUN, first, Int, next, powers, QUOT10, source, target, uInt, and Unit.

Referenced by decAddOp(), decFinalize(), decQuantizeOp(), and decSetSubnormal().

static void decStatus ( decNumber dn,
uInt  status,
decContext set 
) [static]

static Flag decStrEq ( const char *  str1,
const char *  str2 
) [static]

Definition at line 5458 of file decNumber.c.

References char, and tolower().

Referenced by decNumberFromString().

static void decToString ( const decNumber dn,
char *  string,
Flag  eng 
) [static]

static void decToString ( const decNumber ,
char  [],
Flag   
) [static]

static decNumber * decTrim ( decNumber dn,
Flag  all,
Int *  dropped 
) [static]

static Int decUnitAddSub ( const Unit *  a,
Int  alength,
const Unit *  b,
Int  blength,
Int  bshift,
Unit *  c,
Int  m 
) [static]

Definition at line 4148 of file decNumber.c.

References carry, eInt, Int, printf(), ueInt, and Unit.

Referenced by decAddOp(), decApplyRound(), decDivideOp(), decMultiplyOp(), and decUnitCompare().

static Int decUnitCompare ( const Unit *  a,
Int  alength,
const Unit *  b,
Int  blength,
Int  exp 
) [static]

Definition at line 4028 of file decNumber.c.

References BADINT, D2U, DECBUFFER, DECDPUN, decUnitAddSub(), free(), Int, malloc, NULL, powers, r, result, and Unit.

Referenced by decCompare(), and decDivideOp().


Variable Documentation

const uInt multies[] = { 131073, 26215, 5243, 1049, 210 } [static]

Definition at line 201 of file decNumber.c.

Unit one[] = { 1 } [static]

Definition at line 192 of file decNumber.c.

const uInt powers[]

Initial value:

 { 1, 10, 100, 1000, 10000, 100000, 1000000,
  10000000, 100000000, 1000000000
}

Definition at line 175 of file decNumber.c.

Referenced by build_mult_tree(), decAddOp(), decApplyRound(), decDensePackCoeff(), decDenseUnpackCoeff(), decDivideOp(), decGetDigits(), decGetInt(), decSetCoeff(), decSetOverflow(), decShiftToLeast(), decShiftToMost(), decTrim(), and decUnitCompare().

const uByte resmap[10] = { 0, 3, 3, 3, 3, 5, 7, 7, 7, 7 } [static]

Definition at line 4660 of file decNumber.c.


Generated on Wed Apr 8 14:19:24 2009 for Open64 by  doxygen 1.5.6