1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

1.From Tadashi Saito's advice

to_parts changed to split,assign removed, ** added,bugs in infinite? & nozero? fixed.
2.Rounding functionalities added
  mode now accepts rounding mode.
  round accepts second argument for Bankers' rounding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shigek 2003-06-27 04:38:57 +00:00
parent 7e91b4b546
commit d3ce235bab
4 changed files with 735 additions and 609 deletions

View file

@ -32,7 +32,7 @@ extern "C" {
#define S_INT int
/* Exception codes */
#define VP_EXCEPTION_ALL ((unsigned short)0xFFFF)
#define VP_EXCEPTION_ALL ((unsigned short)0x00FF)
#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001)
#define VP_EXCEPTION_NaN ((unsigned short)0x0002)
#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
@ -43,6 +43,14 @@ extern "C" {
#define VP_EXCEPTION_OP ((unsigned short)0x0020)
#define VP_EXCEPTION_MEMORY ((unsigned short)0x0040)
/* Computation mode */
#define VP_COMP_MODE ((unsigned short)0x0100)
#define VP_COMP_MODE_TRUNCATE 0
#define VP_COMP_MODE_ROUNDUP 1
#define VP_COMP_MODE_CEIL 2
#define VP_COMP_MODE_FLOOR 3
#define VP_COMP_MODE_EVEN 4
#define VP_SIGN_NaN 0 /* NaN */
#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */
#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */
@ -103,6 +111,10 @@ VP_EXPORT double VpGetDoubleNegZero(void);
VP_EXPORT U_LONG VpGetPrecLimit(void);
VP_EXPORT U_LONG VpSetPrecLimit(U_LONG n);
/* Computation mode */
VP_EXPORT unsigned long VpGetCompMode(void);
VP_EXPORT unsigned long VpSetCompMode(unsigned long n);
VP_EXPORT int VpException(unsigned short f,char *str,int always);
VP_EXPORT int VpIsNegDoubleZero(double v);
VP_EXPORT U_LONG VpNumOfChars(Real *vp);
@ -123,14 +135,13 @@ VP_EXPORT void VpVtoD(double *d,S_LONG *e,Real *m);
VP_EXPORT void VpDtoV(Real *m,double d);
VP_EXPORT void VpItoV(Real *m,S_INT ival);
VP_EXPORT int VpSqrt(Real *y,Real *x);
VP_EXPORT void VpRound(Real *y,Real *x,int sw,int f,int il);
VP_EXPORT void VpActiveRound(Real *y,Real *x,int f,int il);
VP_EXPORT void VpFrac(Real *y,Real *x);
VP_EXPORT int VpPower(Real *y,Real *x,S_INT n);
VP_EXPORT void VpPi(Real *y);
VP_EXPORT void VpExp1(Real *y);
VP_EXPORT void VpExp(Real *y,Real *x);
VP_EXPORT void VpSinCos(Real *psin,Real *pcos,Real *x);
VP_EXPORT int VPrint(FILE *fp,char *cntl_chr,Real *a);
/*
* ------------------
@ -177,9 +188,11 @@ VP_EXPORT int VPrint(FILE *fp,char *cntl_chr,Real *a);
#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
#define VpSetInf(a,s) ( ((s)>0)?VpSetPosInf(a):VpSetNegInf(a) )
#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
#ifdef _DEBUG
int VpVarCheck(Real * v);
VP_EXPORT int VPrint(FILE *fp,char *cntl_chr,Real *a);
#endif /* _DEBUG */
#if defined(__cplusplus)