Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Map-range/Action-/map-range.action
Normal file
30
Task/Map-range/Action-/map-range.action
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
|
||||
|
||||
PROC Map(REAL POINTER a1,a2,b1,b2,s,res)
|
||||
REAL tmp1,tmp2,tmp3
|
||||
|
||||
RealSub(s,a1,tmp1) ;tmp1=s-a1
|
||||
RealSub(b2,b1,tmp2) ;tmp2=b2-b1
|
||||
RealMult(tmp1,tmp2,tmp3) ;tmp3=(s-a1)*(b2-b1)
|
||||
RealSub(a2,a1,tmp1) ;tmp1=a2-a1
|
||||
RealDiv(tmp3,tmp1,tmp2) ;tmp2=(s-a1)*(b2-b1)/(a2-a1)
|
||||
RealAdd(b1,tmp2,res) ;res=b1+(s-a1)*(b2-b1)/(a2-a1)
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
BYTE i
|
||||
REAL a1,a2,b1,b2,s,res
|
||||
|
||||
Put(125) PutE() ;clear screen
|
||||
|
||||
ValR("0",a1) ValR("10",a2)
|
||||
ValR("-1",b1) ValR("0",b2)
|
||||
|
||||
FOR i=0 TO 10
|
||||
DO
|
||||
IntToReal(i,s)
|
||||
Map(a1,a2,b1,b2,s,res)
|
||||
PrintR(s) Print(" maps to ")
|
||||
PrintRE(res)
|
||||
OD
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue