Float arithmetic 7.5 except two SQRT methods

This commit is contained in:
Alex Dyachenko 2014-06-05 14:51:06 -04:00
parent 609b9eb948
commit a7fc90ffa1
2 changed files with 34 additions and 12 deletions

View File

@ -272,6 +272,15 @@ private ref class MPEXPR(name) : base
negativeOp(destination, destination, (mpir_ui)-Right); \ negativeOp(destination, destination, (mpir_ui)-Right); \
} }
#define DEFINE_BINARY_ASSIGNMENT_REF_SI2(name, leftTypeAbbr, rightTypeAbbr, operation, negateOp) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
Left->AssignTo(destination); \
operation(destination, destination, (Right >= 0) ? (mpir_ui)Right : (mpir_ui)-Right); \
if (Right < 0) \
negateOp(destination, destination); \
}
#define DEFINE_BINARY_ASSIGNMENT_SI_REF(name, leftTypeAbbr, rightTypeAbbr, positiveOp, negativeOp1, negativeOp2) \ #define DEFINE_BINARY_ASSIGNMENT_SI_REF(name, leftTypeAbbr, rightTypeAbbr, positiveOp, negativeOp1, negativeOp2) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \ DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \ { \
@ -285,6 +294,19 @@ private ref class MPEXPR(name) : base
} \ } \
} }
#define DEFINE_BINARY_ASSIGNMENT_SI_REF2(name, leftTypeAbbr, rightTypeAbbr, positiveOp, negativeOp1, negativeOp2) \
DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \
{ \
Right->AssignTo(destination); \
if (Left >= 0) \
positiveOp(destination, (mpir_ui)Left, destination); \
else \
{ \
negativeOp1(destination, (mpir_ui)-Left, destination); \
negativeOp2(destination, destination); \
} \
}
#define DEFINE_TERNARY_ASSIGNMENT_REF_REF_REF(name, typeAbbr, operation) \ #define DEFINE_TERNARY_ASSIGNMENT_REF_REF_REF(name, typeAbbr, operation) \
DEFINE_ASSIGNMENT_PROLOG(name##typeAbbr##typeAbbr##typeAbbr) \ DEFINE_ASSIGNMENT_PROLOG(name##typeAbbr##typeAbbr##typeAbbr) \
{ \ { \

View File

@ -247,24 +247,24 @@ return result->ToString();
DEFINE_UNARY_ASSIGNMENT_REF(Abs, Flt, MP(abs)) DEFINE_UNARY_ASSIGNMENT_REF(Abs, Flt, MP(abs))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Add, Flt, MP(add)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Add, Flt, MP(add))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Flt, Ui, MP(add)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(Add, Flt, Ui, MP(add_ui))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Flt, Si, MP(add)) DEFINE_BINARY_ASSIGNMENT_REF_SI (Add, Flt, Si, MP(add_ui), MP(sub_ui))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Subtract, Flt, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Subtract, Flt, MP(sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Flt, Ui, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(Subtract, Flt, Ui, MP(sub_ui))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Ui, Flt, MP(sub)) DEFINE_BINARY_ASSIGNMENT_VAL_REF(Subtract, Ui, Flt, MP(ui_sub))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Flt, Si, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_SI (Subtract, Flt, Si, MP(sub_ui), MP(add_ui))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Si, Flt, MP(sub)) DEFINE_BINARY_ASSIGNMENT_SI_REF (Subtract, Si, Flt, MP(ui_sub), MP(add_ui), MP(neg))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Multiply, Flt, MP(mul)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Multiply, Flt, MP(mul))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Flt, Ui, MP(mul)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(Multiply, Flt, Ui, MP(mul_ui))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Flt, Si, MP(mul)) DEFINE_BINARY_ASSIGNMENT_REF_SI2(Multiply, Flt, Si, MP(mul_ui), MP(neg))
DEFINE_BINARY_ASSIGNMENT_REF_REF(Divide, Flt, MP(div)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Divide, Flt, MP(div))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Flt, Ui, MP(div)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(Divide, Flt, Ui, MP(div_ui))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Ui, Flt, MP(div)) DEFINE_BINARY_ASSIGNMENT_VAL_REF(Divide, Ui, Flt, MP(ui_div))
DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Flt, Si, MP(div)) DEFINE_BINARY_ASSIGNMENT_REF_SI2(Divide, Flt, Si, MP(div_ui), MP(neg))
DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Si, Flt, MP(div)) DEFINE_BINARY_ASSIGNMENT_SI_REF2(Divide, Si, Flt, MP(ui_div), MP(ui_div), MP(neg))
DEFINE_BINARY_ASSIGNMENT_REF_VAL(ShiftLeft, Flt, Bits, MP(mul_2exp)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(ShiftLeft, Flt, Bits, MP(mul_2exp))
DEFINE_BINARY_ASSIGNMENT_REF_VAL(ShiftRight, Flt, Bits, MP(div_2exp)) DEFINE_BINARY_ASSIGNMENT_REF_VAL(ShiftRight, Flt, Bits, MP(div_2exp))