private void _autoIncrement(int n, UniversalValue uv) { if (n < 0) { return; } if (n > 6) { return; } int delta = (n > 3) ? 1 : -1; if (uv.isInt()) { uv.fromInt(uv.toInt() + delta); return; } if (uv.isReal()) { // TODO: For compatibility, registers are converted to int! // Not sure, if this must be supported or changed //uv.fromReal(uv.toReal() + (double)delta); uv.fromInt(uv.toInt() + delta); return; } }
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; 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) { UniversalValue X = _Stack(components).X; _ExtMem(components).swapWithUV(X); if (X.isEmpty()) { X.fromInt(0); } }
public override void execute(MK52_Host components, string command) { Register_Memory rm = _RegMem(components); UniversalValue ptrE = _ExtMem(components).getCurrentLine(); UniversalValue ptrR = rm._registerAddress(rm.registerByName(command)); if (ptrE.isEmpty()) { ptrR.fromInt(0); return; } ptrR.fromLocation(ptrE); }
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 void XtoM(int n) { if (n < 0 || n >= REGISTER_MEMORY_NVALS) { return; } UniversalValue uv = _registerAddress(n); if (n < 16) { uv.fromLocation(_rst.X); } else { uv.fromInt(_rst.X.toInt()); } }
protected void _executeLoop(MK52_Host components, string command, uint reg) { UniversalValue loopReg = _RegMem(components)._registerAddress((int)reg); Int64 t = loopReg.toInt(); if (t > 0) { loopReg.fromInt(t - 1); } if (loopReg.toInt() > 0) { _ProgMem(components).setCounter(command); } else { _ProgMem(components).incrementCounter(); } }
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); }