Easter-Egg Befehle im MPR Part II - Berechnungen

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 367
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Easter-Egg Befehle im MPR Part II - Berechnungen

Post by Theo_Gottwald » 12. Feb 2017, 12:06

Letzte Woche habe ich mal alte Entwickler-Unterlagen nachgesehen von vor etlichen Jahren.
Und tatsächlich es gibt Befehle, die der MPR kann und die gar nicht in der Hilfe stehen.
Undokumentierte "Geheimbefehle".

Thema in Part II: Wissenschaftliche Berechnungen.
Regulär hat der MPR für Berechnungen nur den CAL\-Befehl. Dieser hat keine richtige Auswertung von Klammern und ist für wissenschaftliche Berechnungen wenig geeignet. Unter der Haube versteckt sich aber ein echter wissenschaftlicher Taschenrechner im MPR. Dazu hat der MPR diese zwei bisher geheimen Befehle.


****************************
m_eval
****************************

Dieser Befehl implementiert einen wissenschaftlichen Formel-Rechner, der relativ langsam arbeitet aber kaum Wünsche offen lässt. Der Rechner ist derzeit nur in englisch implementiert.
Im Fehlerfall erhält man eine aussagekräftige Fehlermeldung, statt des Ergebnisses.

[englisch]
Using extended precision, 18 digits of precision is obtained. Factorials are computed up to 1754! without overflow.

Expressions and functions should follow strictly to standard algebraic syntax rules.
Operators and expressions which can be used are:

+ - * / \ ^ ! ( ) < = > <> >= <=

The Operator Precedence follows algebraic rules.
The only exception is the unary negation operator which in this program does not have a special priority following exponentiation.

However, operations inside parentheses always have the highest priority and are always evaluated first.
Thus by using parentheses in the right places you can always obtain the operator precedence you need for your purpose.

The following operator precedence is used in the program:
1. parentheses ( )
2. unary operators (Factorials (!) )
3. one argument functions
4. exponentiation (^) (power expressions)
5. multiplication (*) and floating-point division (/)
6. integer division (\)
7. modulo (MOD)
8. addition (+), subtraction (-)
9. relational operators (<, <=, =, >=, >, <> )
10. NOT, ISFALSE and ISTRUE
11. AND
12. OR and XOR (exclusive OR)
13. EQV (equivalence)
14. IMP (implication)

These are the implemented trigonometric functions:

"ARCSINH() - Arc (Inverse) Hyperbolic Sine"
"ARCCOSH() - Arc (Inverse) Hyperbolic Cosine"
"ARCTANH() - Arc (Inverse) Hyperbolic Tangent"
"ARCSECH() - Arc (Inverse) Hyperbolic Secant"
"ARCCSCH() - Arc (Inverse) Hyperbolic Cosecant"
"ARCCOTH() - Arc (Inverse) Hyperbolic Cotangent"
"ARCSIN() - Arc (Inverse) Sine"
"ARCCOS() - Arc (Inverse) Cosine"
"ARCSEC() - Arc (Inverse) Secant"
"ARCCSC() - Arc (Inverse) Cosecant"
"ARCCOT() - Arc (Inverse) Cotangent"
"SINH() - Hyperbolic Sine","TANH() - Hyperbolic Tangent"
"SECH() - Hyperbolic Secant"
"CSCH() - Hyperbolic Cosecant"
"COTH() - Hyperbolic Cotangent"
"SEC() - Secant"
"CSC() - Cosecant"
"COT() - Cotangent"
"SIN() - Sine","COS() - Cosine"
"TAN() - Tangent"
"ATN() - Arc (Inverse) Tangent"
"LN() - Natural Log (base E)"
"EXP2() - Exponentiation of 2 or Antilog 2"
"EXP10() - Exponentiation of 10 or Antilog 10"
"EXP() - Exponentiation of E or Antilog E"
"SQR() - Square Root","LOG10() - Common Log (base 10)"
"ABS() - Absolute Value"
"LOG2() - Log (base 2)"
"LOG() - Natural Log (base E)"
"AND - Logical AND"
"XOR - Logical XOR (Exclusive OR)"
"OR - Logical OR"
"MOD - MOD (Modulo)"
"IMP - Logical IMP (Implication)"
"EQV - Logical EQV (Equivalence)"
"NOT - NOT","ISTRUE - Logical Truth"
"ISFALSE - Logical Falsity"
"CEIL() - Ceiling"
"FRAC() - Fractional Part"
"FIX() - Truncate To Integer"
"SGN() - Sign"
"PI# - Constant (3.14159..)"
"E# - Constant (2.71828..)"

A number of constants and conversions are available, making this math evaluator an advanced scientific calculator.
These "known constants" include:

"Foot_TO_meter" = "*1/ 3.28084"
"Meter_TO_foot" , "* 3.28084"
"Inch_TO_centimeter" , "* 2.54"
"Centimeter_TO_inch" , "*1 / 2.54"
"Kilometer_TO_mile" , "*1 / 1.609344"
"Mile_TO_kilometer" , "* 1.609344"
"Inch_TO_foot" , "*1 / 12"
"Foot_TO_inch" , "* 12"
"Yard_TO_meter" , "*1 / 1.093613"
"Meter_TO_yard" , "* 1.093613"
"Fathom_TO_meter" , "* 1.8288"
"Meter_TO_fathom" , "*1 / 1.8288"
"Mile_TO_light-year" , "*1 / 5880000000000"
"Light-year_TO_mile" , "* 5880000000000"
"Parsec_TO_light-year" , "* 3.261643"
"Light-year_TO_parsec" , "*1 / 3.261643"
"Square_ft_TO_square_m" , "*1 / 10.76391"
"Square_m_TO_square_ft" , "* 10.76391"
"Square_in_TO_square_cm" , "* 6.4516"
"Square_cm_TO_square_in" , "*1 / 6.4516"
"Hectare_TO_acre" , "* 2.471054"
"Acre_TO_hectare" , "*1 / 2.471054"
"Pound_TO_kilogram" , "*1 / 2.204623"
"Kilogram_TO_pound" , "* 2.204623"
"Ton_(metric)_TO_Kilogram" , "* 1000"
"Kilogram_TO_ton_(metric)" , "*1 / 1000"
"Ton_(US)_TO_Kilogram" , "* 907.18474"
"Kilogram_TO_ton_(US)" , "*1 / 907.18474"
"Ton_(UK)_TO_Kilogram" , "* 1016.046909"
"Kilogram_TO_ton_(UK)" , "*1 / 1016.046909"
"Ounce_(avoirdupois)_TO_gram" , "* 28.349551"
"Gram_TO_ounce_(avoirdupois)" , "*1 / 28.349551"
"Ounce_(troy)_TO_gram" , "* 31.103508"
"Gram_TO_ounce_(troy)" , "*1 / 31.103508"
"Fahrenheit_TO_Celsius" , "*1 / 1.8 - 32 / 1.8"
"Celsius_TO_Fahrenheit" , "* 1.8 + 32"
"Celsius_TO_Kelvin" , "*1 + 273.16"
"Kelvin_TO_Celsius" , "*1 - 273.16"
"Gallon_(US_dry)_TO_liter" , "* 4.404884"
"Liter_TO_gallon_(US_dry)" , "*1 / 4.404884"
"Gallon_(US_liquid)_TO_liter" , "* 3.785412"
"Liter_TO_gallon_(US_liquid)" , "*1 / 3.785412"
"Quart_(US_dry)_TO_gallon_(US_dry)" , "*1 / 4"
"Gallon_(US_dry)_TO_quart_(US_dry)" , "* 4"
"Pint_TO_liter_(US_dry)" , "* 0.55061"
"Liter_TO_pint_(US_dry)" , "*1 / 0.55061"
"Pint_TO_liter_(US_liquid)" , "* 0.473176"
"Liter_TO_pint_(US_liquid)" , "*1 / 0.473176"
"Cubic_ft_TO_cubic_m" , "*1 / 35.314667"
"Cubic_m_TO_cubic_ft" , "* 35.314667"
"Horsepower_(elec.)_TO_watt" , "* 745.7"
"Watt_TO_horsepower_(elec.)" , "*1 / 745.7"
"Horsepower_(metric)_TO_watt" , "* 735.499"
"Watt_TO_horsepower_(metric)" , "*1 / 735.499"
"BTU/hour_TO_watt" , "* 0.293071"
"Watt_TO_BTU/hour" , "*1 / 0.293071"
"Kilowatt_TO_watt" , "* 1000"
"Watt_TO_kilowatt" , "*1 / 1000"
"Kph_TO_mph" , "*1 / 1.609344"
"Mph_TO_kph" , "* 1.609344"
"Knot_TO_mph" , "* 1.150778"
"Mph_TO_knot" , "*1 / 1.150778"
"Meter/sec_TO_ft/sec" , "* 3.28084"
"Ft/sec_TO_meter/sec" , "*1 / 3.28084"
"Second_TO_minute" , "*1 / 60"
"Minute_TO_second" , "* 60"
"Minute_TO_hour" , "*1 / 60"
"Hour_TO_minute" , "* 60"
"Minute_TO_day" , "*1 / 1440"
"Day_TO_minute" , "* 1440"
"Day_TO_hour" , "* 24"
"Hour_TO_day" , "*1 / 24"
"Psi_TO_pascal" , "* 6894.757"
"Pascal_TO_psi" , "*1 / 6894.757"
"Psi_TO_atmosphere" , "* 0.068046"
"Atmosphere_TO_psi" , "*1 / 0.068046"
"Psi_TO_kg/sqcm" , "* 0.070307"
"Kg/sqcm_TO_psi" , "*1 / 0.070307"
"Degrees_TO_radians" , "* 1.74532925199432958E-2
"Radians_TO_degrees" , "*1 / 1.74532925199432958E-2

Here are the known conversions:

"Acceleration_of_gravity_(m/sec²)" , "9.80665"
"Dry_air_density_at_STP_(kg/m³)" , "1.293"
"Light_speed_in_a_vacuum_(m/sec)" , "299792458"
"Solar_constant_(watts/m²)" , "1340"
"Sound_speed_at_STP_(m/sec)" , "331.4"
"Standard_atmosphere_(nt/m²)" , "101300"
"Earth_equatorial_radius_(m)" , "6378000"
"Earth_escape_velcity_(m/sec)" , "11186"
"Earth_magnetic_dipole_moment_(amp-m²)" , "6.400E21"
"Earth_mass_(kg)" , "5.983E24"
"Earth_mean_angular_rotational_speed_(rads/sec)" , ".0000729"
"Earth_mean_density_(kg/m³)" , "5522"
"Earth_mean_orbital_speed_(m/sec)" , "29770"
"Earth_polar_radius_(m)" , "6357000"
"Earth_volume_(m³)" , "1.087E21"
"Alpha_particle_mass_(kg)" , "6.64465598E-27"
"Electron_charge-mass_ratio_(coul/kg)" , "175881961000"
"Electron_rest_mass_(kg)" , "9.10938188E-31"
"Muon_rest_mass_(kg)" , "1.88353109E-28"
"Neutron_rest_mass_(kg)" , "1.67492716E-27"
"Proton_rest_mass_(kg)" , "1.67262158E-27"
"Atomic_mass_constant_(kg)" , "1.66053873E-27"
"Avogadro_constant_(1/mole)" , "6.02214199E23"
"Boltzmann_constant_(joule/K)" , "1.3806503E-23"
"Elementary_charge_(coul)" , "1.602176462E-19"
"Faraday_constant_(coul/mole)" , "96485.3415"
"Gravitational_constant_(nt-m²/kg²)" , ".000000000066726"
"Permeability_constant_(henry/m)" , "1.25663706143E-6"
"Permittivity_constant_(farad/m)" , "8.85418781762E-12"
"Planck_constant_(joule-sec)" , "6.62606876E-34"
"Rydberg_constant_(1/m)" , "10973731.568549"
"Stefan-Boltzmann_constant_(watt/m²K4)" , ".000000056704"
"Universal_gas_constant_(joule/K-mole)" , "8.314472"
"Wien_displacement_constant_(m-K)" , ".00290"

Input of angles can be in degrees or radians, depending if you specify the "#" as an additional flag.
However, trigonometric output using the ARC functions will always be in radians.
You can transform angles to radians and vice versa.

Beispiel:

Code: Select all

VAR\$$FOR=SIN(1)*Inch_TO_centimeter
' Die Angabe des |# bewirkt Winkelgerechnungen in "Degree" statt "Radian"
GRN\m_eval|$$FOR|#
VAR\$$RES=$v1$
MBX\$$RES

VAR\$$FOR=(5*Inch_TO_centimeter)*Acceleration_of_gravity_(m/sec²)
GRN\m_eval|$$FOR|#>$$RES
MBX\$$RES

****************************
m_calc
****************************


Dieser Befehl ist eine Alternative zum CAL\-Befehl.
Die Implementation ermöglicht das Berechnen von beliebigen, geklammerten Ausdrücken.
Ebenso werden die üblichen Rechenregeln berücksichtigt (Punkt vor Strich etc.).
Zusätzlich kann das Ergebnis auf vielfache Art und Weise gerundet werden.

Es gibt die folgenden Operatoren (Auflistung in der Reihenfolge der Priorität):

' Logische Operatoren - Allerhöchste Priorität
> Größer als
< Kleiner als
= Gleich
! Nicht gleich

^ Hoch - Zweithöchste Priorität

* Multiplikation
% Modulo-Division
/ Division
\ Rest von Division ermitteln

+ Addition
- Subtraktion

Beispiel:

Code: Select all

GRN\m_calc|13\2>$$RES
MBX\$$RES
Das Ergebnis des Befehls kann nun auf vielfache Weise nachbearbeitet werden.
Dazu stehen unter anderem folgende Möglichkeiten zur Verfügung:

|i - Integer, rundet auf die nächste Ganzzahl, die gleich oder größer als das Ergebnis ist
|c - rundet auf die nächst kleinere Ganzzahl, die gleich oder kleiner als das Ergebnis ist
|x - schneidet einfach alle Nachkommastellen ab
|f - fractiona, gibt nur die Nachkommastellen zurück
|a - Absolutwert: Schneidet ein evtl. negatives Vorzeichen weg.
|r - rundet auf 2 Dezimalstellen
|s - Sign, gibt 1,0 oder -1 zurück, je nachdem welches Vorzeichen das Ergebnis hatte

Die Zeichen können auch kombiniert werden und werden dann der Reihe nach verarbeitet.

Beispiele:

Code: Select all

GRN\m_calc|13\2|x>$$RES
MBX\$$RES

GRN\m_calc|-13\2|fa>$$RES
MBX\$$RES

GRN\m_calc|-13\2|xa>$$RES
MBX\$$RES

VAR\$$NAM=10
VAR\$$FOR=(100*$$NUM)+20
GRN\m_calc\$$FOR|ia>$$ERG
MBX\Das Ergebnis ist: $$ERG

Hier noch Mal der Hinweis: Die Befehls stehe nicht in der Hilfe und sind derzeit offiziell nicht vorhanden obwohl sie jeder MPR Nutzer sofort nutzen kann. Also dazu ist kein Update nötig die Befehle sind da schon drin und zwar seit Jahren.

Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 4 guests