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); }
protected RPN_Stack _dealWithClergy2(MK52_Host components) { RPN_Stack s = _Stack(components); if (s.X.isEmpty() || s.Y.isEmpty()) { return(null); } double valueX = s.X.toReal(); double valueY = s.Y.toReal(); if (double.IsNaN(valueX) && double.IsNaN(valueY)) { s.pop(2); // remove Y, leave one NaN in X return(null); } if (double.IsNaN(valueX)) { s.pop(1); // remove X, leave Y return(null); } if (double.IsNaN(valueY)) { s.pop(2); // remove Y, leave X return(null); } return(s); // the rest of ariphmetics }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } double valueX = s.X.toReal(); double valueY = s.Y.toReal(); double result = valueY / valueX; if (double.IsNaN(result) || double.IsNegativeInfinity(result) || double.IsPositiveInfinity(result) || s.X.isReal() || s.Y.isReal()) { s.pop(0); // store Bx, remove X s.X.fromReal(result); return; } Int64 frac = s.Y.toInt() % s.X.toInt(); Int64 res = s.Y.toInt() / s.X.toInt(); s.pop(0); // store Bx, remove X if (frac == 0) { s.X.fromInt(res); // exact division } else { s.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; 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(); if (s.X.isInt()) { return; } double x = s.X.toReal(); bool positive = true; if (x < 0.0) { positive = false; x = -x; } double degr = Math.Floor(x); double sec = (x - degr) * 3600.0; double min = Math.Floor(sec / 60.0); sec -= min * 60.0; x = degr + 0.01 * (min + sec * 0.01); s.X.fromReal(positive ? x : -x); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } double valueX = s.X.toReal(); double valueY = s.Y.toReal(); double result = valueY * valueX; if (result < UniversalValue.HUGE_NEGATIVE_AS_REAL || UniversalValue.HUGE_POSITIVE_AS_REAL < result || s.X.isReal() || s.Y.isReal()) { s.pop(0); // store Bx, remove X s.X.fromReal(result); return; } Int64 res = s.Y.toInt() * s.X.toInt(); s.pop(0); // store Bx, remove X s.X.fromInt(res); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } double x = s.X.toReal(); double y = s.Y.toReal(); s.pop(0); if (x <= 0.0 || y <= 0.0) { s.X.fromReal(double.NaN); return; } if (y == 1.0) { s.X.fromReal(double.PositiveInfinity); return; } double result = Math.Log(y) / Math.Log(x); s.X.fromReal(result); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); if (s.X.isInt()) { return; } double x = s.X.toReal(); bool positive = true; if (x < 0.0) { positive = false; x = -x; } double degr = Math.Floor(x); double mins = (x - degr) * 100.0; if (mins >= 60.0) { s.X.fromReal(double.NaN); return; } x = degr + mins / 60.0; s.X.fromReal(positive ? x : -x); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); if (s.X.isEmpty()) { return; } if (s.X.isInt()) { s.X.fromInt(-s.X.toInt()); return; } double value = s.X.toReal(); if (double.IsNaN(value)) { return; } if (double.IsNegativeInfinity(value)) { s.X.fromReal(double.PositiveInfinity); return; } if (double.IsPositiveInfinity(value)) { s.X.fromReal(double.NegativeInfinity); return; } s.X.fromReal(-value); }
public override void activate(string prevReceiver) { base.activate(prevReceiver); if (prevReceiver.StartsWith("AUTO")) { tick(0); return; } LCD_Manager lm = _parent.getLCD(); RPN_Stack st = _parent._m_RPN_Stack; lm.clearScreen(); lm.outputStatus( _parent._m_Program_Memory.getCounter(), _parent._m_Extended_Memory.getCounter(), _parent._m_RPN_Stack.getDModeName(), " "); lm.outputCalcRegister(0, st.X.toString()); lm.outputCalcLabel(0, st.X_Label); lm.outputCalcRegister(1, st.Y.toString()); lm.outputCalcLabel(1, st.Y_Label); lm.outputCalcRegister(2, st.Z.toString()); lm.outputCalcLabel(2, st.Z_Label); lm.outputCalcRegister(3, st.T.toString()); lm.outputCalcLabel(3, st.T_Label); lm.forcePaint(); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); s.storeBx(); s.push(); s.X.fromReal(UniversalValue.__EE); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); //s.storeBx(); // in MK-52 the Bx is not updated here s.push(); s.X.fromString(command); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); s.storeBx(); double x = s.X.toReal(); s.X.fromReal(x * 1.7453292519943295e-2); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); s.storeBx(); double x = s.X.toReal(); s.X.fromReal(x / 25.4); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); s.storeBx(); s.push(); double result = components._m_RPN_Functions.myRNG.NextDouble(); s.X.fromReal(result); }
public void init(MK52_Host components) { _parent = components; _rst = _parent._m_RPN_Stack; _emem = _parent._m_Extended_Memory; for (int i = 0; i < REGISTER_MEMORY_NVALS; i++) { m_Values.Add(new UniversalValue()); } clear(); }
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); int result = 1; if (s != null) { result = (int)(s.X.toInt() & 0x7FFF); } components._m_RPN_Functions.myRNG = new Random(result); s.pop(0); }
public override void activate(string prevReceiver) { base.activate(prevReceiver); LCD_Manager lm = _parent.getLCD(); lm.updateStatusFMODE("NUM"); lm.forcePaint(); _stackInput = _parent._m_RPN_Stack; _stackInput._DataEntry = new StringBuilder(); _stackInput._DataEntry.Append(' '); _mode = _Whole; }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); double x = s.X.toReal(); s.X.fromReal(1.0 / x); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); bool result = s.X.toInt() > 0; s.X.fromInt(result? 0: 1); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); switch (s.XtoOctant()) { case -1: break; case 0: case 4: s.X.fromInt(0); return; case 1: case 5: s.X.fromInt(1); return; case 2: s.X.fromReal(double.PositiveInfinity); return; case 3: case 7: s.X.fromInt(-1); return; case 6: s.X.fromReal(double.NegativeInfinity); return; default: break; } double result = s.XtoRadian(); if (double.IsInfinity(result)) { s.X.fromReal(double.NaN); return; } s.setTrigAccuracyWarning(result); result = Math.Tan(result); s.X.fromReal(result); }
protected RPN_Stack _dealWithClergy1(MK52_Host components) { RPN_Stack s = _Stack(components); if (s.X.isEmpty()) { return(null); } if (double.IsNaN(s.X.toReal())) { return(null); } return(s); // the rest of ariphmetics }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _Stack(components); s.storeBx(); s.push(); UniversalValue X = s.X; _ExtMem(components).toUV(X); if (X.isEmpty()) { X.fromInt(0); } }
public override void execute(MK52_Host components, string command) { RPN_Stack st = _Stack(components); Program_Memory pm = _ProgMem(components); if (st.X.toReal() == 0.0) { pm.incrementCounter(); } else { pm.setCounter(command); } }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } bool valueX = s.X.toInt() > 0; bool valueY = s.Y.toInt() > 0; s.pop(0); s.X.fromInt((valueX || valueY) ? 1 : 0); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy2(components); if (s == null) { return; } double valueX = s.X.toReal(); double valueY = s.Y.toReal(); if (valueY > valueX) { s.swap(); // keep both values in stack } }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); double result = s.X.toReal(); if (result == 0.0) { return; } s.X.fromInt((result < 0.0) ? -1 : 1); }
public override void execute(MK52_Host components, string command) { RPN_Stack s = _dealWithClergy1(components); if (s == null) { return; } s.storeBx(); double x = s.X.toReal(); if (s.setNegativeRootWarning(x)) { x = -x; } s.X.fromReal(Math.Sqrt(x)); }
public override void execute(MK52_Host components, string command) { RPN_Functions _rpnf = components._m_RPN_Functions; LCD_Manager _lcd = components._m_Hardware_LCD; RPN_Stack _st = components._m_RPN_Stack; Program_Memory _pm = components._m_Program_Memory; Extended_Memory _em = components._m_Extended_Memory; //_lcd.updateStatus(_pm.getCounter(), _em.getCounter(), _st.getDModeName(), "RUN"); //_lcd.updateCalcRegister(0, _st.X.toString()); //_lcd.updateCalcLabel(0, _st.X_Label); //_lcd.updateCalcRegister(1, _st.Y.toString()); //_lcd.updateCalcLabel(1, _st.Y_Label); //_lcd.updateCalcRegister(2, _st.Z.toString()); //_lcd.updateCalcLabel(2, _st.Z_Label); //_lcd.updateCalcRegister(3, _st.T.toString()); //_lcd.updateCalcLabel(3, _st.T_Label); //_lcd.requestUpdate(); }