Types in engineering problems

Introduction

A batch of a new type has been registered.





The personality of the type is being revealed.





An old joke.





For 38 years now, I have had to solve various problems by drawing up appropriate programs. Over the years, the range of such tasks has turned out to be very large: from programming the AT90S2313 controller to a program for automatically converting the Russian-German technical dictionary into German-Russian, and from calculating the optimal stringer section to drawing a view of the earth's surface from a window from orbit using the backward ray tracing method.





Despite the variety of tasks, all of them, perhaps, can be attributed to one class, which I conventionally call "engineering", since for the most part they operate with concepts of a scientific and technical nature. In solving all these problems, I did not see any benefit in using concepts such as "abstract" type, i.e. assigning some arbitrary property to program objects. Typically, these properties are internally represented as integers when translated.





It may be argued that I do not see the point in such types because in old languages ​​(like the PL / 1 I use) there was no typing at all in the modern sense. No, the concept of type did exist. For example, if in the same PL / 1 you describe two mismatched objects, even if of the same size, and try to assign one to the other, you will get a predictable error message during compilation (Fig. 1).









Figure:  1. Type mismatch error in PL / 1 during compilation.
. 1. PL/1 .

, PL/1? , «» « IEEE-754». .





, . . . , IEEE-754. – . PL/1 «» «».





:





Declare (S1, S2) char(*) varying;
S1=S1||S2;
S1=S1+S2;

      
      



, , , , . , . , PL/1.





, «» , , , . , , , «» - . – , , – / . « »: , … , , ? « » , :





_=([2.6*-0.2]+++[/4]+[/4]-2*) mod 7
      
      



.





«» «» , , «» «». , , – «» . : «» «» - , «» «» «». «» «» , , .





, , , . ?





. , « » [1]. «» – , , - , Matlab Mathcad. PL/1 [2] , , , .





«» , ( , .. ), , , , , .





«» , («-») [3]: , (n+1) a, a1, a2,…an, k , (n+1-k) , 1, 2,… n-k, (n+1) .





- , .





, :





- L ( - ),





- M ( - ),





- T ( - ),





- Θ ( - ),





- I ( - ),





- J ( - ),





- N ( - ),





, , «» , : [x]=Ll Mm Tt Θθ Ii Jj Nn.





, «» , – , , . – .





«»

, , , . , - , - .. «» IEEE-754.





. , X1, X2, X3 [], [] [], X1=X2+X3, X2 0.01 X3 0.001, X1 1000.





– «» , .. «» . «» .





, , – . , «» , , .





«»

, – ( - ) ( - ).





. , – . () . , PL/1 sin, sind, . «» «» «» «», π/180.





, «» , , , sin , . , :





W=φ/t;    // ( )





V=R*W;    // ( )





, φ «» «», , W «» « », – « », « ».





«» , , . «» , (.. ). – «», .. . φ/t ( W) «» «, », R*W «» « ». , , sin(2*φ) - «» «».





«»

, , , «» . PL/1 IEEE-754 , .





«» , , Z=SQRT(X**2+Y**2), «» ( ) . . , -128 127, «» 8+9*2=26 .





«»

«» , «» .





«» . , , , .





«» .





- «» . - «» , - . , X**(1e0/3e0) «» X 1/3, .. .





, . , .. . «» , «» «» , .





, , «» , , , , . . (, ), . «» .





«»

«» ( ), , PL/1, :





Declare V float(53) [/];





, , , , , : , , , , , , , , . «».





:





Declare Mu float(53) [(1000*m)**3/c**2];







Declare Fi float(53) [/180*];







«» , %replace «» , :





%Replace







[]   by [1000*],







[]  by [3600*c],







[] by [1852*],







[] by [/];















Declare







      float(53) [/],







_ float(53) [];







%Replace «», «», «» «» «» , .





«»

«» , . , , , ?





«» , :





V=10 [/];





. - , . , , . :





Declare 

// 

g  float(53) static init(9.81e0) [/c**2],

v0 float(53) static init(10e0)   [/],

// 

m  float(53) [],

v  float(53) [/],
float(53) [*/**2];


v=v0;  F=g*m;
      
      



0. «» :





v=0;   F,m=0;







«»

PL/1 / : , read/write get/put.





, read/write - «» .





«» . – , «» , , , , , , .





put get «» get, .. , .





, PL/1 , .. «» , .. «» , «» , , :





Declare

X1 float(53) static init(10e0) [],

X2 float(53) defined(X1);

 

put skip list(X1,X2);
      
      



10000 10.





?TYPE «»

«» , , TYPE, «» . () ?TYPE, «» (.. ) .





, «» , «» , . «» , , :





put skip list(s/t,type(s/t));





, , :





Declare
float(53) static init(10) [],
float(53) static init(5)  [];


put skip list(s,?type,t,?type,s/t,?type);
      
      



(. 2):





Figure:  2. Using the built-in variable? TYPE when displaying results
. 2. ?TYPE

«»

, , , «» . , , .. .





, , , , .





, , «» :





Declare







// -







Vmod entry((3) float(53)[]) returns(float(53)[]);







, «» ( «?»), .





Declare







//







Vmod0 entry((3) float(53)[?]) returns(float(53)[?]);







SQRT. , , «» , ½.





, , «» .





«»

?TYPE, . , «» (. 3). , , «» .





test:proc main;

%replace

[]  BY [1000*],

[] BY [3600*];

 

declare

s  float(53) static init(10) [],

t  float(53) static init(5)  [],

v  float(53) [/];

 

if s*t>v*t then stop;

      
      



«»

«» , , , . , «» , , «» .





, .. .





.





) , :





//







WEarth  float(53) static init(0.000072921158e0)      [/C],







//







Dpi     float(53) static init(6.28318530717958648e0) [],







// Epsilon/Mu







Em      float(53) static init(66072.1866e0)          [KM**2],







//







Mu      float(53) static init(398600.4e0)            [KM**3/C**2],







// 358







Am      float(53) static init(6736e0)                [KM],







//







Re      float(53) static init(6378.137e0)            [KM],







) , :





:





//---- +-180 ----







do i=1 to 3;







   vsg(i)=vsg0(i)/1000e0;       //







   vrg(i)=vrg0(i)/1000e0;       //







   if Lamseans(i) > 180e0 then Lamseans(i)-=360e0;







end i;







:





//---- +-180 ----







do i=1 to 3;







   vsg(i)=vsg0(i);     //







   vrg(i)=vrg0(i);     //







   if Lamseans(i) > _180 then Lamseans(i)-=_360;







end i;







:





BetaBal=60e0*(per2-per1)/(te2s-te1s)/2e0;   //







:





BetaBal=(per2-per1)/(te2s-te1s)/2e0;        //







) , , :





:





//---- ----







Radius  = J3-et1+dz1*dz1+J4*cos(ArgLat+ArgLat);







Radius *= Axe*(1e0+J7*tp);







:





//---- ----







Radius  = Axe*(1e0+J7*tp)* (J3-et1+dz1*dz1+J4*cos(ArgLat+ArgLat));







. , , , , :





//---- ----







do AxeOfPer=Am, i=1 to 4;                   // 358







 AxeOfPer=((Period/Dpi)**2*Mu)**(1e0/3e0)







         /(1e0-2e0/3e0*Em/AxeOfPer/AxeOfPer*(4e0*CosIncl*CosIncl-1e0));







end;







- :





//---- ----







Fi = Fi + Alz*sin(2e0*Fi);







Alz – , 1/298.257. , Fi , .. . «», , . «» «» .





PL/1 , «» :





- , ;





- , .





«» – , , , / . .





«» , , «» .





«» . «» . , «» «» . .





, - , (, sind) , (- ). .





Mars Climate Orbiter 23 1999 - « » . , «» , , , «-», .





1.       , , . . . , . . , 1989, . 182.





2.       .. « » RSDN Magazine #4 2011, . 15-21.





3. A.S. Romanov, A.V. Semikolenov, S.N. Taranenko, A.P. Shakhorin Theory of similarity and dimension. Boundary layer. Electronic educational publication of the Moscow State Technical University. N.E. Bauman, 2011, p. 8.












All Articles