public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); UniversalValue X = s.X; if (X.isInt()) { X.fromInt(0); return; } double result = X.toReal(); bool positive = true; if (result < 0) { result = -result; positive = false; } result = result - Math.Floor(result); X.fromReal(positive ? result : -result); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); UniversalValue X = s.X; if (X.isInt()) { return; } double result = X.toReal(); if (result < 0) { result = -Math.Floor(-result); } else { result = Math.Floor(result); } X.fromReal(result); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); double result = 1.0; UniversalValue X = s.X; if (X.isReal()) { result = Math.Pow(10.0, X.toReal()); X.fromReal(result); return; } Int64 p = X.toInt(); if (p > 300) { X.fromReal(double.PositiveInfinity); return; } if (p < -300) { X.fromInt(0); return; } if (0 <= p && p <= 18) { Int64 r2 = 1; while (p > 0) { r2 *= 10L; p--; } X.fromInt(r2); return; } while (p > 0) { result *= 10.0; p--; } while (p < 0) { result *= 0.1; p++; } X.fromReal(result); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); UniversalValue X = s.X; double result = X.toReal(); if (result >= 0.0) { return; } if (X.isReal()) { X.fromReal(-result); return; } X.fromInt(-X.toInt()); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } s.pop(0); UniversalValue X_ = s.X; UniversalValue Y_ = s.Bx; if (Y_.isEmpty()) { X_.fromInt(1); return; } double result = 1.0; double x = X_.toReal(); if (Y_.isReal()) { result = Math.Pow(x, Y_.toReal()); X_.fromReal(result); return; } Int64 p = Y_.toInt(); Int64 p2 = p; if (x == 0.0 && p == 0) // special case { X_.fromInt(1); return; } if (x == 0.0 && p < 0) { X_.fromReal(double.PositiveInfinity); return; } while (p > 0) { result *= x; p--; } x = 1.0 / x; while (p < 0) { result *= x; p++; } if (p2 <= 0 || X_.isReal() || Math.Abs(result) > UniversalValue.HUGE_POSITIVE_AS_REAL) { X_.fromReal(result); return; } // Try to keep as integer Int64 result2 = X_.toInt(); Int64 mul = result2; while (p2 > 1) { result2 *= mul; p2--; } X_.fromInt(result2); }